mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-08 00:07:30 +09:00
Issue #1593 - Follow-up: Fix :host selector matching
Previously, we would match `:host` if: (a) we don't have any arguments and our parent is the shadow root, or; (b) if any of the arguments match, then reject if we don't have a containing shadow Revised, we would match `:host` if: (Preconditions) The element must have a shadow root, the selector must not have any feature selectors, and it is not blocked from matching `:host` (e.g. .matches outside of the shadow root context) (a) The selector does not have any arguments, or; (b) It matches any of its arguments in the functional part of the pseudo-class With this, we now pass these tests that were previously failing: http://wpt.live/css/css-scoping/css-scoping-shadow-host-rule.html http://wpt.live/css/css-scoping/host-descendant-002.html http://wpt.live/css/css-scoping/host-multiple-001.html Improved (1 less red box): http://wpt.live/css/css-scoping/css-scoping-shadow-host-namespace.html
This commit is contained in:
parent
ebe27baa23
commit
edc45f6849
1 changed files with 25 additions and 28 deletions
|
|
@ -1378,7 +1378,10 @@ enum class SelectorMatchesFlags : uint8_t {
|
||||||
|
|
||||||
// The selector is part of an argument to a functional pseudo-class or
|
// The selector is part of an argument to a functional pseudo-class or
|
||||||
// pseudo-element.
|
// pseudo-element.
|
||||||
IS_PSEUDO_CLASS_ARGUMENT = 1 << 2
|
IS_PSEUDO_CLASS_ARGUMENT = 1 << 2,
|
||||||
|
|
||||||
|
// The selector should be blocked from matching the :host pseudo-class.
|
||||||
|
IS_HOST_INACCESSIBLE = 1 << 3
|
||||||
};
|
};
|
||||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(SelectorMatchesFlags)
|
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(SelectorMatchesFlags)
|
||||||
|
|
||||||
|
|
@ -1395,7 +1398,8 @@ static inline bool ActiveHoverQuirkMatches(nsCSSSelector* aSelector,
|
||||||
// flags are unknown).
|
// flags are unknown).
|
||||||
aSelectorFlags & (SelectorMatchesFlags::UNKNOWN |
|
aSelectorFlags & (SelectorMatchesFlags::UNKNOWN |
|
||||||
SelectorMatchesFlags::HAS_PSEUDO_ELEMENT |
|
SelectorMatchesFlags::HAS_PSEUDO_ELEMENT |
|
||||||
SelectorMatchesFlags::IS_PSEUDO_CLASS_ARGUMENT)) {
|
SelectorMatchesFlags::IS_PSEUDO_CLASS_ARGUMENT |
|
||||||
|
SelectorMatchesFlags::IS_HOST_INACCESSIBLE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1954,17 +1958,17 @@ static bool SelectorMatches(Element* aElement,
|
||||||
// we must be matching only against host pseudo selectors, and the
|
// we must be matching only against host pseudo selectors, and the
|
||||||
// selector's context must be the shadow root (the selector must be
|
// selector's context must be the shadow root (the selector must be
|
||||||
// featureless, the left-most selector, and be in a shadow root
|
// featureless, the left-most selector, and be in a shadow root
|
||||||
// style). The :host selector may also be be functional, with a
|
// style).
|
||||||
// compound selector. If this is the case, then also ensure that the
|
if (!aElement->GetShadowRoot() ||
|
||||||
// host element matches against the compound
|
aSelector->HasFeatureSelectors() ||
|
||||||
// selector.
|
aSelectorFlags & SelectorMatchesFlags::IS_HOST_INACCESSIBLE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// We match automatically if GetParent() and GetShadowRoot() have
|
// The :host selector may also be be functional, with a compound
|
||||||
// the same result iff our selector list is empty. Without special
|
// selector. If this is the case, then also ensure that the host
|
||||||
// casing this ahead of all other selector matching, it fails.
|
// element matches against the compound selector.
|
||||||
// Have not determined the cause.
|
if (!pseudoClass->u.mSelectorList) {
|
||||||
if (!pseudoClass->u.mSelectorList &&
|
|
||||||
aElement->GetParent() == aElement->GetShadowRoot()) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1973,25 +1977,15 @@ static bool SelectorMatches(Element* aElement,
|
||||||
// selector check under SelectorMatches.
|
// selector check under SelectorMatches.
|
||||||
NodeMatchContext nodeContext(EventStates(),
|
NodeMatchContext nodeContext(EventStates(),
|
||||||
aNodeMatchContext.mIsRelevantLink);
|
aNodeMatchContext.mIsRelevantLink);
|
||||||
if (SelectorListMatches(aElement,
|
if (!SelectorListMatches(aElement,
|
||||||
pseudoClass,
|
pseudoClass,
|
||||||
nodeContext,
|
nodeContext,
|
||||||
aTreeMatchContext)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case CSSPseudoClassType::hostContext:
|
case CSSPseudoClassType::hostContext:
|
||||||
{
|
{
|
||||||
// In order to match host-context, the element must be a
|
// In order to match host-context, the element must be a
|
||||||
|
|
@ -4162,11 +4156,14 @@ nsCSSRuleProcessor::RestrictedSelectorListMatches(Element* aElement,
|
||||||
"SelectorMatchesTree call");
|
"SelectorMatchesTree call");
|
||||||
|
|
||||||
NodeMatchContext nodeContext(EventStates(), false);
|
NodeMatchContext nodeContext(EventStates(), false);
|
||||||
|
SelectorMatchesFlags flags = aElement->IsInShadowTree() ?
|
||||||
|
SelectorMatchesFlags::NONE :
|
||||||
|
SelectorMatchesFlags::IS_HOST_INACCESSIBLE;
|
||||||
return SelectorListMatches(aElement,
|
return SelectorListMatches(aElement,
|
||||||
aSelectorList,
|
aSelectorList,
|
||||||
nodeContext,
|
nodeContext,
|
||||||
aTreeMatchContext,
|
aTreeMatchContext,
|
||||||
SelectorMatchesFlags::NONE);
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue