- Revision
- 89910
- Author
- [email protected]
- Date
- 2011-06-28 02:20:58 -0700 (Tue, 28 Jun 2011)
Log Message
2011-06-28 Kent Tamura <[email protected]>
Reviewed by Hajime Morita.
Use RefPtr for the HTMLElement data members of TextFieldInptType
and SearchInputType.
https://bugs.webkit.org/show_bug.cgi?id=63511
No new tests because of no behavior change.
* html/SearchInputType.cpp:
(WebCore::SearchInputType::SearchInputType):
No need to initialize the element members explicitly because
RefPtr constructor works well.
(WebCore::SearchInputType::createShadowSubtree):
Substitute an element to a data member, and don't call RefPtr<>::release().
(WebCore::SearchInputType::innerBlockElement):
Moved from the header file, and adjustment for RefPtr<>.
(WebCore::SearchInputType::resultsButtonElement): ditto.
(WebCore::SearchInputType::cancelButtonElement): ditto.
(WebCore::SearchInputType::destroyShadowSubtree):
Adjustment for RefPtr<>.
* html/SearchInputType.h:
- Move accessor functions to the cpp file because they are virtual.
- Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::TextFieldInputType):
No need to initialize the element members explicitly because
RefPtr constructor works well.
(WebCore::TextFieldInputType::~TextFieldInputType):
Explicityly defines the destructor in the cpp file to avoid to
make it implicitly in the header file. If the destructor was made
in the header file, we would need to include HTMLElement.h in the
header file.
(WebCore::TextFieldInputType::createShadowSubtree):
- Don't call RenderTheme::themeForPage().
- Substitute an element to a data member, and don't call RefPtr<>::release().
(WebCore::TextFieldInputType::setInnerTextElement):
Moved from the header file to avoid to include HTMLElement.h.
(WebCore::TextFieldInputType::setSpeechButtonElement): ditto.
(WebCore::TextFieldInputType::innerTextElement):
Moved from the header file, and adjustment for RefPtr<>.
(WebCore::TextFieldInputType::innerSpinButtonElement): ditto.
(WebCore::TextFieldInputType::speechButtonElement): ditto.
(WebCore::TextFieldInputType::destroyShadowSubtree):
Adjustment for RefPtr<>.
* html/TextFieldInputType.h:
- Move accessor functions to the cpp file because they are virtual.
- Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (89909 => 89910)
--- trunk/Source/WebCore/ChangeLog 2011-06-28 09:19:58 UTC (rev 89909)
+++ trunk/Source/WebCore/ChangeLog 2011-06-28 09:20:58 UTC (rev 89910)
@@ -1,3 +1,53 @@
+2011-06-28 Kent Tamura <[email protected]>
+
+ Reviewed by Hajime Morita.
+
+ Use RefPtr for the HTMLElement data members of TextFieldInptType
+ and SearchInputType.
+ https://bugs.webkit.org/show_bug.cgi?id=63511
+
+ No new tests because of no behavior change.
+
+ * html/SearchInputType.cpp:
+ (WebCore::SearchInputType::SearchInputType):
+ No need to initialize the element members explicitly because
+ RefPtr constructor works well.
+ (WebCore::SearchInputType::createShadowSubtree):
+ Substitute an element to a data member, and don't call RefPtr<>::release().
+ (WebCore::SearchInputType::innerBlockElement):
+ Moved from the header file, and adjustment for RefPtr<>.
+ (WebCore::SearchInputType::resultsButtonElement): ditto.
+ (WebCore::SearchInputType::cancelButtonElement): ditto.
+ (WebCore::SearchInputType::destroyShadowSubtree):
+ Adjustment for RefPtr<>.
+ * html/SearchInputType.h:
+ - Move accessor functions to the cpp file because they are virtual.
+ - Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
+ * html/TextFieldInputType.cpp:
+ (WebCore::TextFieldInputType::TextFieldInputType):
+ No need to initialize the element members explicitly because
+ RefPtr constructor works well.
+ (WebCore::TextFieldInputType::~TextFieldInputType):
+ Explicityly defines the destructor in the cpp file to avoid to
+ make it implicitly in the header file. If the destructor was made
+ in the header file, we would need to include HTMLElement.h in the
+ header file.
+ (WebCore::TextFieldInputType::createShadowSubtree):
+ - Don't call RenderTheme::themeForPage().
+ - Substitute an element to a data member, and don't call RefPtr<>::release().
+ (WebCore::TextFieldInputType::setInnerTextElement):
+ Moved from the header file to avoid to include HTMLElement.h.
+ (WebCore::TextFieldInputType::setSpeechButtonElement): ditto.
+ (WebCore::TextFieldInputType::innerTextElement):
+ Moved from the header file, and adjustment for RefPtr<>.
+ (WebCore::TextFieldInputType::innerSpinButtonElement): ditto.
+ (WebCore::TextFieldInputType::speechButtonElement): ditto.
+ (WebCore::TextFieldInputType::destroyShadowSubtree):
+ Adjustment for RefPtr<>.
+ * html/TextFieldInputType.h:
+ - Move accessor functions to the cpp file because they are virtual.
+ - Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
+
2011-06-28 Felician Marton <[email protected]>
Reviewed by Nikolas Zimmermann.
Modified: trunk/Source/WebCore/html/SearchInputType.cpp (89909 => 89910)
--- trunk/Source/WebCore/html/SearchInputType.cpp 2011-06-28 09:19:58 UTC (rev 89909)
+++ trunk/Source/WebCore/html/SearchInputType.cpp 2011-06-28 09:20:58 UTC (rev 89910)
@@ -40,9 +40,6 @@
inline SearchInputType::SearchInputType(HTMLInputElement* element)
: BaseTextInputType(element)
- , m_innerBlock(0)
- , m_resultsButton(0)
- , m_cancelButton(0)
{
}
@@ -69,43 +66,52 @@
void SearchInputType::createShadowSubtree()
{
ASSERT(!m_innerBlock);
- ASSERT(!innerTextElement());
ASSERT(!m_resultsButton);
ASSERT(!m_cancelButton);
ExceptionCode ec = 0;
Document* document = element()->document();
- RefPtr<HTMLElement> inner = TextControlInnerElement::create(document);
- m_innerBlock = inner.get();
- element()->ensureShadowRoot()->appendChild(inner.release(), ec);
+ m_innerBlock = TextControlInnerElement::create(document);
+ element()->ensureShadowRoot()->appendChild(m_innerBlock, ec);
#if ENABLE(INPUT_SPEECH)
if (element()->isSpeechEnabled()) {
- RefPtr<HTMLElement> speech = InputFieldSpeechButtonElement::create(document);
- setSpeechButtonElement(speech.get());
- element()->ensureShadowRoot()->appendChild(speech.release(), ec);
+ setSpeechButtonElement(InputFieldSpeechButtonElement::create(document));
+ element()->ensureShadowRoot()->appendChild(speechButtonElement(), ec);
}
#endif
- RefPtr<HTMLElement> results = SearchFieldResultsButtonElement::create(document);
- m_resultsButton = results.get();
- m_innerBlock->appendChild(results.release(), ec);
+ m_resultsButton = SearchFieldResultsButtonElement::create(document);
+ m_innerBlock->appendChild(m_resultsButton, ec);
- RefPtr<HTMLElement> innerText = TextControlInnerTextElement::create(document);
- setInnerTextElement(innerText.get());
- m_innerBlock->appendChild(innerText.release(), ec);
+ setInnerTextElement(TextControlInnerTextElement::create(document));
+ m_innerBlock->appendChild(innerTextElement(), ec);
- RefPtr<HTMLElement> cancel = SearchFieldCancelButtonElement::create(element()->document());
- m_cancelButton = cancel.get();
- m_innerBlock->appendChild(cancel.release(), ec);
+ m_cancelButton = SearchFieldCancelButtonElement::create(element()->document());
+ m_innerBlock->appendChild(m_cancelButton, ec);
}
+HTMLElement* SearchInputType::innerBlockElement() const
+{
+ return m_innerBlock.get();
+}
+
+HTMLElement* SearchInputType::resultsButtonElement() const
+{
+ return m_resultsButton.get();
+}
+
+HTMLElement* SearchInputType::cancelButtonElement() const
+{
+ return m_cancelButton.get();
+}
+
void SearchInputType::destroyShadowSubtree()
{
TextFieldInputType::destroyShadowSubtree();
- m_innerBlock = 0;
- m_resultsButton = 0;
- m_cancelButton = 0;
+ m_innerBlock.clear();
+ m_resultsButton.clear();
+ m_cancelButton.clear();
}
Modified: trunk/Source/WebCore/html/SearchInputType.h (89909 => 89910)
--- trunk/Source/WebCore/html/SearchInputType.h 2011-06-28 09:19:58 UTC (rev 89909)
+++ trunk/Source/WebCore/html/SearchInputType.h 2011-06-28 09:20:58 UTC (rev 89910)
@@ -51,13 +51,13 @@
virtual const AtomicString& formControlType() const;
virtual bool shouldRespectSpeechAttribute();
virtual bool isSearchField() const;
- virtual HTMLElement* innerBlockElement() const { return m_innerBlock; }
- virtual HTMLElement* resultsButtonElement() const { return m_resultsButton; }
- virtual HTMLElement* cancelButtonElement() const { return m_cancelButton; }
+ virtual HTMLElement* innerBlockElement() const;
+ virtual HTMLElement* resultsButtonElement() const;
+ virtual HTMLElement* cancelButtonElement() const;
- HTMLElement* m_innerBlock;
- HTMLElement* m_resultsButton;
- HTMLElement* m_cancelButton;
+ RefPtr<HTMLElement> m_innerBlock;
+ RefPtr<HTMLElement> m_resultsButton;
+ RefPtr<HTMLElement> m_cancelButton;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (89909 => 89910)
--- trunk/Source/WebCore/html/TextFieldInputType.cpp 2011-06-28 09:19:58 UTC (rev 89909)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp 2011-06-28 09:20:58 UTC (rev 89910)
@@ -36,6 +36,7 @@
#include "Frame.h"
#include "HTMLInputElement.h"
#include "KeyboardEvent.h"
+#include "Page.h"
#include "RenderTextControlSingleLine.h"
#include "RenderTheme.h"
#include "ShadowRoot.h"
@@ -49,14 +50,13 @@
TextFieldInputType::TextFieldInputType(HTMLInputElement* element)
: InputType(element)
- , m_innerText(0)
- , m_innerSpinButton(0)
-#if ENABLE(INPUT_SPEECH)
- , m_speechButton(0)
-#endif
{
}
+TextFieldInputType::~TextFieldInputType()
+{
+}
+
bool TextFieldInputType::isTextField() const
{
return true;
@@ -134,7 +134,9 @@
ASSERT(!m_innerText);
ASSERT(!m_innerSpinButton);
- bool shouldHaveSpinButton = RenderTheme::themeForPage(element()->document()->page())->shouldHaveSpinButton(element());
+ Document* document = element()->document();
+ RefPtr<RenderTheme> theme = document->page() ? document->page()->theme() : RenderTheme::defaultTheme();
+ bool shouldHaveSpinButton = theme->shouldHaveSpinButton(element());
bool hasDecorations = shouldHaveSpinButton;
#if ENABLE(INPUT_SPEECH)
if (element()->isSpeechEnabled())
@@ -142,37 +144,63 @@
#endif
ExceptionCode ec = 0;
- Document* document = element()->document();
- RefPtr<HTMLElement> innerText = TextControlInnerTextElement::create(document);
- m_innerText = innerText.get();
- element()->ensureShadowRoot()->appendChild(innerText.release(), ec);
+ m_innerText = TextControlInnerTextElement::create(document);
+ element()->ensureShadowRoot()->appendChild(m_innerText, ec);
if (!hasDecorations)
return;
#if ENABLE(INPUT_SPEECH)
ASSERT(!m_speechButton);
if (element()->isSpeechEnabled()) {
- RefPtr<HTMLElement> speech = InputFieldSpeechButtonElement::create(document);
- m_speechButton = speech.get();
- element()->ensureShadowRoot()->appendChild(speech.release(), ec);
+ m_speechButton = InputFieldSpeechButtonElement::create(document);
+ element()->ensureShadowRoot()->appendChild(m_speechButton, ec);
}
#endif
if (shouldHaveSpinButton) {
- RefPtr<HTMLElement> inner = SpinButtonElement::create(document);
- m_innerSpinButton = inner.get();
- element()->ensureShadowRoot()->appendChild(inner.release(), ec);
+ m_innerSpinButton = SpinButtonElement::create(document);
+ element()->ensureShadowRoot()->appendChild(m_innerSpinButton, ec);
}
}
+void TextFieldInputType::setInnerTextElement(PassRefPtr<HTMLElement> element)
+{
+ m_innerText = element;
+}
+
+#if ENABLE(INPUT_SPEECH)
+void TextFieldInputType::setSpeechButtonElement(PassRefPtr<HTMLElement> element)
+{
+ m_speechButton = element;
+}
+#endif
+
+HTMLElement* TextFieldInputType::innerTextElement() const
+{
+ ASSERT(m_innerText);
+ return m_innerText.get();
+}
+
+HTMLElement* TextFieldInputType::innerSpinButtonElement() const
+{
+ return m_innerSpinButton.get();
+}
+
+#if ENABLE(INPUT_SPEECH)
+HTMLElement* TextFieldInputType::speechButtonElement() const
+{
+ return m_speechButton.get();
+}
+#endif
+
void TextFieldInputType::destroyShadowSubtree()
{
InputType::destroyShadowSubtree();
- m_innerText = 0;
+ m_innerText.clear();
#if ENABLE(INPUT_SPEECH)
- m_speechButton = 0;
+ m_speechButton.clear();
#endif
- m_innerSpinButton = 0;
+ m_innerSpinButton.clear();
}
bool TextFieldInputType::shouldUseInputMethod() const
Modified: trunk/Source/WebCore/html/TextFieldInputType.h (89909 => 89910)
--- trunk/Source/WebCore/html/TextFieldInputType.h 2011-06-28 09:19:58 UTC (rev 89909)
+++ trunk/Source/WebCore/html/TextFieldInputType.h 2011-06-28 09:20:58 UTC (rev 89910)
@@ -40,23 +40,24 @@
class TextFieldInputType : public InputType {
protected:
TextFieldInputType(HTMLInputElement*);
+ virtual ~TextFieldInputType();
virtual bool canSetSuggestedValue();
virtual void handleKeydownEvent(KeyboardEvent*);
void handleKeydownEventForSpinButton(KeyboardEvent*);
void handleWheelEventForSpinButton(WheelEvent*);
- virtual HTMLElement* innerTextElement() const { return m_innerText; }
- virtual HTMLElement* innerSpinButtonElement() const { return m_innerSpinButton; }
+ virtual HTMLElement* innerTextElement() const;
+ virtual HTMLElement* innerSpinButtonElement() const;
#if ENABLE(INPUT_SPEECH)
- virtual HTMLElement* speechButtonElement() const { return m_speechButton; }
+ virtual HTMLElement* speechButtonElement() const;
#endif
protected:
virtual void createShadowSubtree();
virtual void destroyShadowSubtree();
- void setInnerTextElement(HTMLElement* element) { m_innerText = element; }
+ void setInnerTextElement(PassRefPtr<HTMLElement>);
#if ENABLE(INPUT_SPEECH)
- void setSpeechButtonElement(HTMLElement* element) { m_speechButton = element; }
+ void setSpeechButtonElement(PassRefPtr<HTMLElement>);
#endif
private:
@@ -70,10 +71,10 @@
virtual String sanitizeValue(const String&);
virtual bool shouldRespectListAttribute();
- HTMLElement* m_innerText;
- HTMLElement* m_innerSpinButton;
+ RefPtr<HTMLElement> m_innerText;
+ RefPtr<HTMLElement> m_innerSpinButton;
#if ENABLE(INPUT_SPEECH)
- HTMLElement* m_speechButton;
+ RefPtr<HTMLElement> m_speechButton;
#endif
};