Title: [285211] trunk
- Revision
- 285211
- Author
- an...@apple.com
- Date
- 2021-11-03 09:59:48 -0700 (Wed, 03 Nov 2021)
Log Message
::slotted element style not invalidated correctly in nested case
https://bugs.webkit.org/show_bug.cgi?id=232665
Reviewed by Simon Fraser.
LayoutTests/imported/w3c:
* web-platform-tests/css/css-scoping/slotted-nested-expected.txt:
Source/WebCore:
We fail to invalidate ::slotted style if the assigned node is not from the current host scope.
* style/StyleInvalidator.cpp:
(WebCore::Style::invalidateAssignedElements):
Invalidate more accurately by following assigned node chain recursively instead of just invalidating all host children.
(WebCore::Style::Invalidator::invalidateIfNeeded):
Remove the unnecessary and incorrect m_didInvalidateHostChildren optimization.
* style/StyleInvalidator.h:
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285210 => 285211)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-03 16:52:28 UTC (rev 285210)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-03 16:59:48 UTC (rev 285211)
@@ -1,5 +1,14 @@
2021-11-03 Antti Koivisto <an...@apple.com>
+ ::slotted element style not invalidated correctly in nested case
+ https://bugs.webkit.org/show_bug.cgi?id=232665
+
+ Reviewed by Simon Fraser.
+
+ * web-platform-tests/css/css-scoping/slotted-nested-expected.txt:
+
+2021-11-03 Antti Koivisto <an...@apple.com>
+
::slotted shouldn't match an active <slot>
https://bugs.webkit.org/show_bug.cgi?id=232664
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-nested-expected.txt (285210 => 285211)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-nested-expected.txt 2021-11-03 16:52:28 UTC (rev 285210)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-nested-expected.txt 2021-11-03 16:59:48 UTC (rev 285211)
@@ -2,5 +2,5 @@
PASS Slotted matches rules against the slot in the right tree
-FAIL Style invalidation works correctly for nested slots assert_not_equals: got disallowed value "rgb(0, 128, 0)"
+PASS Style invalidation works correctly for nested slots
Modified: trunk/Source/WebCore/ChangeLog (285210 => 285211)
--- trunk/Source/WebCore/ChangeLog 2021-11-03 16:52:28 UTC (rev 285210)
+++ trunk/Source/WebCore/ChangeLog 2021-11-03 16:59:48 UTC (rev 285211)
@@ -1,3 +1,23 @@
+2021-11-03 Antti Koivisto <an...@apple.com>
+
+ ::slotted element style not invalidated correctly in nested case
+ https://bugs.webkit.org/show_bug.cgi?id=232665
+
+ Reviewed by Simon Fraser.
+
+ We fail to invalidate ::slotted style if the assigned node is not from the current host scope.
+
+ * style/StyleInvalidator.cpp:
+ (WebCore::Style::invalidateAssignedElements):
+
+ Invalidate more accurately by following assigned node chain recursively instead of just invalidating all host children.
+
+ (WebCore::Style::Invalidator::invalidateIfNeeded):
+
+ Remove the unnecessary and incorrect m_didInvalidateHostChildren optimization.
+
+ * style/StyleInvalidator.h:
+
2021-11-03 Jer Noble <jer.no...@apple.com>
[iOS] AVAssetResourceLoadingRequest.request does not include a Range: header on iOS 15.
Modified: trunk/Source/WebCore/style/StyleInvalidator.cpp (285210 => 285211)
--- trunk/Source/WebCore/style/StyleInvalidator.cpp 2021-11-03 16:52:28 UTC (rev 285210)
+++ trunk/Source/WebCore/style/StyleInvalidator.cpp 2021-11-03 16:59:48 UTC (rev 285211)
@@ -128,20 +128,28 @@
return information;
}
+static void invalidateAssignedElements(HTMLSlotElement& slot)
+{
+ auto* assignedNodes = slot.assignedNodes();
+ if (!assignedNodes)
+ return;
+ for (auto& node : *assignedNodes) {
+ if (!is<Element>(node.get()))
+ continue;
+ if (is<HTMLSlotElement>(*node) && node->containingShadowRoot()) {
+ invalidateAssignedElements(downcast<HTMLSlotElement>(*node));
+ continue;
+ }
+ downcast<Element>(*node).invalidateStyleInternal();
+ }
+}
+
Invalidator::CheckDescendants Invalidator::invalidateIfNeeded(Element& element, const SelectorFilter* filter)
{
invalidateInShadowTreeIfNeeded(element);
- bool shouldCheckForSlots = m_ruleInformation.hasSlottedPseudoElementRules && !m_didInvalidateHostChildren;
- if (shouldCheckForSlots && is<HTMLSlotElement>(element)) {
- auto* containingShadowRoot = element.containingShadowRoot();
- if (containingShadowRoot && containingShadowRoot->host()) {
- for (auto& possiblySlotted : childrenOfType<Element>(*containingShadowRoot->host()))
- possiblySlotted.invalidateStyleInternal();
- }
- // No need to do this again.
- m_didInvalidateHostChildren = true;
- }
+ if (m_ruleInformation.hasSlottedPseudoElementRules && is<HTMLSlotElement>(element))
+ invalidateAssignedElements(downcast<HTMLSlotElement>(element));
switch (element.styleValidity()) {
case Style::Validity::Valid: {
@@ -161,8 +169,6 @@
return CheckDescendants::Yes;
case Style::Validity::SubtreeInvalid:
case Style::Validity::SubtreeAndRenderersInvalid:
- if (shouldCheckForSlots)
- return CheckDescendants::Yes;
return CheckDescendants::No;
}
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/style/StyleInvalidator.h (285210 => 285211)
--- trunk/Source/WebCore/style/StyleInvalidator.h 2021-11-03 16:52:28 UTC (rev 285210)
+++ trunk/Source/WebCore/style/StyleInvalidator.h 2021-11-03 16:59:48 UTC (rev 285211)
@@ -90,7 +90,6 @@
RuleInformation m_ruleInformation;
bool m_dirtiesAllStyle { false };
- bool m_didInvalidateHostChildren { false };
};
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes