Title: [105123] trunk
Revision
105123
Author
[email protected]
Date
2012-01-16 19:56:16 -0800 (Mon, 16 Jan 2012)

Log Message

Implement multiple AT_TARGET event dispatching in regard to shadow tree.
https://bugs.webkit.org/show_bug.cgi?id=76217

Reviewed by Dimitri Glazkov.

The original motivation is to fix the regression: Event.eventPhase is not set to 2
(at target) when handling dblclick event in <input> element.
Since the issue is not specific to <input> element, but general one, this patch fixes
the regression by adapting a living draft spec of shadow DOM.
This won't break a compatibility if there is no shadow boundaries in event dispatching.
See the following shadow dom spec how multiple AT_TARGET events work.
http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#event-dispatch

Source/WebCore:

* dom/EventContext.cpp:
(WebCore::EventContext::handleLocalEvents):

LayoutTests:

* fast/dom/shadow/shadow-boundary-events-expected.txt:
* fast/dom/shadow/shadow-boundary-events.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (105122 => 105123)


--- trunk/LayoutTests/ChangeLog	2012-01-17 03:47:09 UTC (rev 105122)
+++ trunk/LayoutTests/ChangeLog	2012-01-17 03:56:16 UTC (rev 105123)
@@ -1,3 +1,21 @@
+2012-01-16  Hayato Ito  <[email protected]>
+
+        Implement multiple AT_TARGET event dispatching in regard to shadow tree.
+        https://bugs.webkit.org/show_bug.cgi?id=76217
+
+        Reviewed by Dimitri Glazkov.
+
+        The original motivation is to fix the regression: Event.eventPhase is not set to 2
+        (at target) when handling dblclick event in <input> element.
+        Since the issue is not specific to <input> element, but general one, this patch fixes
+        the regression by adapting a living draft spec of shadow DOM.
+        This won't break a compatibility if there is no shadow boundaries in event dispatching.
+        See the following shadow dom spec how multiple AT_TARGET events work.
+        http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#event-dispatch
+
+        * fast/dom/shadow/shadow-boundary-events-expected.txt:
+        * fast/dom/shadow/shadow-boundary-events.html:
+
 2012-01-16  Robert Hogan  <[email protected]>
 
         Heap-use-after-free in WebCore::RenderBlock::selectionGaps

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt (105122 => 105123)


--- trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt	2012-01-17 03:47:09 UTC (rev 105122)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt	2012-01-17 03:56:16 UTC (rev 105123)
@@ -76,8 +76,8 @@
 
 Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.
 Moving focus from shadowD/shadowF/shadowG/divH to shadowD/shadowK/divL
-PASS dispatchedEvent("focus") is ["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)(capturing phase)", "divL(@divL)"]
-PASS dispatchedEvent("blur") is ["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)(capturing phase)", "shadowG(@shadowG)(capturing phase)", "divH(@divH)"]
+PASS dispatchedEvent("focus") is ["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)", "divL(@divL)"]
+PASS dispatchedEvent("blur") is ["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)", "shadowG(@shadowG)", "divH(@divH)"]
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events.html (105122 => 105123)


--- trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events.html	2012-01-17 03:47:09 UTC (rev 105122)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events.html	2012-01-17 03:56:16 UTC (rev 105123)
@@ -59,6 +59,8 @@
         eventString += '(@' + event.currentTarget.id + ')';
     if (event.eventPhase == 1)
         eventString += '(capturing phase)';
+    if (event.target && event.currentTarget && event.target.id == event.currentTarget.id)
+        shouldBe("event.eventPhase", "2", true);
     eventRecords[eventType].push(eventString);
 }
 
@@ -204,8 +206,8 @@
 
     moveFocus('shadowD/shadowF/shadowG/divH', 'shadowD/shadowK/divL',
               'Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.');
-    shouldBe('dispatchedEvent("focus")', '["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)(capturing phase)", "divL(@divL)"]');
-    shouldBe('dispatchedEvent("blur")', '["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)(capturing phase)", "shadowG(@shadowG)(capturing phase)", "divH(@divH)"]');
+    shouldBe('dispatchedEvent("focus")', '["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)", "divL(@divL)"]');
+    shouldBe('dispatchedEvent("blur")', '["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)", "shadowG(@shadowG)", "divH(@divH)"]');
 }
 
 test();

Modified: trunk/Source/WebCore/ChangeLog (105122 => 105123)


--- trunk/Source/WebCore/ChangeLog	2012-01-17 03:47:09 UTC (rev 105122)
+++ trunk/Source/WebCore/ChangeLog	2012-01-17 03:56:16 UTC (rev 105123)
@@ -1,3 +1,21 @@
+2012-01-16  Hayato Ito  <[email protected]>
+
+        Implement multiple AT_TARGET event dispatching in regard to shadow tree.
+        https://bugs.webkit.org/show_bug.cgi?id=76217
+
+        Reviewed by Dimitri Glazkov.
+
+        The original motivation is to fix the regression: Event.eventPhase is not set to 2
+        (at target) when handling dblclick event in <input> element.
+        Since the issue is not specific to <input> element, but general one, this patch fixes
+        the regression by adapting a living draft spec of shadow DOM.
+        This won't break a compatibility if there is no shadow boundaries in event dispatching.
+        See the following shadow dom spec how multiple AT_TARGET events work.
+        http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#event-dispatch
+
+        * dom/EventContext.cpp:
+        (WebCore::EventContext::handleLocalEvents):
+
 2012-01-16  Jason Liu  <[email protected]>
 
         platformRequest(QNX) need to get the conditional information from ResourceRequest.

Modified: trunk/Source/WebCore/dom/EventContext.cpp (105122 => 105123)


--- trunk/Source/WebCore/dom/EventContext.cpp	2012-01-17 03:47:09 UTC (rev 105122)
+++ trunk/Source/WebCore/dom/EventContext.cpp	2012-01-17 03:56:16 UTC (rev 105123)
@@ -43,9 +43,16 @@
 
 void EventContext::handleLocalEvents(Event* event) const
 {
+    unsigned short eventPhase = event->eventPhase();
+    if (m_target.get() == m_currentTarget.get()) {
+        if (eventPhase == Event::CAPTURING_PHASE && event->bubbles())
+            return;
+        event->setEventPhase(Event::AT_TARGET);
+    }
     event->setTarget(m_target.get());
     event->setCurrentTarget(m_currentTarget.get());
     m_node->handleLocalEvents(event);
+    event->setEventPhase(eventPhase);
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to