Changeset 94658 in webkit
- Timestamp:
- Sep 7, 2011 3:07:10 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r94654 r94658 1 2011-09-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 Change event is not fired for input[type=number] when the user reverts a change made by script 4 https://bugs.webkit.org/show_bug.cgi?id=67697 5 6 Reviewed by Kent Tamura. 7 8 Add a regression test to ensure WebKit fires change event when the user reverts a change made by script. 9 10 * fast/forms/number-input-changeevent-expected.txt: Added. 11 * fast/forms/number-input-changeevent.html: Added. 12 1 13 2011-09-07 Csaba Osztrogonác <ossy@webkit.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r94657 r94658 1 2011-09-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 Change event is not fired for input[type=number] when the user reverts a change made by script 4 https://bugs.webkit.org/show_bug.cgi?id=67697 5 6 Reviewed by Kent Tamura. 7 8 The bug was caused by HTMLInputElement::setValue not calling setTextAsOfLastFormControlChangeEvent 9 for text fields other than type=text. 10 11 Also fixed a that stepUpFromRenderer does not call setTextAsOfLastFormControlChangeEvent at appropriate 12 timing due to setValueAsNumber always passing sendChangeEvent=false to setValue by propagating values 13 through setValueAsNumber and applyStep. This refactoring allows us to remove calls to dispatch* in 14 stepUpFromRenderer because they're now called in setValueAsNumber or applyStep. 15 16 Test: fast/forms/number-input-changeevent.html 17 18 * html/BaseDateAndTimeInputType.cpp: 19 (WebCore::BaseDateAndTimeInputType::setValueAsNumber): 20 * html/BaseDateAndTimeInputType.h: 21 * html/HTMLInputElement.cpp: 22 (WebCore::HTMLInputElement::applyStep): 23 (WebCore::HTMLInputElement::stepUp): 24 (WebCore::HTMLInputElement::stepDown): 25 (WebCore::HTMLInputElement::setValue): 26 (WebCore::HTMLInputElement::setValueAsNumber): 27 (WebCore::HTMLInputElement::stepUpFromRenderer): 28 * html/HTMLInputElement.h: 29 * html/InputType.cpp: 30 (WebCore::InputType::setValueAsNumber): 31 * html/InputType.h: 32 * html/NumberInputType.cpp: 33 (WebCore::NumberInputType::setValueAsNumber): 34 * html/NumberInputType.h: 35 * html/RangeInputType.cpp: 36 (WebCore::RangeInputType::setValueAsNumber): 37 (WebCore::RangeInputType::handleKeydownEvent): 38 * html/RangeInputType.h: 39 1 40 2011-09-07 Antti Koivisto <antti@apple.com> 2 41 -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp
r85382 r94658 66 66 } 67 67 68 void BaseDateAndTimeInputType::setValueAsNumber(double newValue, ExceptionCode&) const69 { 70 element()->setValue(serialize(newValue) );68 void BaseDateAndTimeInputType::setValueAsNumber(double newValue, bool sendChangeEvent, ExceptionCode&) const 69 { 70 element()->setValue(serialize(newValue), sendChangeEvent); 71 71 } 72 72 -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.h
r85382 r94658 53 53 virtual void setValueAsDate(double, ExceptionCode&) const; 54 54 virtual double valueAsNumber() const; 55 virtual void setValueAsNumber(double, ExceptionCode&) const;55 virtual void setValueAsNumber(double, bool sendChangeEvent, ExceptionCode&) const; 56 56 virtual bool typeMismatchFor(const String&) const; 57 57 virtual bool typeMismatch() const; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r94639 r94658 389 389 } 390 390 391 void HTMLInputElement::applyStep(double count, AnyStepHandling anyStepHandling, ExceptionCode& ec)391 void HTMLInputElement::applyStep(double count, AnyStepHandling anyStepHandling, bool sendChangeEvent, ExceptionCode& ec) 392 392 { 393 393 double step; … … 429 429 newValue = m_inputType->maximum(); 430 430 431 setValueAsNumber(newValue, ec );431 setValueAsNumber(newValue, ec, sendChangeEvent); 432 432 433 433 if (AXObjectCache::accessibilityEnabled()) … … 456 456 void HTMLInputElement::stepUp(int n, ExceptionCode& ec) 457 457 { 458 applyStep(n, RejectAny, ec); 458 bool sendChangeEvent = false; 459 applyStep(n, RejectAny, sendChangeEvent, ec); 459 460 } 460 461 461 462 void HTMLInputElement::stepDown(int n, ExceptionCode& ec) 462 463 { 463 applyStep(-n, RejectAny, ec); 464 bool sendChangeEvent = false; 465 applyStep(-n, RejectAny, sendChangeEvent, ec); 464 466 } 465 467 … … 1118 1120 } 1119 1121 1120 if (isText () && (!focused() || !sendChangeEvent))1122 if (isTextField() && (!focused() || !sendChangeEvent)) 1121 1123 setTextAsOfLastFormControlChangeEvent(value); 1122 1124 … … 1145 1147 } 1146 1148 1147 void HTMLInputElement::setValueAsNumber(double newValue, ExceptionCode& ec )1149 void HTMLInputElement::setValueAsNumber(double newValue, ExceptionCode& ec, bool sendChangeEvent) 1148 1150 { 1149 1151 if (!isfinite(newValue)) { … … 1151 1153 return; 1152 1154 } 1153 m_inputType->setValueAsNumber(newValue, ec);1155 m_inputType->setValueAsNumber(newValue, sendChangeEvent, ec); 1154 1156 } 1155 1157 … … 1629 1631 String currentStringValue = value(); 1630 1632 double current = m_inputType->parseToDouble(currentStringValue, nan); 1633 const bool sendChangeEvent = true; 1631 1634 if (!isfinite(current)) { 1632 1635 ExceptionCode ec; … … 1637 1640 if (current > m_inputType->maximum() - nextDiff) 1638 1641 current = m_inputType->maximum() - nextDiff; 1639 setValueAsNumber(current, ec );1642 setValueAsNumber(current, ec, sendChangeEvent); 1640 1643 } 1641 1644 if ((sign > 0 && current < m_inputType->minimum()) || (sign < 0 && current > m_inputType->maximum())) 1642 setValue(m_inputType->serialize(sign > 0 ? m_inputType->minimum() : m_inputType->maximum()) );1645 setValue(m_inputType->serialize(sign > 0 ? m_inputType->minimum() : m_inputType->maximum()), sendChangeEvent); 1643 1646 else { 1644 1647 ExceptionCode ec; … … 1660 1663 newValue = m_inputType->maximum(); 1661 1664 1662 setValueAsNumber(newValue, ec );1665 setValueAsNumber(newValue, ec, n == 1 || n == -1); 1663 1666 current = newValue; 1664 1667 if (n > 1) 1665 applyStep(n - 1, AnyIsDefaultStep, ec);1668 applyStep(n - 1, AnyIsDefaultStep, sendChangeEvent, ec); 1666 1669 else if (n < -1) 1667 applyStep(n + 1, AnyIsDefaultStep, ec);1670 applyStep(n + 1, AnyIsDefaultStep, sendChangeEvent, ec); 1668 1671 } else 1669 applyStep(n, AnyIsDefaultStep, ec); 1670 } 1671 1672 if (currentStringValue != value()) { 1673 if (m_inputType->isRangeControl()) 1674 dispatchFormControlChangeEvent(); 1675 else 1676 dispatchFormControlInputEvent(); 1672 applyStep(n, AnyIsDefaultStep, sendChangeEvent, ec); 1677 1673 } 1678 1674 } -
trunk/Source/WebCore/html/HTMLInputElement.h
r94639 r94658 161 161 162 162 double valueAsNumber() const; 163 void setValueAsNumber(double, ExceptionCode& );163 void setValueAsNumber(double, ExceptionCode&, bool sendChangeEvent = false); 164 164 165 165 virtual String placeholder() const; … … 327 327 328 328 // Helper for stepUp()/stepDown(). Adds step value * count to the current value. 329 void applyStep(double count, AnyStepHandling, ExceptionCode&);329 void applyStep(double count, AnyStepHandling, bool sendChangeEvent, ExceptionCode&); 330 330 double alignValueForStep(double value, double step, unsigned currentDecimalPlaces, unsigned stepDecimalPlaces); 331 331 -
trunk/Source/WebCore/html/InputType.cpp
r94639 r94658 183 183 } 184 184 185 void InputType::setValueAsNumber(double, ExceptionCode& ec) const185 void InputType::setValueAsNumber(double, bool, ExceptionCode& ec) const 186 186 { 187 187 ec = INVALID_STATE_ERR; -
trunk/Source/WebCore/html/InputType.h
r94639 r94658 127 127 virtual void setValueAsDate(double, ExceptionCode&) const; 128 128 virtual double valueAsNumber() const; 129 virtual void setValueAsNumber(double, ExceptionCode&) const;129 virtual void setValueAsNumber(double, bool sendChangeEvent, ExceptionCode&) const; 130 130 131 131 // Validation functions -
trunk/Source/WebCore/html/NumberInputType.cpp
r94274 r94658 84 84 } 85 85 86 void NumberInputType::setValueAsNumber(double newValue, ExceptionCode& ec) const86 void NumberInputType::setValueAsNumber(double newValue, bool sendChangeEvent, ExceptionCode& ec) const 87 87 { 88 88 if (newValue < -numeric_limits<float>::max()) { … … 94 94 return; 95 95 } 96 element()->setValue(serialize(newValue) );96 element()->setValue(serialize(newValue), sendChangeEvent); 97 97 } 98 98 -
trunk/Source/WebCore/html/NumberInputType.h
r92589 r94658 44 44 virtual const AtomicString& formControlType() const; 45 45 virtual double valueAsNumber() const; 46 virtual void setValueAsNumber(double, ExceptionCode&) const;46 virtual void setValueAsNumber(double, bool sendChangeEvent, ExceptionCode&) const; 47 47 virtual bool typeMismatchFor(const String&) const; 48 48 virtual bool typeMismatch() const; -
trunk/Source/WebCore/html/RangeInputType.cpp
r91982 r94658 79 79 } 80 80 81 void RangeInputType::setValueAsNumber(double newValue, ExceptionCode&) const82 { 83 element()->setValue(serialize(newValue) );81 void RangeInputType::setValueAsNumber(double newValue, bool sendChangeEvent, ExceptionCode&) const 82 { 83 element()->setValue(serialize(newValue), sendChangeEvent); 84 84 } 85 85 … … 221 221 if (newValue != current) { 222 222 ExceptionCode ec; 223 setValueAsNumber(newValue, ec); 223 bool sendChangeEvent = true; 224 setValueAsNumber(newValue, sendChangeEvent, ec); 224 225 225 226 if (AXObjectCache::accessibilityEnabled()) -
trunk/Source/WebCore/html/RangeInputType.h
r88757 r94658 47 47 virtual const AtomicString& formControlType() const; 48 48 virtual double valueAsNumber() const; 49 virtual void setValueAsNumber(double, ExceptionCode&) const;49 virtual void setValueAsNumber(double, bool sendChangeEvent, ExceptionCode&) const; 50 50 virtual bool supportsRequired() const; 51 51 virtual bool rangeUnderflow(const String&) const;
Note: See TracChangeset
for help on using the changeset viewer.