Changeset 89910 in webkit
- Timestamp:
- Jun 28, 2011 2:20:58 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r89907 r89910 1 2011-06-28 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Hajime Morita. 4 5 Use RefPtr for the HTMLElement data members of TextFieldInptType 6 and SearchInputType. 7 https://bugs.webkit.org/show_bug.cgi?id=63511 8 9 No new tests because of no behavior change. 10 11 * html/SearchInputType.cpp: 12 (WebCore::SearchInputType::SearchInputType): 13 No need to initialize the element members explicitly because 14 RefPtr constructor works well. 15 (WebCore::SearchInputType::createShadowSubtree): 16 Substitute an element to a data member, and don't call RefPtr<>::release(). 17 (WebCore::SearchInputType::innerBlockElement): 18 Moved from the header file, and adjustment for RefPtr<>. 19 (WebCore::SearchInputType::resultsButtonElement): ditto. 20 (WebCore::SearchInputType::cancelButtonElement): ditto. 21 (WebCore::SearchInputType::destroyShadowSubtree): 22 Adjustment for RefPtr<>. 23 * html/SearchInputType.h: 24 - Move accessor functions to the cpp file because they are virtual. 25 - Change element data member types: HTMLElement* -> RefPtr<HTMLElement>. 26 * html/TextFieldInputType.cpp: 27 (WebCore::TextFieldInputType::TextFieldInputType): 28 No need to initialize the element members explicitly because 29 RefPtr constructor works well. 30 (WebCore::TextFieldInputType::~TextFieldInputType): 31 Explicityly defines the destructor in the cpp file to avoid to 32 make it implicitly in the header file. If the destructor was made 33 in the header file, we would need to include HTMLElement.h in the 34 header file. 35 (WebCore::TextFieldInputType::createShadowSubtree): 36 - Don't call RenderTheme::themeForPage(). 37 - Substitute an element to a data member, and don't call RefPtr<>::release(). 38 (WebCore::TextFieldInputType::setInnerTextElement): 39 Moved from the header file to avoid to include HTMLElement.h. 40 (WebCore::TextFieldInputType::setSpeechButtonElement): ditto. 41 (WebCore::TextFieldInputType::innerTextElement): 42 Moved from the header file, and adjustment for RefPtr<>. 43 (WebCore::TextFieldInputType::innerSpinButtonElement): ditto. 44 (WebCore::TextFieldInputType::speechButtonElement): ditto. 45 (WebCore::TextFieldInputType::destroyShadowSubtree): 46 Adjustment for RefPtr<>. 47 * html/TextFieldInputType.h: 48 - Move accessor functions to the cpp file because they are virtual. 49 - Change element data member types: HTMLElement* -> RefPtr<HTMLElement>. 50 1 51 2011-06-28 Felician Marton <marton.felician.zoltan@stud.u-szeged.hu> 2 52 -
trunk/Source/WebCore/html/SearchInputType.cpp
r89460 r89910 41 41 inline SearchInputType::SearchInputType(HTMLInputElement* element) 42 42 : BaseTextInputType(element) 43 , m_innerBlock(0)44 , m_resultsButton(0)45 , m_cancelButton(0)46 43 { 47 44 } … … 70 67 { 71 68 ASSERT(!m_innerBlock); 72 ASSERT(!innerTextElement());73 69 ASSERT(!m_resultsButton); 74 70 ASSERT(!m_cancelButton); … … 76 72 ExceptionCode ec = 0; 77 73 Document* document = element()->document(); 78 RefPtr<HTMLElement> inner = TextControlInnerElement::create(document); 79 m_innerBlock = inner.get(); 80 element()->ensureShadowRoot()->appendChild(inner.release(), ec); 74 m_innerBlock = TextControlInnerElement::create(document); 75 element()->ensureShadowRoot()->appendChild(m_innerBlock, ec); 81 76 82 77 #if ENABLE(INPUT_SPEECH) 83 78 if (element()->isSpeechEnabled()) { 84 RefPtr<HTMLElement> speech = InputFieldSpeechButtonElement::create(document); 85 setSpeechButtonElement(speech.get()); 86 element()->ensureShadowRoot()->appendChild(speech.release(), ec); 79 setSpeechButtonElement(InputFieldSpeechButtonElement::create(document)); 80 element()->ensureShadowRoot()->appendChild(speechButtonElement(), ec); 87 81 } 88 82 #endif 89 83 90 RefPtr<HTMLElement> results = SearchFieldResultsButtonElement::create(document); 91 m_resultsButton = results.get(); 92 m_innerBlock->appendChild(results.release(), ec); 84 m_resultsButton = SearchFieldResultsButtonElement::create(document); 85 m_innerBlock->appendChild(m_resultsButton, ec); 93 86 94 RefPtr<HTMLElement> innerText = TextControlInnerTextElement::create(document); 95 setInnerTextElement(innerText.get()); 96 m_innerBlock->appendChild(innerText.release(), ec); 87 setInnerTextElement(TextControlInnerTextElement::create(document)); 88 m_innerBlock->appendChild(innerTextElement(), ec); 97 89 98 RefPtr<HTMLElement> cancel = SearchFieldCancelButtonElement::create(element()->document()); 99 m_cancelButton = cancel.get(); 100 m_innerBlock->appendChild(cancel.release(), ec); 90 m_cancelButton = SearchFieldCancelButtonElement::create(element()->document()); 91 m_innerBlock->appendChild(m_cancelButton, ec); 92 } 93 94 HTMLElement* SearchInputType::innerBlockElement() const 95 { 96 return m_innerBlock.get(); 97 } 98 99 HTMLElement* SearchInputType::resultsButtonElement() const 100 { 101 return m_resultsButton.get(); 102 } 103 104 HTMLElement* SearchInputType::cancelButtonElement() const 105 { 106 return m_cancelButton.get(); 101 107 } 102 108 … … 104 110 { 105 111 TextFieldInputType::destroyShadowSubtree(); 106 m_innerBlock = 0;107 m_resultsButton = 0;108 m_cancelButton = 0;112 m_innerBlock.clear(); 113 m_resultsButton.clear(); 114 m_cancelButton.clear(); 109 115 } 110 116 -
trunk/Source/WebCore/html/SearchInputType.h
r89460 r89910 52 52 virtual bool shouldRespectSpeechAttribute(); 53 53 virtual bool isSearchField() const; 54 virtual HTMLElement* innerBlockElement() const { return m_innerBlock; }55 virtual HTMLElement* resultsButtonElement() const { return m_resultsButton; }56 virtual HTMLElement* cancelButtonElement() const { return m_cancelButton; }54 virtual HTMLElement* innerBlockElement() const; 55 virtual HTMLElement* resultsButtonElement() const; 56 virtual HTMLElement* cancelButtonElement() const; 57 57 58 HTMLElement*m_innerBlock;59 HTMLElement*m_resultsButton;60 HTMLElement*m_cancelButton;58 RefPtr<HTMLElement> m_innerBlock; 59 RefPtr<HTMLElement> m_resultsButton; 60 RefPtr<HTMLElement> m_cancelButton; 61 61 }; 62 62 -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r89460 r89910 37 37 #include "HTMLInputElement.h" 38 38 #include "KeyboardEvent.h" 39 #include "Page.h" 39 40 #include "RenderTextControlSingleLine.h" 40 41 #include "RenderTheme.h" … … 50 51 TextFieldInputType::TextFieldInputType(HTMLInputElement* element) 51 52 : InputType(element) 52 , m_innerText(0) 53 , m_innerSpinButton(0) 54 #if ENABLE(INPUT_SPEECH) 55 , m_speechButton(0) 56 #endif 53 { 54 } 55 56 TextFieldInputType::~TextFieldInputType() 57 57 { 58 58 } … … 135 135 ASSERT(!m_innerSpinButton); 136 136 137 bool shouldHaveSpinButton = RenderTheme::themeForPage(element()->document()->page())->shouldHaveSpinButton(element()); 137 Document* document = element()->document(); 138 RefPtr<RenderTheme> theme = document->page() ? document->page()->theme() : RenderTheme::defaultTheme(); 139 bool shouldHaveSpinButton = theme->shouldHaveSpinButton(element()); 138 140 bool hasDecorations = shouldHaveSpinButton; 139 141 #if ENABLE(INPUT_SPEECH) … … 143 145 144 146 ExceptionCode ec = 0; 145 Document* document = element()->document(); 146 RefPtr<HTMLElement> innerText = TextControlInnerTextElement::create(document); 147 m_innerText = innerText.get(); 148 element()->ensureShadowRoot()->appendChild(innerText.release(), ec); 147 m_innerText = TextControlInnerTextElement::create(document); 148 element()->ensureShadowRoot()->appendChild(m_innerText, ec); 149 149 if (!hasDecorations) 150 150 return; … … 153 153 ASSERT(!m_speechButton); 154 154 if (element()->isSpeechEnabled()) { 155 RefPtr<HTMLElement> speech = InputFieldSpeechButtonElement::create(document); 156 m_speechButton = speech.get(); 157 element()->ensureShadowRoot()->appendChild(speech.release(), ec); 155 m_speechButton = InputFieldSpeechButtonElement::create(document); 156 element()->ensureShadowRoot()->appendChild(m_speechButton, ec); 158 157 } 159 158 #endif 160 159 161 160 if (shouldHaveSpinButton) { 162 RefPtr<HTMLElement> inner = SpinButtonElement::create(document); 163 m_innerSpinButton = inner.get(); 164 element()->ensureShadowRoot()->appendChild(inner.release(), ec); 165 } 166 } 161 m_innerSpinButton = SpinButtonElement::create(document); 162 element()->ensureShadowRoot()->appendChild(m_innerSpinButton, ec); 163 } 164 } 165 166 void TextFieldInputType::setInnerTextElement(PassRefPtr<HTMLElement> element) 167 { 168 m_innerText = element; 169 } 170 171 #if ENABLE(INPUT_SPEECH) 172 void TextFieldInputType::setSpeechButtonElement(PassRefPtr<HTMLElement> element) 173 { 174 m_speechButton = element; 175 } 176 #endif 177 178 HTMLElement* TextFieldInputType::innerTextElement() const 179 { 180 ASSERT(m_innerText); 181 return m_innerText.get(); 182 } 183 184 HTMLElement* TextFieldInputType::innerSpinButtonElement() const 185 { 186 return m_innerSpinButton.get(); 187 } 188 189 #if ENABLE(INPUT_SPEECH) 190 HTMLElement* TextFieldInputType::speechButtonElement() const 191 { 192 return m_speechButton.get(); 193 } 194 #endif 167 195 168 196 void TextFieldInputType::destroyShadowSubtree() 169 197 { 170 198 InputType::destroyShadowSubtree(); 171 m_innerText = 0;172 #if ENABLE(INPUT_SPEECH) 173 m_speechButton = 0;174 #endif 175 m_innerSpinButton = 0;199 m_innerText.clear(); 200 #if ENABLE(INPUT_SPEECH) 201 m_speechButton.clear(); 202 #endif 203 m_innerSpinButton.clear(); 176 204 } 177 205 -
trunk/Source/WebCore/html/TextFieldInputType.h
r89460 r89910 41 41 protected: 42 42 TextFieldInputType(HTMLInputElement*); 43 virtual ~TextFieldInputType(); 43 44 virtual bool canSetSuggestedValue(); 44 45 virtual void handleKeydownEvent(KeyboardEvent*); … … 46 47 void handleWheelEventForSpinButton(WheelEvent*); 47 48 48 virtual HTMLElement* innerTextElement() const { return m_innerText; }49 virtual HTMLElement* innerSpinButtonElement() const { return m_innerSpinButton; }49 virtual HTMLElement* innerTextElement() const; 50 virtual HTMLElement* innerSpinButtonElement() const; 50 51 #if ENABLE(INPUT_SPEECH) 51 virtual HTMLElement* speechButtonElement() const { return m_speechButton; }52 virtual HTMLElement* speechButtonElement() const; 52 53 #endif 53 54 … … 55 56 virtual void createShadowSubtree(); 56 57 virtual void destroyShadowSubtree(); 57 void setInnerTextElement( HTMLElement* element) { m_innerText = element; }58 void setInnerTextElement(PassRefPtr<HTMLElement>); 58 59 #if ENABLE(INPUT_SPEECH) 59 void setSpeechButtonElement( HTMLElement* element) { m_speechButton = element; }60 void setSpeechButtonElement(PassRefPtr<HTMLElement>); 60 61 #endif 61 62 … … 71 72 virtual bool shouldRespectListAttribute(); 72 73 73 HTMLElement*m_innerText;74 HTMLElement*m_innerSpinButton;74 RefPtr<HTMLElement> m_innerText; 75 RefPtr<HTMLElement> m_innerSpinButton; 75 76 #if ENABLE(INPUT_SPEECH) 76 HTMLElement*m_speechButton;77 RefPtr<HTMLElement> m_speechButton; 77 78 #endif 78 79 };
Note: See TracChangeset
for help on using the changeset viewer.