diff options
author | Jeremy Andrews <athenian200@outlook.com> | 2021-11-20 10:12:23 -0600 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-19 21:45:51 +0000 |
commit | 643e298a550d5b3eeed7ad4bbedc1551be76c6b7 (patch) | |
tree | 6fcdeacd5a6985db9a5b175f83f522c4f8ed8a8f | |
parent | f82c95d1eb4cdb2c814700944c64b8836021b600 (diff) | |
download | uxp-643e298a550d5b3eeed7ad4bbedc1551be76c6b7.tar.gz |
Issue #1593 - Part 4: Make :host pass DOM parsing test and basic specificity tests.
-rw-r--r-- | layout/style/nsCSSRuleProcessor.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index a30d1cd098..f49b9d3258 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1906,14 +1906,33 @@ static bool SelectorMatches(Element* aElement, // compound selector. If this is the case, then also ensure that the // host element matches against the compound // selector. - return aElement->GetShadowRoot() && - aTreeMatchContext.mOnlyMatchHostPseudo && - !aSelector->HasFeatureSelectors() && - !aSelector->mNext && - (!pseudoClass->u.mSelectors || - AnySelectorInArgListMatches(aElement, pseudoClass, - aNodeMatchContext, - aTreeMatchContext)); + + // We match automatically if GetParent() and GetShadowRoot() have + // the same result. Without special casing this ahead of all other + // selector matching, it fails. Have not determined the cause. + + if (aElement->GetParent() == aElement->GetShadowRoot()) { + break; + } + + // Match if any selector in the argument list matches. + + NodeMatchContext nodeContext(EventStates(), + nsCSSRuleProcessor::IsLink(aElement)); + if (AnySelectorInArgListMatches(aElement, pseudoClass, + nodeContext, + aTreeMatchContext)) { + break; + } + + // Finally, with the exception of the two above cases, make sure we + // don't match if GetContainingShadow() returns null. For whatever + // reason, we can't test for this case first. + + if (aElement->GetContainingShadow() == nullptr) { + return false; + } + } break; |