summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-03-19 19:10:46 +0800
committerMoonchild <moonchild@palemoon.org>2023-03-23 12:18:02 +0100
commit4665c79582682817533d85b164bef3f4ad97a6c8 (patch)
tree0b975b455d0e3a69892914b40766bdf6eec64fff
parent7c82808510e2cc164ef1e030bbff847416424d28 (diff)
downloaduxp-4665c79582682817533d85b164bef3f4ad97a6c8.tar.gz
Issue #1592 - Part 7: Slottables cannot be matched from the outer tree.
-rw-r--r--layout/style/nsCSSRuleProcessor.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp
index a3b6e5fc0c..a13b35214d 100644
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1359,8 +1359,9 @@ enum class SelectorMatchesFlags : uint8_t {
// pseudo-element.
IS_PSEUDO_CLASS_ARGUMENT = 1 << 2,
- // The selector should be blocked from matching the :host pseudo-class.
- IS_HOST_INACCESSIBLE = 1 << 3
+ // The selector should be blocked from matching because it is called
+ // from outside the shadow tree.
+ IS_OUTSIDE_SHADOW_TREE = 1 << 3
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(SelectorMatchesFlags)
@@ -1379,7 +1380,7 @@ static inline bool ActiveHoverQuirkMatches(nsCSSSelector* aSelector,
aSelectorFlags & (SelectorMatchesFlags::UNKNOWN |
SelectorMatchesFlags::HAS_PSEUDO_ELEMENT |
SelectorMatchesFlags::IS_PSEUDO_CLASS_ARGUMENT |
- SelectorMatchesFlags::IS_HOST_INACCESSIBLE)) {
+ SelectorMatchesFlags::IS_OUTSIDE_SHADOW_TREE)) {
return false;
}
@@ -1777,6 +1778,8 @@ static bool SelectorMatches(Element* aElement,
}
}
+ const bool isOutsideShadowTree =
+ !!(aSelectorFlags & SelectorMatchesFlags::IS_OUTSIDE_SHADOW_TREE);
const bool isNegated = (aDependence != nullptr);
// The selectors for which we set node bits are, unfortunately, early
// in this function (because they're pseudo-classes, which are
@@ -1945,6 +1948,11 @@ static bool SelectorMatches(Element* aElement,
case CSSPseudoClassType::slotted:
{
+ // Slottables cannot be matched from the outer tree.
+ if (isOutsideShadowTree) {
+ return false;
+ }
+
// Slot elements cannot be matched.
if (aElement->IsHTMLElement(nsGkAtoms::slot)) {
return false;
@@ -1976,7 +1984,7 @@ static bool SelectorMatches(Element* aElement,
// style).
if (!shadow ||
aSelector->HasFeatureSelectors() ||
- aSelectorFlags & SelectorMatchesFlags::IS_HOST_INACCESSIBLE) {
+ isOutsideShadowTree) {
return false;
}
@@ -4205,7 +4213,7 @@ nsCSSRuleProcessor::RestrictedSelectorListMatches(Element* aElement,
NodeMatchContext nodeContext(EventStates(), false);
SelectorMatchesFlags flags = aElement->IsInShadowTree() ?
SelectorMatchesFlags::NONE :
- SelectorMatchesFlags::IS_HOST_INACCESSIBLE;
+ SelectorMatchesFlags::IS_OUTSIDE_SHADOW_TREE;
return SelectorListMatches(aElement,
aSelectorList,
nodeContext,