Title: [261433] trunk
Revision
261433
Author
[email protected]
Date
2020-05-09 00:00:41 -0700 (Sat, 09 May 2020)

Log Message

Fix wpt shadow-dom/slots-fallback-in-document.html
https://bugs.webkit.org/show_bug.cgi?id=211640

Patch by Tetsuharu Ohzeki <[email protected]> on 2020-05-09
Reviewed by Ryosuke Niwa.

By specs, HTMLSlotElement.assignedNodes() should not count children of
a slot in a document tree for flattened assigned nodes.

https://html.spec.whatwg.org/multipage/scripting.html#dom-slot-assignednodes
https://dom.spec.whatwg.org/#find-flattened-slotables

As sideeffect, this patch also fix wpt
shadow-dom/slots-outside-shadow-dom-expected.html

LayoutTests/imported/w3c:

* web-platform-tests/shadow-dom/slots-fallback-in-document-expected.txt:
* web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt:

Source/WebCore:

Test: web-platform-tests/shadow-dom/slots-fallback-in-document.html
      web-platform-tests/shadow-dom/slots-outside-shadow-dom.html

* html/HTMLSlotElement.cpp:
(WebCore::flattenAssignedNodes):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (261432 => 261433)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-05-09 05:32:06 UTC (rev 261432)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-05-09 07:00:41 UTC (rev 261433)
@@ -1,3 +1,23 @@
+2020-05-09  Tetsuharu Ohzeki  <[email protected]>
+
+        Fix wpt shadow-dom/slots-fallback-in-document.html
+        https://bugs.webkit.org/show_bug.cgi?id=211640
+
+        Reviewed by Ryosuke Niwa.
+
+        By specs, HTMLSlotElement.assignedNodes() should not count children of
+        a slot in a document tree for flattened assigned nodes.
+
+        https://html.spec.whatwg.org/multipage/scripting.html#dom-slot-assignednodes
+        https://dom.spec.whatwg.org/#find-flattened-slotables
+
+        As sideeffect, this patch also fix wpt
+        shadow-dom/slots-outside-shadow-dom-expected.html
+
+        * web-platform-tests/shadow-dom/slots-fallback-in-document-expected.txt:
+        * web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt:
+
+
 2020-05-08  David Kilzer  <[email protected]>
 
         Remove empty directories from from svn.webkit.org repository

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-in-document-expected.txt (261432 => 261433)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-in-document-expected.txt	2020-05-09 05:32:06 UTC (rev 261432)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-in-document-expected.txt	2020-05-09 07:00:41 UTC (rev 261433)
@@ -1,5 +1,5 @@
 This is fallback content
 
-FAIL Children of a slot in a document tree should not be counted in flattened assigned nodes. assert_array_equals: property 0, expected Element node <slot id="slot"><div id="fallback">This is fallback conte... but got Element node <div id="fallback">This is fallback content</div>
+PASS Children of a slot in a document tree should not be counted in flattened assigned nodes. 
 PASS Slot fallback content in shadow tree should be counted in flattened assigned nodes. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt (261432 => 261433)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt	2020-05-09 05:32:06 UTC (rev 261432)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt	2020-05-09 07:00:41 UTC (rev 261433)
@@ -1,4 +1,4 @@
 foo
 
-FAIL Light DOM slot element should be in flattened assignedNodes assert_array_equals: property 0, expected Element node <slot>foo</slot> but got Text node "foo"
+PASS Light DOM slot element should be in flattened assignedNodes 
 

Modified: trunk/Source/WebCore/ChangeLog (261432 => 261433)


--- trunk/Source/WebCore/ChangeLog	2020-05-09 05:32:06 UTC (rev 261432)
+++ trunk/Source/WebCore/ChangeLog	2020-05-09 07:00:41 UTC (rev 261433)
@@ -1,3 +1,25 @@
+2020-05-09  Tetsuharu Ohzeki  <[email protected]>
+
+        Fix wpt shadow-dom/slots-fallback-in-document.html
+        https://bugs.webkit.org/show_bug.cgi?id=211640
+
+        Reviewed by Ryosuke Niwa.
+
+        By specs, HTMLSlotElement.assignedNodes() should not count children of
+        a slot in a document tree for flattened assigned nodes.
+
+        https://html.spec.whatwg.org/multipage/scripting.html#dom-slot-assignednodes
+        https://dom.spec.whatwg.org/#find-flattened-slotables
+
+        As sideeffect, this patch also fix wpt
+        shadow-dom/slots-outside-shadow-dom-expected.html
+
+        Test: web-platform-tests/shadow-dom/slots-fallback-in-document.html
+              web-platform-tests/shadow-dom/slots-outside-shadow-dom.html
+
+        * html/HTMLSlotElement.cpp:
+        (WebCore::flattenAssignedNodes):
+
 2020-05-08  Basuke Suzuki  <[email protected]>
 
         Fix build error on PlatStation port after r261132

Modified: trunk/Source/WebCore/html/HTMLSlotElement.cpp (261432 => 261433)


--- trunk/Source/WebCore/html/HTMLSlotElement.cpp	2020-05-09 05:32:06 UTC (rev 261432)
+++ trunk/Source/WebCore/html/HTMLSlotElement.cpp	2020-05-09 07:00:41 UTC (rev 261433)
@@ -106,6 +106,9 @@
 
 static void flattenAssignedNodes(Vector<Ref<Node>>& nodes, const HTMLSlotElement& slot)
 {
+    if (!slot.containingShadowRoot())
+        return;
+
     auto* assignedNodes = slot.assignedNodes();
     if (!assignedNodes) {
         for (RefPtr<Node> child = slot.firstChild(); child; child = child->nextSibling()) {
@@ -117,7 +120,7 @@
         return;
     }
     for (const RefPtr<Node>& node : *assignedNodes) {
-        if (is<HTMLSlotElement>(*node))
+        if (is<HTMLSlotElement>(*node) && downcast<HTMLSlotElement>(*node).containingShadowRoot())
             flattenAssignedNodes(nodes, downcast<HTMLSlotElement>(*node));
         else
             nodes.append(*node);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to