From f8c0802719723b9b5e90d238e3e1063bb10bce66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 30 Oct 2024 23:24:33 +0000 Subject: [PATCH] Bug 1927714 - Missing style invalidation in ShadowRoot::AddSlot(). r=smaug, a=dmeehan Usually RemoveSlot takes care of this, but if it's not the first slot it doesn't. Differential Revision: https://phabricator.services.mozilla.com/D227334 --- dom/base/ShadowRoot.cpp | 2 ++ .../shadow-reassign-dynamic-005-crash.html | 15 ++++++++++++++ .../shadow-reassign-dynamic-006-ref.html | 6 ++++++ .../shadow-reassign-dynamic-006.html | 20 +++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-005-crash.html create mode 100644 testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006-ref.html create mode 100644 testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006.html diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index 2bf79c205d62..47d29087b76b 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -253,6 +253,8 @@ void ShadowRoot::AddSlot(HTMLSlotElement* aSlot) { return; } + InvalidateStyleAndLayoutOnSubtree(aSlot); + HTMLSlotElement* oldSlot = currentSlots->SafeElementAt(1); if (SlotAssignment() == SlotAssignmentMode::Named) { if (oldSlot) { diff --git a/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-005-crash.html b/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-005-crash.html new file mode 100644 index 000000000000..9e4f002cfec3 --- /dev/null +++ b/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-005-crash.html @@ -0,0 +1,15 @@ + +
+ +
Child1
+
Child2
+
+ diff --git a/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006-ref.html b/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006-ref.html new file mode 100644 index 000000000000..60a6282457f1 --- /dev/null +++ b/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006-ref.html @@ -0,0 +1,6 @@ + +CSS Test Reference +
+
Child1
+
Child2
+
diff --git a/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006.html b/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006.html new file mode 100644 index 000000000000..ace701eea93f --- /dev/null +++ b/testing/web-platform/tests/css/css-scoping/shadow-reassign-dynamic-006.html @@ -0,0 +1,20 @@ + + +CSS Scoping: Dynamic reassignment of a named slot child. + + + + +
+ +
Child1
+
Child2
+
+