Title: [206534] trunk
- Revision
- 206534
- Author
- [email protected]
- Date
- 2016-09-28 12:37:14 -0700 (Wed, 28 Sep 2016)
Log Message
assignedNodes should include fallback contents when flattened option is set
https://bugs.webkit.org/show_bug.cgi?id=162656
Reviewed by Antti Koivisto.
LayoutTests/imported/w3c:
Rebaselined the tests now that all the test cases are passing.
* web-platform-tests/shadow-dom/slots-expected.txt:
* web-platform-tests/shadow-dom/slots-fallback-expected.txt:
Source/WebCore:
Fixed the bug by traversing through fallback contents when there are no assigned nodes.
Tests: imported/w3c/web-platform-tests/shadow-dom/slots.html
imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html
* html/HTMLSlotElement.cpp:
(WebCore::flattenAssignedNodes):
(WebCore::HTMLSlotElement::assignedNodes):
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206533 => 206534)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-09-28 19:34:27 UTC (rev 206533)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-09-28 19:37:14 UTC (rev 206534)
@@ -1,3 +1,15 @@
+2016-09-28 Ryosuke Niwa <[email protected]>
+
+ assignedNodes should include fallback contents when flattened option is set
+ https://bugs.webkit.org/show_bug.cgi?id=162656
+
+ Reviewed by Antti Koivisto.
+
+ Rebaselined the tests now that all the test cases are passing.
+
+ * web-platform-tests/shadow-dom/slots-expected.txt:
+ * web-platform-tests/shadow-dom/slots-fallback-expected.txt:
+
2016-09-27 Ryosuke Niwa <[email protected]>
Import w3c shadow DOM tests and fix one assertion
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-expected.txt (206533 => 206534)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-expected.txt 2016-09-28 19:34:27 UTC (rev 206533)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-expected.txt 2016-09-28 19:37:14 UTC (rev 206534)
@@ -2,7 +2,7 @@
PASS Slots: Basic.
PASS Slots: Slots in closed.
PASS Slots: Slots not in a shadow tree.
-FAIL Slots: Distributed nooes for Slots not in a shadow tree. assert_array_equals: lengths differ, expected 1 got 0
+PASS Slots: Distributed nooes for Slots not in a shadow tree.
PASS Slots: Name matching
PASS Slots: No direct host child.
PASS Slots: Default Slot.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-expected.txt (206533 => 206534)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-expected.txt 2016-09-28 19:34:27 UTC (rev 206533)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-expected.txt 2016-09-28 19:37:14 UTC (rev 206534)
@@ -1,12 +1,12 @@
-FAIL Slots fallback: Basic. assert_array_equals: lengths differ, expected 1 got 0
-FAIL Slots fallback: Slots in Slots. assert_array_equals: lengths differ, expected 1 got 0
-FAIL Slots fallback: Fallback contents should not be used if a node is assigned. assert_array_equals: lengths differ, expected 1 got 0
-FAIL Slots fallback: Slots in Slots: Assinged nodes should be used as fallback contents of another slot assert_array_equals: lengths differ, expected 1 got 0
-FAIL Slots fallback: Complex case. assert_array_equals: lengths differ, expected 2 got 0
-FAIL Slots fallback: Mutation. Append fallback contents. assert_array_equals: lengths differ, expected 3 got 0
-FAIL Slots fallback: Mutation. Remove fallback contents. assert_array_equals: lengths differ, expected 1 got 0
-FAIL Slots fallback: Mutation. Assign a node to a slot so that fallback contens are no longer used. assert_array_equals: lengths differ, expected 2 got 0
-FAIL Slots fallback: Mutation. Remove an assigned node from a slot so that fallback contens will be used. assert_array_equals: lengths differ, expected 1 got 0
-FAIL Slots fallback: Mutation. Remove a slot which is a fallback content of another slot. assert_array_equals: lengths differ, expected 1 got 0
+PASS Slots fallback: Basic.
+PASS Slots fallback: Slots in Slots.
+PASS Slots fallback: Fallback contents should not be used if a node is assigned.
+PASS Slots fallback: Slots in Slots: Assinged nodes should be used as fallback contents of another slot
+PASS Slots fallback: Complex case.
+PASS Slots fallback: Mutation. Append fallback contents.
+PASS Slots fallback: Mutation. Remove fallback contents.
+PASS Slots fallback: Mutation. Assign a node to a slot so that fallback contens are no longer used.
+PASS Slots fallback: Mutation. Remove an assigned node from a slot so that fallback contens will be used.
+PASS Slots fallback: Mutation. Remove a slot which is a fallback content of another slot.
Modified: trunk/Source/WebCore/ChangeLog (206533 => 206534)
--- trunk/Source/WebCore/ChangeLog 2016-09-28 19:34:27 UTC (rev 206533)
+++ trunk/Source/WebCore/ChangeLog 2016-09-28 19:37:14 UTC (rev 206534)
@@ -1,3 +1,19 @@
+2016-09-28 Ryosuke Niwa <[email protected]>
+
+ assignedNodes should include fallback contents when flattened option is set
+ https://bugs.webkit.org/show_bug.cgi?id=162656
+
+ Reviewed by Antti Koivisto.
+
+ Fixed the bug by traversing through fallback contents when there are no assigned nodes.
+
+ Tests: imported/w3c/web-platform-tests/shadow-dom/slots.html
+ imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html
+
+ * html/HTMLSlotElement.cpp:
+ (WebCore::flattenAssignedNodes):
+ (WebCore::HTMLSlotElement::assignedNodes):
+
2016-09-27 Wenson Hsieh <[email protected]>
Adopt MediaRemote SPI to achieve desired Now Playing behavior
Modified: trunk/Source/WebCore/html/HTMLSlotElement.cpp (206533 => 206534)
--- trunk/Source/WebCore/html/HTMLSlotElement.cpp 2016-09-28 19:34:27 UTC (rev 206533)
+++ trunk/Source/WebCore/html/HTMLSlotElement.cpp 2016-09-28 19:37:14 UTC (rev 206534)
@@ -26,12 +26,12 @@
#include "config.h"
#include "HTMLSlotElement.h"
-
#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
#include "MutationObserver.h"
#include "ShadowRoot.h"
+#include "Text.h"
namespace WebCore {
@@ -98,30 +98,37 @@
return shadowRoot->assignedNodesForSlot(*this);
}
-static void flattenAssignedNodes(Vector<Node*>& nodes, const Vector<Node*>& assignedNodes)
+static void flattenAssignedNodes(Vector<Node*>& nodes, const HTMLSlotElement& slot)
{
- for (Node* node : assignedNodes) {
- if (is<HTMLSlotElement>(*node)) {
- if (auto* innerAssignedNodes = downcast<HTMLSlotElement>(*node).assignedNodes())
- flattenAssignedNodes(nodes, *innerAssignedNodes);
- continue;
+ auto* assignedNodes = slot.assignedNodes();
+ if (!assignedNodes) {
+ for (Node* child = slot.firstChild(); child; child = child->nextSibling()) {
+ if (is<HTMLSlotElement>(*child))
+ flattenAssignedNodes(nodes, downcast<HTMLSlotElement>(*child));
+ else if (is<Text>(*child) || is<Element>(*child))
+ nodes.append(child);
}
- nodes.append(node);
+ return;
}
+ for (Node* node : *assignedNodes) {
+ if (is<HTMLSlotElement>(*node))
+ flattenAssignedNodes(nodes, downcast<HTMLSlotElement>(*node));
+ else
+ nodes.append(node);
+ }
}
Vector<Node*> HTMLSlotElement::assignedNodes(const AssignedNodesOptions& options) const
{
+ if (options.flatten) {
+ Vector<Node*> nodes;
+ flattenAssignedNodes(nodes, *this);
+ return nodes;
+ }
auto* assignedNodes = this->assignedNodes();
if (!assignedNodes)
return { };
-
- if (!options.flatten)
- return *assignedNodes;
-
- Vector<Node*> nodes;
- flattenAssignedNodes(nodes, *assignedNodes);
- return nodes;
+ return *assignedNodes;
}
void HTMLSlotElement::enqueueSlotChangeEvent()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes