Title: [120754] trunk
Revision
120754
Author
[email protected]
Date
2012-06-19 14:20:22 -0700 (Tue, 19 Jun 2012)

Log Message

[Shadow DOM] An upper boundary breaks if a child node of an insertion point is clicked.
https://bugs.webkit.org/show_bug.cgi?id=89407

Reviewed by Dimitri Glazkov.

Source/WebCore:

Update an event re-targeting algorithm so that it can set event's
target correctly when a fallback element in an insertion point is
clicked. To distinguish between distributed nodes and fallback
elements in an ancestor chain of composite shadow tree, an event
dispatcher checks explicitly whether a node is actually
distributed or assigned to the given insertion point.

Test: fast/dom/shadow/shadow-dom-event-dispatching.html

* dom/EventDispatcher.cpp:
(WebCore::isAssignedTo):
(WebCore):
(WebCore::EventDispatcher::ensureEventAncestors):
* html/shadow/InsertionPoint.h:
(WebCore::InsertionPoint::contains):

LayoutTests:

* fast/dom/shadow/shadow-dom-event-dispatching-expected.txt:
* fast/dom/shadow/shadow-dom-event-dispatching.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120753 => 120754)


--- trunk/LayoutTests/ChangeLog	2012-06-19 21:19:37 UTC (rev 120753)
+++ trunk/LayoutTests/ChangeLog	2012-06-19 21:20:22 UTC (rev 120754)
@@ -1,3 +1,13 @@
+2012-06-19  Hayato Ito  <[email protected]>
+
+        [Shadow DOM] An upper boundary breaks if a child node of an insertion point is clicked.
+        https://bugs.webkit.org/show_bug.cgi?id=89407
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/shadow-dom-event-dispatching-expected.txt:
+        * fast/dom/shadow/shadow-dom-event-dispatching.html:
+
 2012-06-19  Martin Kosiba  <[email protected]>
 
         [Chromium] Add LayoutTests for find in page.

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-expected.txt (120753 => 120754)


--- trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-expected.txt	2012-06-19 21:19:37 UTC (rev 120753)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-expected.txt	2012-06-19 21:20:22 UTC (rev 120754)
@@ -405,26 +405,36 @@
 DIV	 id=sandbox
 	DIV	 id=top
 		DIV	 id=A
-			DIV	 id=fallback
+			DIV	 id=used-fallback
+			DIV	 id=B
 
 
-Moving mouse from A/fallback to A
+Moving mouse from A/used-fallback to A
 
   mouseout
-     @fallback (target: fallback) (related: A)
-     @content (target: fallback) (related: A)
-     @shadow-root (target: fallback) (related: A)
+     @used-fallback (target: used-fallback) (related: A)
+     @content1 (target: used-fallback) (related: A)
+     @shadow-root (target: used-fallback) (related: A)
 
   mouseover
 
-Moving mouse from A to A/fallback
+Moving mouse from A to A/used-fallback
 
   mouseout
 
   mouseover
-     @fallback (target: fallback) (related: A)
-     @content (target: fallback) (related: A)
-     @shadow-root (target: fallback) (related: A)
+     @used-fallback (target: used-fallback) (related: A)
+     @content1 (target: used-fallback) (related: A)
+     @shadow-root (target: used-fallback) (related: A)
+
+Click non-used-fallback node
+
+  click
+     @non-used-fallback (target: non-used-fallback)
+     @content2 (target: non-used-fallback)
+     @shadow-root (target: non-used-fallback)
+     @A (target: A)
+     @top (target: A)
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching.html (120753 => 120754)


--- trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching.html	2012-06-19 21:19:37 UTC (rev 120753)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching.html	2012-06-19 21:20:22 UTC (rev 120754)
@@ -359,16 +359,23 @@
         createDOM('div', {'id': 'top'},
                   createDOM('div', {'id': 'A'},
                             createShadowRoot(
-                                createDOM('content', {'id': 'content', 'select': '#none'},
-                                          createDOM('div', {'id': 'fallback'}))),
+                                createDOM('content', {'id': 'content1', 'select': '#none'},
+                                          createDOM('div', {'id': 'used-fallback'})),
+                                createDOM('content', {'id': 'content2'},
+                                          createDOM('div', {'id': 'non-used-fallback'}))),
                             createDOM('div', {'id': 'B'}))));
 
-    addEventListeners(['top', 'A', 'B', 'A/', 'A/content', 'A/fallback']);
+    addEventListeners(['top', 'A', 'B', 'A/', 'A/content1', 'A/used-fallback', 'A/content2', 'A/non-used-fallback']);
     getNodeInShadowTreeStack('A/').id = 'shadow-root';
     showSandboxTree();
 
-    moveMouse('A/fallback', 'A');
-    moveMouse('A', 'A/fallback');
+    moveMouse('A/used-fallback', 'A');
+    moveMouse('A', 'A/used-fallback');
+
+    clearEventRecords();
+    debug('\nClick non-used-fallback node');
+    getNodeInShadowTreeStack('A/non-used-fallback').click();
+    debugDispatchedEvent('click');
 }
 
 function test()

Modified: trunk/Source/WebCore/ChangeLog (120753 => 120754)


--- trunk/Source/WebCore/ChangeLog	2012-06-19 21:19:37 UTC (rev 120753)
+++ trunk/Source/WebCore/ChangeLog	2012-06-19 21:20:22 UTC (rev 120754)
@@ -1,3 +1,26 @@
+2012-06-19  Hayato Ito  <[email protected]>
+
+        [Shadow DOM] An upper boundary breaks if a child node of an insertion point is clicked.
+        https://bugs.webkit.org/show_bug.cgi?id=89407
+
+        Reviewed by Dimitri Glazkov.
+
+        Update an event re-targeting algorithm so that it can set event's
+        target correctly when a fallback element in an insertion point is
+        clicked. To distinguish between distributed nodes and fallback
+        elements in an ancestor chain of composite shadow tree, an event
+        dispatcher checks explicitly whether a node is actually
+        distributed or assigned to the given insertion point.
+
+        Test: fast/dom/shadow/shadow-dom-event-dispatching.html
+
+        * dom/EventDispatcher.cpp:
+        (WebCore::isAssignedTo):
+        (WebCore):
+        (WebCore::EventDispatcher::ensureEventAncestors):
+        * html/shadow/InsertionPoint.h:
+        (WebCore::InsertionPoint::contains):
+
 2012-06-19  Adrienne Walker  <[email protected]>
 
         Fix scrollbar layers being misplaced with a clipped owner layer

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (120753 => 120754)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2012-06-19 21:19:37 UTC (rev 120753)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2012-06-19 21:20:22 UTC (rev 120754)
@@ -51,6 +51,12 @@
 
 static HashSet<Node*>* gNodesDispatchingSimulatedClicks = 0;
 
+static inline bool isAssignedTo(const Node* node, const InsertionPoint* insertionPoint)
+{
+    ASSERT(insertionPoint);
+    return node && (insertionPoint->contains(node) || (node->isShadowRoot() && toShadowRoot(node)->assignedTo() == insertionPoint));
+}
+
 EventRelatedTargetAdjuster::EventRelatedTargetAdjuster(PassRefPtr<Node> node, PassRefPtr<Node> relatedTarget)
     : m_node(node)
     , m_relatedTarget(relatedTarget)
@@ -203,13 +209,15 @@
     bool inDocument = m_node->inDocument();
     bool isSVGElement = m_node->isSVGElement();
     Vector<EventTarget*> targetStack;
+    Node* last = 0;
     for (ComposedShadowTreeParentWalker walker(m_node.get()); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) {
         Node* node = walker.get();
-        if ((isInsertionPoint(node) && toInsertionPoint(node)->hasDistribution()) || targetStack.isEmpty())
+        if ((isInsertionPoint(node) && isAssignedTo(last, toInsertionPoint(node))) || targetStack.isEmpty())
             targetStack.append(eventTargetRespectingSVGTargetRules(node));
         m_ancestors.append(EventContext(node, eventTargetRespectingSVGTargetRules(node), targetStack.last()));
         if (!inDocument)
             return;
+        last = node;
         if (!node->isShadowRoot())
             continue;
         if (determineDispatchBehavior(event, toShadowRoot(node)) == StayInsideShadowDOM)

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (120753 => 120754)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.h	2012-06-19 21:19:37 UTC (rev 120753)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h	2012-06-19 21:20:22 UTC (rev 120754)
@@ -57,6 +57,7 @@
     virtual bool isInsertionPoint() const OVERRIDE { return true; }
 
     size_t indexOf(Node* node) const { return m_distribution.find(node); }
+    bool contains(const Node* node) const { return m_distribution.contains(const_cast<Node*>(node)); }
     size_t size() const { return m_distribution.size(); }
     Node* at(size_t index)  const { return m_distribution.at(index).get(); }
     Node* first() const { return m_distribution.isEmpty() ? 0 : m_distribution.first().get(); }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to