Changeset 91014 in webkit
- Timestamp:
- Jul 14, 2011 10:45:04 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r91008 r91014 1 2011-07-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 Move subtreeHasChanged from RenderTextControl to HTMLTextFormControlElement 4 https://bugs.webkit.org/show_bug.cgi?id=64476 5 6 Reviewed by Kent Tamura. 7 8 Moved subtreeHasChanged from RenderTextControl, RenderTextControlSingleLine, and 9 RenderTextControlMultiLine to HTMLTextFormControlElement, HTMLInputElement, and 10 HTMLTextAreaElement. Also moved m_searchEventTimer and related functions from 11 RenderTextSingleLine to SearchInputType. 12 13 * html/HTMLInputElement.cpp: 14 (WebCore::HTMLInputElement::subtreeHasChanged): Moved from RenderTextControlSingleLine. 15 (WebCore::HTMLInputElement::onSearch): Calls stopSearchEventTimer. 16 * html/HTMLInputElement.h: 17 * html/HTMLTextAreaElement.cpp: 18 (WebCore::HTMLTextAreaElement::subtreeHasChanged): Moved from RenderTextMultiLine. 19 * html/HTMLTextAreaElement.h: 20 * html/HTMLTextFormControlElement.cpp: 21 (WebCore::HTMLTextFormControlElement::defaultEventHandler): Calls subtreeHasChanged. 22 (WebCore::HTMLTextFormControlElement::subtreeHasChanged): Added; calls respondToChangeByUser. 23 * html/HTMLTextFormControlElement.h: 24 * html/SearchInputType.cpp: 25 (WebCore::SearchInputType::SearchInputType): Initializes m_searchEventTimer. 26 (WebCore::SearchInputType::startSearchEventTimer): Moved from RenderTextControlSingleLine. 27 (WebCore::SearchInputType::stopSearchEventTimer): Ditto. 28 (WebCore::SearchInputType::searchEventTimerFired): Ditto. 29 * html/SearchInputType.h: 30 * html/TextFieldInputType.cpp: 31 (WebCore::TextFieldInputType::handleBeforeTextInsertedEvent): Updated comment. 32 * rendering/RenderTextControl.cpp: 33 * rendering/RenderTextControl.h: 34 (WebCore::RenderTextControl::respondToChangeByUser): Renamed from subtreeHasChanged. 35 * rendering/RenderTextControlMultiLine.cpp: 36 * rendering/RenderTextControlMultiLine.h: 37 * rendering/RenderTextControlSingleLine.cpp: 38 (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine): No longer initializes 39 m_searchEventTimer. 40 * rendering/RenderTextControlSingleLine.h: 41 1 42 2011-07-14 Vsevolod Vlasov <vsevik@chromium.org> 2 43 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r90971 r91014 56 56 #include "RenderTheme.h" 57 57 #include "RuntimeEnabledFeatures.h" 58 #include "SearchInputType.h" 58 59 #include "ScriptEventListener.h" 59 60 #include "WheelEvent.h" … … 613 614 setNeedsValidityCheck(); 614 615 notifyFormStateChanged(); 616 } 617 618 void HTMLInputElement::subtreeHasChanged() 619 { 620 ASSERT(isTextField()); 621 ASSERT(renderer()); 622 RenderTextControlSingleLine* renderTextControl = toRenderTextControlSingleLine(renderer()); 623 624 HTMLTextFormControlElement::subtreeHasChanged(); 625 626 bool wasChanged = wasChangedSinceLastFormControlChangeEvent(); 627 setChangedSinceLastFormControlChangeEvent(true); 628 629 // We don't need to call sanitizeUserInputValue() function here because 630 // HTMLInputElement::handleBeforeTextInsertedEvent() has already called 631 // sanitizeUserInputValue(). 632 // sanitizeValue() is needed because IME input doesn't dispatch BeforeTextInsertedEvent. 633 String value = toRenderTextControl(renderer())->text(); 634 if (isAcceptableValue(value)) 635 setValueFromRenderer(sanitizeValue(convertFromVisibleValue(value))); 636 // Recalc for :invalid and hasUnacceptableValue() change. 637 setNeedsStyleRecalc(); 638 639 if (cancelButtonElement()) 640 renderTextControl->updateCancelButtonVisibility(); 641 642 // If the incremental attribute is set, then dispatch the search event 643 if (searchEventsShouldBeDispatched() && isSearchField() && m_inputType) 644 static_cast<SearchInputType*>(m_inputType.get())->startSearchEventTimer(); 645 646 if (!wasChanged && focused()) { 647 if (Frame* frame = document()->frame()) 648 frame->editor()->textFieldDidBeginEditing(this); 649 } 650 651 if (focused()) { 652 if (Frame* frame = document()->frame()) 653 frame->editor()->textDidChangeInTextField(this); 654 } 615 655 } 616 656 … … 1374 1414 { 1375 1415 ASSERT(isSearchField()); 1376 if ( renderer())1377 toRenderTextControlSingleLine(renderer())->stopSearchEventTimer();1416 if (m_inputType) 1417 static_cast<SearchInputType*>(m_inputType.get())->stopSearchEventTimer(); 1378 1418 dispatchEvent(Event::create(eventNames().searchEvent, true, false)); 1379 1419 } -
trunk/Source/WebCore/html/HTMLInputElement.h
r90971 r91014 316 316 317 317 void updateType(); 318 319 virtual void subtreeHasChanged(); 318 320 319 321 bool getAllowedValueStepWithDecimalPlaces(AnyStepHandling, double*, unsigned*) const; -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r90983 r91014 243 243 } 244 244 245 void HTMLTextAreaElement::subtreeHasChanged() 246 { 247 HTMLTextFormControlElement::subtreeHasChanged(); 248 249 setChangedSinceLastFormControlChangeEvent(true); 250 setFormControlValueMatchesRenderer(false); 251 setNeedsValidityCheck(); 252 253 if (!focused()) 254 return; 255 256 if (Frame* frame = document()->frame()) 257 frame->editor()->textDidChangeInTextArea(this); 258 } 259 245 260 void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) const 246 261 { -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r90971 r91014 83 83 84 84 virtual void defaultEventHandler(Event*); 85 86 virtual void subtreeHasChanged(); 85 87 86 88 virtual bool isEnumeratable() const { return true; } -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r90983 r91014 83 83 { 84 84 if (event->type() == eventNames().webkitEditableContentChangedEvent && renderer() && renderer()->isTextControl()) { 85 toRenderTextControl(renderer())->subtreeHasChanged();85 subtreeHasChanged(); 86 86 return; 87 87 } … … 95 95 return; 96 96 innerTextElement()->defaultEventHandler(event); 97 } 98 99 void HTMLTextFormControlElement::subtreeHasChanged() 100 { 101 toRenderTextControl(renderer())->respondToChangeByUser(); 97 102 } 98 103 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r90983 r91014 89 89 90 90 virtual void defaultEventHandler(Event*); 91 virtual void subtreeHasChanged(); 91 92 92 93 private: -
trunk/Source/WebCore/html/SearchInputType.cpp
r90089 r91014 33 33 34 34 #include "HTMLInputElement.h" 35 #include "RenderTextControlSingleLine.h" 35 36 #include "ShadowRoot.h" 36 37 #include "TextControlInnerElements.h" … … 41 42 inline SearchInputType::SearchInputType(HTMLInputElement* element) 42 43 : BaseTextInputType(element) 44 , m_searchEventTimer(this, &SearchInputType::searchEventTimerFired) 43 45 { 44 46 } … … 105 107 } 106 108 109 void SearchInputType::startSearchEventTimer() 110 { 111 ASSERT(element()->renderer()); 112 unsigned length = toRenderTextControlSingleLine(element()->renderer())->text().length(); 113 114 if (!length) { 115 stopSearchEventTimer(); 116 element()->onSearch(); 117 return; 118 } 119 120 // After typing the first key, we wait 0.5 seconds. 121 // After the second key, 0.4 seconds, then 0.3, then 0.2 from then on. 122 m_searchEventTimer.startOneShot(max(0.2, 0.6 - 0.1 * length)); 123 } 124 125 void SearchInputType::stopSearchEventTimer() 126 { 127 m_searchEventTimer.stop(); 128 } 129 130 void SearchInputType::searchEventTimerFired(Timer<SearchInputType>*) 131 { 132 element()->onSearch(); 133 } 134 107 135 108 136 } // namespace WebCore -
trunk/Source/WebCore/html/SearchInputType.h
r90089 r91014 33 33 34 34 #include "BaseTextInputType.h" 35 #include "Timer.h" 35 36 36 37 namespace WebCore { … … 42 43 public: 43 44 static PassOwnPtr<InputType> create(HTMLInputElement*); 45 46 void startSearchEventTimer(); 47 void stopSearchEventTimer(); 44 48 45 49 private: … … 54 58 virtual HTMLElement* cancelButtonElement() const; 55 59 60 void searchEventTimerFired(Timer<SearchInputType>*); 61 56 62 RefPtr<HTMLElement> m_resultsButton; 57 63 RefPtr<HTMLElement> m_cancelButton; 64 Timer<SearchInputType> m_searchEventTimer; 58 65 }; 59 66 -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r90983 r91014 280 280 // We use RenderTextControlSingleLine::text() instead of InputElement::value() 281 281 // because they can be mismatched by sanitizeValue() in 282 // RenderTextControlSingleLine::subtreeHasChanged() in some cases.282 // HTMLInputElement::subtreeHasChanged() in some cases. 283 283 unsigned oldLength = numGraphemeClusters(toRenderTextControlSingleLine(element()->renderer())->text()); 284 284 -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r90983 r91014 173 173 } 174 174 175 void RenderTextControl::setLastChangeWasUserEdit(bool lastChangeWasUserEdit)176 {177 m_lastChangeWasUserEdit = lastChangeWasUserEdit;178 document()->setIgnoreAutofocus(lastChangeWasUserEdit);179 }180 181 175 VisiblePosition RenderTextControl::visiblePositionForIndex(int index) const 182 176 { … … 190 184 it.advance(index - 1); 191 185 return VisiblePosition(it.range()->endPosition(), UPSTREAM); 192 }193 194 void RenderTextControl::subtreeHasChanged()195 {196 m_lastChangeWasUserEdit = true;197 186 } 198 187 -
trunk/Source/WebCore/rendering/RenderTextControl.h
r90983 r91014 37 37 38 38 bool lastChangeWasUserEdit() const { return m_lastChangeWasUserEdit; } 39 void setLastChangeWasUserEdit(bool lastChangeWasUserEdit); 40 41 virtual void subtreeHasChanged(); 39 void respondToChangeByUser() { m_lastChangeWasUserEdit = true; } 42 40 String text(); 43 41 String textWithHardLineBreaks(); -
trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp
r90983 r91014 41 41 if (node() && node()->inDocument()) 42 42 static_cast<HTMLTextAreaElement*>(node())->rendererWillBeDestroyed(); 43 }44 45 void RenderTextControlMultiLine::subtreeHasChanged()46 {47 RenderTextControl::subtreeHasChanged();48 HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(node());49 textArea->setChangedSinceLastFormControlChangeEvent(true);50 textArea->setFormControlValueMatchesRenderer(false);51 textArea->setNeedsValidityCheck();52 53 if (!node()->focused())54 return;55 56 if (Frame* frame = this->frame())57 frame->editor()->textDidChangeInTextArea(textArea);58 43 } 59 44 -
trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h
r90983 r91014 35 35 virtual bool isTextArea() const { return true; } 36 36 37 virtual void subtreeHasChanged();38 39 37 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction); 40 38 -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r90983 r91014 73 73 , m_shouldDrawCapsLockIndicator(false) 74 74 , m_desiredInnerTextHeight(-1) 75 , m_searchEventTimer(this, &RenderTextControlSingleLine::searchEventTimerFired)76 75 , m_searchPopup(0) 77 76 { … … 155 154 156 155 m_searchPopup->saveRecentSearches(name, m_recentSearches); 157 }158 159 void RenderTextControlSingleLine::stopSearchEventTimer()160 {161 m_searchEventTimer.stop();162 156 } 163 157 … … 195 189 if (m_searchPopup) 196 190 m_searchPopup->popupMenu()->hide(); 197 }198 199 void RenderTextControlSingleLine::subtreeHasChanged()200 {201 RenderTextControl::subtreeHasChanged();202 203 ASSERT(node()->isElementNode());204 Element* element = static_cast<Element*>(node());205 bool wasChanged = element->wasChangedSinceLastFormControlChangeEvent();206 element->setChangedSinceLastFormControlChangeEvent(true);207 208 HTMLInputElement* input = inputElement();209 // We don't need to call sanitizeUserInputValue() function here because210 // HTMLInputElement::handleBeforeTextInsertedEvent() has already called211 // sanitizeUserInputValue().212 // sanitizeValue() is needed because IME input doesn't dispatch BeforeTextInsertedEvent.213 String value = text();214 if (input->isAcceptableValue(value))215 input->setValueFromRenderer(input->sanitizeValue(input->convertFromVisibleValue(value)));216 // Recalc for :invalid and hasUnacceptableValue() change.217 input->setNeedsStyleRecalc();218 219 if (cancelButtonElement())220 updateCancelButtonVisibility();221 222 // If the incremental attribute is set, then dispatch the search event223 if (input->searchEventsShouldBeDispatched())224 startSearchEventTimer();225 226 if (!wasChanged && node()->focused()) {227 if (Frame* frame = this->frame())228 frame->editor()->textFieldDidBeginEditing(static_cast<Element*>(node()));229 }230 231 if (node()->focused()) {232 if (Frame* frame = document()->frame())233 frame->editor()->textDidChangeInTextField(static_cast<Element*>(node()));234 }235 191 } 236 192 … … 587 543 { 588 544 return static_cast<Element*>(node())->getAttribute(autosaveAttr); 589 }590 591 void RenderTextControlSingleLine::startSearchEventTimer()592 {593 unsigned length = text().length();594 595 // If there's no text, fire the event right away.596 if (!length) {597 stopSearchEventTimer();598 inputElement()->onSearch();599 return;600 }601 602 // After typing the first key, we wait 0.5 seconds.603 // After the second key, 0.4 seconds, then 0.3, then 0.2 from then on.604 m_searchEventTimer.startOneShot(max(0.2, 0.6 - 0.1 * length));605 }606 607 void RenderTextControlSingleLine::searchEventTimerFired(Timer<RenderTextControlSingleLine>*)608 {609 inputElement()->onSearch();610 545 } 611 546 -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h
r90983 r91014 26 26 #include "PopupMenuClient.h" 27 27 #include "RenderTextControl.h" 28 #include "Timer.h"29 28 30 29 namespace WebCore { … … 40 39 virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const; 41 40 PassRefPtr<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const; 41 void updateCancelButtonVisibility() const; 42 42 43 43 void addSearchResult(); … … 55 55 virtual bool isTextField() const { return true; } 56 56 57 virtual void subtreeHasChanged();58 57 virtual void paint(PaintInfo&, const LayoutPoint&); 59 58 virtual void layout(); … … 83 82 virtual RenderStyle* textBaseStyle() const; 84 83 85 void updateCancelButtonVisibility() const;86 84 EVisibility visibilityForCancelButton() const; 87 85 const AtomicString& autosaveName() const; 88 89 void startSearchEventTimer();90 void searchEventTimerFired(Timer<RenderTextControlSingleLine>*);91 86 92 87 // PopupMenuClient methods … … 133 128 bool m_shouldDrawCapsLockIndicator; 134 129 LayoutUnit m_desiredInnerTextHeight; 135 Timer<RenderTextControlSingleLine> m_searchEventTimer;136 130 RefPtr<SearchPopupMenu> m_searchPopup; 137 131 Vector<String> m_recentSearches;
Note: See TracChangeset
for help on using the changeset viewer.