Title: [88026] trunk
Revision
88026
Author
[email protected]
Date
2011-06-03 09:26:15 -0700 (Fri, 03 Jun 2011)

Log Message

2011-06-02  Dimitri Glazkov  <[email protected]>

        Reviewed by Darin Adler.

        Prevent event dispatch for events with related target when host is the target.
        https://bugs.webkit.org/show_bug.cgi?id=61979

        * fast/events/shadow-boundary-crossing-expected.txt: Added test.
        * fast/events/shadow-boundary-crossing.html: Added expectations.
2011-06-02  Dimitri Glazkov  <[email protected]>

        Reviewed by Darin Adler.

        Prevent event dispatch for events with related target when host is the target.
        https://bugs.webkit.org/show_bug.cgi?id=61979

        Turns out, even if we trim the ancestor chain to 0, the event is still dispatched during AT_TARGET.
        So might as well be explicit about what we are trying to do and add a flag to prevent dispatch in these cases.

        * dom/EventDispatcher.cpp:
        (WebCore::EventDispatcher::adjustToShadowBoundaries): Added preventing dispatch when the ancestor chain is trimmed to nothing.
        (WebCore::EventDispatcher::EventDispatcher): Added initializer.
        (WebCore::EventDispatcher::dispatchEvent): Added a check to prevent dispatch.
        * dom/EventDispatcher.h: Added a def.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (88025 => 88026)


--- trunk/LayoutTests/ChangeLog	2011-06-03 16:24:23 UTC (rev 88025)
+++ trunk/LayoutTests/ChangeLog	2011-06-03 16:26:15 UTC (rev 88026)
@@ -1,3 +1,13 @@
+2011-06-02  Dimitri Glazkov  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        Prevent event dispatch for events with related target when host is the target.
+        https://bugs.webkit.org/show_bug.cgi?id=61979
+
+        * fast/events/shadow-boundary-crossing-expected.txt: Added test.
+        * fast/events/shadow-boundary-crossing.html: Added expectations.
+
 2011-06-03  Mario Sanchez Prada  <[email protected]>
 
         Unreviewed, new baselines for GTK after r88007 and r8009.

Modified: trunk/LayoutTests/fast/events/shadow-boundary-crossing-expected.txt (88025 => 88026)


--- trunk/LayoutTests/fast/events/shadow-boundary-crossing-expected.txt	2011-06-03 16:24:23 UTC (rev 88025)
+++ trunk/LayoutTests/fast/events/shadow-boundary-crossing-expected.txt	2011-06-03 16:26:15 UTC (rev 88026)
@@ -6,6 +6,7 @@
 The selectstart event should not propagate out of the shadow DOM: PASS
 The mouseover/mouseout event between two elements inside the same shadow subtree should not propagate out of the shadow DOM: PASS
 The mouseover event in a shadow subtree, where related target is the tree host should not escape out of shadow DOM: PASS
+Events with relatedTarget should not escape out of shadow subtree when its host is the target: PASS
 The mouseover/mouseout event on a shadow subtree host should propagate out of the shadow DOM: PASS
 Label should look beyond shadow boundary to detect if it encloses its associated element: PASS
 Events for default event handler should not be retargeted: PASS

Modified: trunk/LayoutTests/fast/events/shadow-boundary-crossing.html (88025 => 88026)


--- trunk/LayoutTests/fast/events/shadow-boundary-crossing.html	2011-06-03 16:24:23 UTC (rev 88025)
+++ trunk/LayoutTests/fast/events/shadow-boundary-crossing.html	2011-06-03 16:26:15 UTC (rev 88026)
@@ -136,6 +136,28 @@
         relatedTarget.removeEventListener('mouseover', countEventDispatch, false);
         document.body.removeChild(relatedTarget);
     },
+    targetAsHost: function()
+    {
+        var count = 0;
+        var target = document.createElement('div');
+        target.style.cssText = 'width: 50px; height: 50px; padding-left: 50px;';
+        document.body.appendChild(target);
+        var relatedTarget = document.createElement('div');
+        relatedTarget.style.cssText = 'width: 50px; height: 50px';
+        layoutTestController.ensureShadowRoot(target).appendChild(relatedTarget);
+        moveOverRightQuarterOf(target);
+        var countEventDispatch = function(evt)
+        {
+            count++;
+        }
+        target.addEventListener('mouseover', countEventDispatch, false)
+        moveOverLeftQuarterOf(target);
+
+        log("Events with relatedTarget should not escape out of shadow subtree when its host is the target", count == 0);
+
+        target.removeEventListener('mouseout', countEventDispatch, false);
+        document.body.removeChild(target);
+    },
     mouseOverOnHost: function()
     {
         var count = 0;

Modified: trunk/Source/WebCore/ChangeLog (88025 => 88026)


--- trunk/Source/WebCore/ChangeLog	2011-06-03 16:24:23 UTC (rev 88025)
+++ trunk/Source/WebCore/ChangeLog	2011-06-03 16:26:15 UTC (rev 88026)
@@ -1,3 +1,19 @@
+2011-06-02  Dimitri Glazkov  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        Prevent event dispatch for events with related target when host is the target.
+        https://bugs.webkit.org/show_bug.cgi?id=61979
+
+        Turns out, even if we trim the ancestor chain to 0, the event is still dispatched during AT_TARGET.
+        So might as well be explicit about what we are trying to do and add a flag to prevent dispatch in these cases.
+
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::adjustToShadowBoundaries): Added preventing dispatch when the ancestor chain is trimmed to nothing.
+        (WebCore::EventDispatcher::EventDispatcher): Added initializer.
+        (WebCore::EventDispatcher::dispatchEvent): Added a check to prevent dispatch.
+        * dom/EventDispatcher.h: Added a def.
+
 2011-06-03  Dan Bernstein  <[email protected]>
 
         Mac build fix.

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (88025 => 88026)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2011-06-03 16:24:23 UTC (rev 88025)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2011-06-03 16:26:15 UTC (rev 88026)
@@ -175,9 +175,11 @@
         lowestCommonBoundary = m_ancestors.begin();
     }
 
-    // Trim ancestors to lowestCommonBoundary to keep events inside of the common shadow DOM subtree.
-    if (lowestCommonBoundary != m_ancestors.end())
+    if (lowestCommonBoundary != m_ancestors.end()) {
+        // Trim ancestors to lowestCommonBoundary to keep events inside of the common shadow DOM subtree.
         m_ancestors.shrink(lowestCommonBoundary - m_ancestors.begin());
+        m_shouldPreventDispatch = !m_ancestors.size();
+    }
     // Set event's related target to the first encountered shadow DOM boundary in the divergent subtree.
     return firstDivergentBoundary != relatedTargetAncestors.begin() ? *firstDivergentBoundary : relatedTarget;
 }
@@ -228,6 +230,7 @@
 EventDispatcher::EventDispatcher(Node* node)
     : m_node(node)
     , m_ancestorsInitialized(false)
+    , m_shouldPreventDispatch(false)
 {
     ASSERT(node);
     m_view = node->document()->view();
@@ -292,7 +295,7 @@
 
     // Give the target node a chance to do some work before DOM event handlers get a crack.
     void* data = ""
-    if (event->propagationStopped())
+    if (m_shouldPreventDispatch || event->propagationStopped())
         goto doneDispatching;
 
     // Trigger capturing event handlers, starting at the top and working our way down.

Modified: trunk/Source/WebCore/dom/EventDispatcher.h (88025 => 88026)


--- trunk/Source/WebCore/dom/EventDispatcher.h	2011-06-03 16:24:23 UTC (rev 88025)
+++ trunk/Source/WebCore/dom/EventDispatcher.h	2011-06-03 16:26:15 UTC (rev 88026)
@@ -70,6 +70,7 @@
     RefPtr<EventTarget> m_originalTarget;
     RefPtr<FrameView> m_view;
     bool m_ancestorsInitialized;
+    bool m_shouldPreventDispatch;
 };
 
 inline Node* EventDispatcher::node() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to