Title: [132983] trunk
Revision
132983
Author
[email protected]
Date
2012-10-30 22:19:21 -0700 (Tue, 30 Oct 2012)

Log Message

Delaying 'change' and 'input' event dispatching during HTMLInputElement::setValue
https://bugs.webkit.org/show_bug.cgi?id=100772

Reviewed by Abhishek Arya.

Source/WebCore:

'change' and 'input' events are asynchronous and not
cancelable. We can use ScopedEvent.

Test: fast/forms/range/range-type-change-onchange.html

* dom/Node.cpp:
(WebCore::Node::dispatchChangeEvent): Use dispatchScopedEvent.
(WebCore::Node::dispatchInputEvent): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setValue):
Make a scope to delay event dispatching.
* html/RangeInputType.cpp:
(WebCore::RangeInputType::handleKeydownEvent): Ditto.

LayoutTests:

* fast/forms/range/range-type-change-onchange-expected.txt: Added.
* fast/forms/range/range-type-change-onchange.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (132982 => 132983)


--- trunk/LayoutTests/ChangeLog	2012-10-31 05:03:52 UTC (rev 132982)
+++ trunk/LayoutTests/ChangeLog	2012-10-31 05:19:21 UTC (rev 132983)
@@ -1,3 +1,13 @@
+2012-10-30  Kent Tamura  <[email protected]>
+
+        Delaying 'change' and 'input' event dispatching during HTMLInputElement::setValue
+        https://bugs.webkit.org/show_bug.cgi?id=100772
+
+        Reviewed by Abhishek Arya.
+
+        * fast/forms/range/range-type-change-onchange-expected.txt: Added.
+        * fast/forms/range/range-type-change-onchange.html: Added.
+
 2012-10-30  Simon Fraser  <[email protected]>
 
         Fix issues with filters and reflections

Added: trunk/LayoutTests/fast/forms/range/range-type-change-onchange-expected.txt (0 => 132983)


--- trunk/LayoutTests/fast/forms/range/range-type-change-onchange-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/range/range-type-change-onchange-expected.txt	2012-10-31 05:19:21 UTC (rev 132983)
@@ -0,0 +1,10 @@
+Check if no problem happens by type change in onchange handler.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS unless crash
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/range/range-type-change-onchange.html (0 => 132983)


--- trunk/LayoutTests/fast/forms/range/range-type-change-onchange.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/range/range-type-change-onchange.html	2012-10-31 05:19:21 UTC (rev 132983)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+
+<input id="range1" type="range" _onchange_="updateType(this)" autofocus>
+<script>
+description('Check if no problem happens by type change in onchange handler.');
+
+function updateType(input) {
+    input.type = 'text';
+    setTimeout(finish, 0);
+}
+
+function finish() {
+    testPassed('unless crash');
+    finishJSTest();
+}
+
+jsTestIsAsync = true;
+eventSender.keyDown('upArrow');
+</script>
+<script src=""
+</body>
Property changes on: trunk/LayoutTests/fast/forms/range/range-type-change-onchange.html
___________________________________________________________________

Added: svn:mime-type

Modified: trunk/Source/WebCore/ChangeLog (132982 => 132983)


--- trunk/Source/WebCore/ChangeLog	2012-10-31 05:03:52 UTC (rev 132982)
+++ trunk/Source/WebCore/ChangeLog	2012-10-31 05:19:21 UTC (rev 132983)
@@ -1,3 +1,24 @@
+2012-10-30  Kent Tamura  <[email protected]>
+
+        Delaying 'change' and 'input' event dispatching during HTMLInputElement::setValue
+        https://bugs.webkit.org/show_bug.cgi?id=100772
+
+        Reviewed by Abhishek Arya.
+
+        'change' and 'input' events are asynchronous and not
+        cancelable. We can use ScopedEvent.
+
+        Test: fast/forms/range/range-type-change-onchange.html
+
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchChangeEvent): Use dispatchScopedEvent.
+        (WebCore::Node::dispatchInputEvent): Ditto.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setValue):
+        Make a scope to delay event dispatching.
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::handleKeydownEvent): Ditto.
+
 2012-10-30  Simon Fraser  <[email protected]>
 
         Fix issues with filters and reflections

Modified: trunk/Source/WebCore/dom/Node.cpp (132982 => 132983)


--- trunk/Source/WebCore/dom/Node.cpp	2012-10-31 05:03:52 UTC (rev 132982)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-10-31 05:19:21 UTC (rev 132983)
@@ -2665,12 +2665,12 @@
 
 void Node::dispatchChangeEvent()
 {
-    dispatchEvent(Event::create(eventNames().changeEvent, true, false));
+    dispatchScopedEvent(Event::create(eventNames().changeEvent, true, false));
 }
 
 void Node::dispatchInputEvent()
 {
-    dispatchEvent(Event::create(eventNames().inputEvent, true, false));
+    dispatchScopedEvent(Event::create(eventNames().inputEvent, true, false));
 }
 
 bool Node::disabled() const

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (132982 => 132983)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-10-31 05:03:52 UTC (rev 132982)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-10-31 05:19:21 UTC (rev 132983)
@@ -54,6 +54,7 @@
 #include "NumberInputType.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
+#include "ScopedEventQueue.h"
 #include "SearchInputType.h"
 #include "ShadowRoot.h"
 #include "ScriptEventListener.h"
@@ -1021,6 +1022,7 @@
         return;
 
     RefPtr<HTMLInputElement> protector(this);
+    EventQueueScope scope;
     String sanitizedValue = sanitizeValue(value);
     bool valueChanged = sanitizedValue != this->value();
 

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (132982 => 132983)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2012-10-31 05:03:52 UTC (rev 132982)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2012-10-31 05:19:21 UTC (rev 132983)
@@ -43,6 +43,7 @@
 #include "MouseEvent.h"
 #include "PlatformMouseEvent.h"
 #include "RenderSlider.h"
+#include "ScopedEventQueue.h"
 #include "ShadowRoot.h"
 #include "SliderThumbElement.h"
 #include "StepRange.h"
@@ -235,6 +236,7 @@
     newValue = stepRange.clampValue(newValue);
 
     if (newValue != current) {
+        EventQueueScope scope;
         ExceptionCode ec;
         TextFieldEventBehavior eventBehavior = DispatchChangeEvent;
         setValueAsDecimal(newValue, eventBehavior, ec);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to