Issue #2078 - Part 3: Rename nsCSSRuleProcessor::SelectorListMatches to RestrictedSelectorListMatches

This is in preparation for merging the logic of RestrictedSelectorListMatches and AnySelectorInArgListMatches.
This commit is contained in:
FranklinDM 2023-02-18 19:29:42 +08:00 • committed by roytam1
commit 14e8922dca
5 changed files with 24 additions and 22 deletions

View file

@ -3438,7 +3438,7 @@ Element::Closest(const nsAString& aSelector, ErrorResult& aResult)
matchingContext.AddScopeElement(this); matchingContext.AddScopeElement(this);
for (nsINode* node = this; node; node = node->GetParentNode()) { for (nsINode* node = this; node; node = node->GetParentNode()) {
if (node->IsElement() && if (node->IsElement() &&
nsCSSRuleProcessor::SelectorListMatches(node->AsElement(), nsCSSRuleProcessor::RestrictedSelectorListMatches(node->AsElement(),
matchingContext, matchingContext,
selectorList)) { selectorList)) {
return node->AsElement(); return node->AsElement();
@ -3464,7 +3464,8 @@ Element::Matches(const nsAString& aSelector, ErrorResult& aError)
TreeMatchContext::eNeverMatchVisited); TreeMatchContext::eNeverMatchVisited);
matchingContext.SetHasSpecifiedScope(); matchingContext.SetHasSpecifiedScope();
matchingContext.AddScopeElement(this); matchingContext.AddScopeElement(this);
return nsCSSRuleProcessor::SelectorListMatches(this, matchingContext, return nsCSSRuleProcessor::RestrictedSelectorListMatches(this,
matchingContext,
selectorList); selectorList);
} }

View file

@ -2879,7 +2879,7 @@ FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot,
// We have an element with the right id and it's a strict descendant // We have an element with the right id and it's a strict descendant
// of aRoot. Make sure it really matches the selector. // of aRoot. Make sure it really matches the selector.
if (!aMatchInfo || if (!aMatchInfo ||
nsCSSRuleProcessor::SelectorListMatches(element, nsCSSRuleProcessor::RestrictedSelectorListMatches(element,
aMatchInfo->mMatchContext, aMatchInfo->mMatchContext,
aMatchInfo->mSelectorList)) { aMatchInfo->mSelectorList)) {
aList.AppendElement(element); aList.AppendElement(element);
@ -2932,7 +2932,7 @@ FindMatchingElements(nsINode* aRoot, nsCSSSelectorList* aSelectorList, T &aList,
cur; cur;
cur = cur->GetNextNode(aRoot)) { cur = cur->GetNextNode(aRoot)) {
if (cur->IsElement() && if (cur->IsElement() &&
nsCSSRuleProcessor::SelectorListMatches(cur->AsElement(), nsCSSRuleProcessor::RestrictedSelectorListMatches(cur->AsElement(),
matchingContext, matchingContext,
aSelectorList)) { aSelectorList)) {
if (onlyFirstMatch) { if (onlyFirstMatch) {

View file

@ -465,7 +465,7 @@ inDOMUtils::SelectorMatchesElement(nsIDOMElement* aElement,
} }
// We have a matching pseudo element, now remove it so we can compare // We have a matching pseudo element, now remove it so we can compare
// directly against |element| when proceeding into SelectorListMatches. // directly against |element| when proceeding into RestrictedSelectorListMatches.
// It's OK to do this - we just cloned sel and nothing else is using it. // It's OK to do this - we just cloned sel and nothing else is using it.
sel->RemoveRightmostSelector(); sel->RemoveRightmostSelector();
} }
@ -476,7 +476,8 @@ inDOMUtils::SelectorMatchesElement(nsIDOMElement* aElement,
nsRuleWalker::eRelevantLinkUnvisited, nsRuleWalker::eRelevantLinkUnvisited,
element->OwnerDoc(), element->OwnerDoc(),
TreeMatchContext::eNeverMatchVisited); TreeMatchContext::eNeverMatchVisited);
*aMatches = nsCSSRuleProcessor::SelectorListMatches(element, matchingContext, *aMatches = nsCSSRuleProcessor::RestrictedSelectorListMatches(element,
matchingContext,
sel); sel);
return NS_OK; return NS_OK;
} }

View file

@ -1337,8 +1337,8 @@ struct NodeMatchContext {
// node being matched that is itself or an ancestor.) // node being matched that is itself or an ancestor.)
// //
// Always false when TreeMatchContext::mForStyling is false. (We // Always false when TreeMatchContext::mForStyling is false. (We
// could figure it out for SelectorListMatches, but we're starting // could figure it out for RestrictedSelectorListMatches, but we're
// from the middle of the selector list when doing // starting from the middle of the selector list when doing
// Has{Attribute,State}DependentStyle, so we can't tell. So when // Has{Attribute,State}DependentStyle, so we can't tell. So when
// mForStyling is false, we have to assume we don't know.) // mForStyling is false, we have to assume we don't know.)
const bool mIsRelevantLink; const bool mIsRelevantLink;
@ -4094,7 +4094,7 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext)
} }
/* static */ bool /* static */ bool
nsCSSRuleProcessor::SelectorListMatches(Element* aElement, nsCSSRuleProcessor::RestrictedSelectorListMatches(Element* aElement,
TreeMatchContext& aTreeMatchContext, TreeMatchContext& aTreeMatchContext,
nsCSSSelectorList* aSelectorList) nsCSSSelectorList* aSelectorList)
{ {

View file

@ -92,7 +92,7 @@ public:
* include any pseudo-element selectors. aSelectorList is allowed * include any pseudo-element selectors. aSelectorList is allowed
* to be null; in this case false will be returned. * to be null; in this case false will be returned.
*/ */
static bool SelectorListMatches(mozilla::dom::Element* aElement, static bool RestrictedSelectorListMatches(mozilla::dom::Element* aElement,
TreeMatchContext& aTreeMatchContext, TreeMatchContext& aTreeMatchContext,
nsCSSSelectorList* aSelectorList); nsCSSSelectorList* aSelectorList);