Title: [140650] branches/chromium/1364
- Revision
- 140650
- Author
- [email protected]
- Date
- 2013-01-23 21:44:15 -0800 (Wed, 23 Jan 2013)
Log Message
Merge 140324
> INPUT_MULTIPLE_FIELDS_UI: should not dispatch 'input' events if the element value is not updated
> https://bugs.webkit.org/show_bug.cgi?id=107429
>
> Reviewed by Kentaro Hara.
>
> Source/WebCore:
>
> http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#common-event-behaviors
> > any time the user causes the element's value to change, the user agent
> > must queue a task to fire a simple event that bubbles named input at the
> > input element.
>
> Tests:
> fast/forms/time-multiple-fields/time-multiple-fields-keyboard-event.html
> is updated to cover this change.
>
> * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
> (WebCore::BaseMultipleFieldsDateAndTimeInputType::editControlValueChanged):
> If the new value is equivalent to the old value, don't dispatch events.
> However we should recalculate validity and call notifyFormStateChanged
> because input.validity.badInput state might be changed.
>
> LayoutTests:
>
> * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
> * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
>
[email protected]
Review URL: https://codereview.chromium.org/12047073
Modified Paths
Diff
Modified: branches/chromium/1364/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt (140649 => 140650)
--- branches/chromium/1364/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt 2013-01-24 05:42:33 UTC (rev 140649)
+++ branches/chromium/1364/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt 2013-01-24 05:44:15 UTC (rev 140650)
@@ -13,7 +13,11 @@
Backspace - Make value empty
== Digit keys ==
+PASS eventsCounter.input is undefined.
+PASS eventsCounter.change is undefined.
PASS input.value is "07:56"
+PASS eventsCounter.input is 1
+PASS eventsCounter.change is 1
== Digit keys starting with zero ==
PASS input.value is "14:03"
== Digit keys and backspace key ==
@@ -25,7 +29,11 @@
PASS input.value is "05:56"
PASS input.value is "03:56"
== Up/Down keys on empty value ==
+PASS eventsCounter.input is undefined.
+PASS eventsCounter.change is undefined.
PASS input.value is "14:58"
+PASS eventsCounter.input is 1
+PASS eventsCounter.change is 1
== Tab key ==
PASS input.value is "03:05"
PASS input.value is "07:05"
Modified: branches/chromium/1364/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html (140649 => 140650)
--- branches/chromium/1364/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html 2013-01-24 05:42:33 UTC (rev 140649)
+++ branches/chromium/1364/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html 2013-01-24 05:44:15 UTC (rev 140650)
@@ -41,12 +41,26 @@
input.focus();
}
+var eventsCounter = {};
+function countEvents(event)
+{
+ if (eventsCounter[event.type] === undefined)
+ eventsCounter[event.type] = 0;
+ eventsCounter[event.type]++;
+}
+input.addEventListener('input', countEvents, false);
+input.addEventListener('change', countEvents, false);
+
beginTest('Digit keys');
-keyDown('7');
-keyDown('5');
-keyDown('6');
-keyDown('A');
+keyDown('7'); // -> 07:[--] --
+keyDown('5'); // -> 07:[05] --
+keyDown('6'); // -> 07:56 [--]
+shouldBeUndefined('eventsCounter.input');
+shouldBeUndefined('eventsCounter.change');
+keyDown('A'); // -> 07:56 [AM]
shouldBeEqualToString('input.value', '07:56');
+shouldBe('eventsCounter.input', '1');
+shouldBe('eventsCounter.change', '1');
beginTest('Digit keys starting with zero');
keyDown('0'); // -> [00]:-- --
@@ -97,14 +111,19 @@
shouldBeEqualToString('input.value', '03:56');
beginTest('Up/Down keys on empty value', '');
-keyDown('upArrow');
-keyDown('upArrow');
-keyDown('rightArrow');
-keyDown('downArrow');
-keyDown('downArrow');
-keyDown('rightArrow');
-keyDown('downArrow');
+eventsCounter = {};
+keyDown('upArrow'); // -> [01]:-- --
+keyDown('upArrow'); // -> [02]:-- --
+keyDown('rightArrow'); // -> 02:[--] --
+keyDown('downArrow'); // -> 02:[59] --
+keyDown('downArrow'); // -> 02:[58] --
+keyDown('rightArrow'); // -> 02:58 [--]
+shouldBeUndefined('eventsCounter.input');
+shouldBeUndefined('eventsCounter.change');
+keyDown('downArrow'); // -> 02:58 [PM]
shouldBeEqualToString('input.value', '14:58');
+shouldBe('eventsCounter.input', '1');
+shouldBe('eventsCounter.change', '1');
beginTest('Tab key', '03:00');
keyDown('\t');
Modified: branches/chromium/1364/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp (140649 => 140650)
--- branches/chromium/1364/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-01-24 05:42:33 UTC (rev 140649)
+++ branches/chromium/1364/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-01-24 05:44:15 UTC (rev 140650)
@@ -73,10 +73,17 @@
void BaseMultipleFieldsDateAndTimeInputType::editControlValueChanged()
{
RefPtr<HTMLInputElement> input(element());
- input->setValueInternal(sanitizeValue(m_dateTimeEditElement->value()), DispatchNoEvent);
- input->setNeedsStyleRecalc();
- input->dispatchFormControlInputEvent();
- input->dispatchFormControlChangeEvent();
+ String oldValue = input->value();
+ String newValue = sanitizeValue(m_dateTimeEditElement->value());
+ // Even if oldValue is null and newValue is "", we should assume they are same.
+ if ((oldValue.isEmpty() && newValue.isEmpty()) || oldValue == newValue)
+ input->setNeedsValidityCheck();
+ else {
+ input->setValueInternal(newValue, DispatchNoEvent);
+ input->setNeedsStyleRecalc();
+ input->dispatchFormControlInputEvent();
+ input->dispatchFormControlChangeEvent();
+ }
input->notifyFormStateChanged();
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes