Title: [140324] trunk
- Revision
- 140324
- Author
- [email protected]
- Date
- 2013-01-21 04:50:30 -0800 (Mon, 21 Jan 2013)
Log Message
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:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (140323 => 140324)
--- trunk/LayoutTests/ChangeLog 2013-01-21 12:45:24 UTC (rev 140323)
+++ trunk/LayoutTests/ChangeLog 2013-01-21 12:50:30 UTC (rev 140324)
@@ -1,3 +1,13 @@
+2013-01-21 Kent Tamura <[email protected]>
+
+ 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.
+
+ * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
+ * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
+
2013-01-21 Alexander Pavlov <[email protected]>
Web Inspector: Do not dispatch mousemove when emulating touch event and no touch is active
Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt (140323 => 140324)
--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt 2013-01-21 12:45:24 UTC (rev 140323)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt 2013-01-21 12:50:30 UTC (rev 140324)
@@ -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: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html (140323 => 140324)
--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html 2013-01-21 12:45:24 UTC (rev 140323)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html 2013-01-21 12:50:30 UTC (rev 140324)
@@ -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: trunk/Source/WebCore/ChangeLog (140323 => 140324)
--- trunk/Source/WebCore/ChangeLog 2013-01-21 12:45:24 UTC (rev 140323)
+++ trunk/Source/WebCore/ChangeLog 2013-01-21 12:50:30 UTC (rev 140324)
@@ -1,3 +1,25 @@
+2013-01-21 Kent Tamura <[email protected]>
+
+ 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.
+
+ 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.
+
2013-01-21 Alexander Pavlov <[email protected]>
Web Inspector: Do not dispatch mousemove when emulating touch event and no touch is active
Modified: trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp (140323 => 140324)
--- trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-01-21 12:45:24 UTC (rev 140323)
+++ trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-01-21 12:50:30 UTC (rev 140324)
@@ -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