summaryrefslogtreecommitdiff
path: root/layout
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-03-18 23:08:00 +0800
committerMoonchild <moonchild@palemoon.org>2023-03-23 12:18:01 +0100
commitc5cb2983e64aa7c2da2b3d504e1298d3a6b42522 (patch)
treee2c701d0ee52ab1358adaa443e878a8f94b00cb5 /layout
parent9c5999c8bc7fb3598b7b572a57da4afbb0048a18 (diff)
downloaduxp-c5cb2983e64aa7c2da2b3d504e1298d3a6b42522.tar.gz
Issue #1592 - Part 5: Use flattened element tree when looking for a parent while matching ::slotted()
Diffstat (limited to 'layout')
-rw-r--r--layout/style/nsCSSRuleProcessor.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp
index a4a2e537c4..a3b6e5fc0c 100644
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -2545,6 +2545,11 @@ SelectorMatchesTree(Element* aPrevElement,
// The relevant link must be an ancestor of the node being matched.
aFlags = SelectorMatchesTreeFlags(aFlags & ~eLookForRelevantLink);
nsIContent* parent = prevElement->GetParent();
+ // Operate on the flattened element tree when matching the
+ // ::slotted() pseudo-element.
+ if (aTreeMatchContext.mRestrictToSlottedPseudo) {
+ parent = prevElement->GetFlattenedTreeParent();
+ }
if (parent) {
if (aTreeMatchContext.mForStyling)
parent->SetFlags(NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
@@ -2555,7 +2560,12 @@ SelectorMatchesTree(Element* aPrevElement,
// for descendant combinators and child combinators, the element
// to test against is the parent
else {
- nsIContent *content = prevElement->GetParent();
+ nsIContent* content = prevElement->GetParent();
+ // Operate on the flattened element tree when matching the
+ // ::slotted() pseudo-element.
+ if (aTreeMatchContext.mRestrictToSlottedPseudo) {
+ content = prevElement->GetFlattenedTreeParent();
+ }
// In the shadow tree, the shadow host behaves as if it
// is a featureless parent of top-level elements of the shadow
@@ -2563,11 +2573,12 @@ SelectorMatchesTree(Element* aPrevElement,
// left most selector because ancestors of the host are not in
// the selector match list.
ShadowRoot* shadowRoot = content ?
- ShadowRoot::FromNode(content) : nullptr;
+ ShadowRoot::FromNode(content) :
+ nullptr;
if (shadowRoot && !selector->mNext && !crossedShadowRootBoundary) {
- content = shadowRoot->GetHost();
- crossedShadowRootBoundary = true;
- contentIsFeatureless = true;
+ content = shadowRoot->GetHost();
+ crossedShadowRootBoundary = true;
+ contentIsFeatureless = true;
}
// GetParent could return a document fragment; we only want