Issue #2828 - Part 3: Refactor selector matching and rule cascade data into separate files/classes

This commit is contained in:
Francis Dominic Fajardo 2025-07-17 22:13:53 +08:00 • committed by roytam1
commit 03f29e75ec
20 changed files with 4432 additions and 4171 deletions

View file

@ -107,7 +107,7 @@
#include "nsIScrollableFrame.h"
#include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */
#include "mozilla/css/Declaration.h"
#include "nsCSSRuleProcessor.h"
#include "nsCSSRuleUtils.h"
#include "nsRuleProcessorData.h"
#include "nsTextNode.h"
@ -3434,9 +3434,9 @@ Element::Closest(const nsAString& aSelector, ErrorResult& aResult)
matchingContext.AddScopeElement(this);
for (nsINode* node = this; node; node = node->GetParentNode()) {
if (node->IsElement() &&
nsCSSRuleProcessor::RestrictedSelectorListMatches(node->AsElement(),
matchingContext,
selectorList)) {
nsCSSRuleUtils::RestrictedSelectorListMatches(node->AsElement(),
matchingContext,
selectorList)) {
return node->AsElement();
}
}
@ -3460,9 +3460,9 @@ Element::Matches(const nsAString& aSelector, ErrorResult& aError)
TreeMatchContext::eNeverMatchVisited);
matchingContext.SetHasSpecifiedScope();
matchingContext.AddScopeElement(this);
return nsCSSRuleProcessor::RestrictedSelectorListMatches(this,
matchingContext,
selectorList);
return nsCSSRuleUtils::RestrictedSelectorListMatches(this,
matchingContext,
selectorList);
}
static const nsAttrValue::EnumTable kCORSAttributeTable[] = {

View file

@ -91,7 +91,7 @@
#include "mozilla/Preferences.h"
#include "prprf.h"
#include "xpcpublic.h"
#include "nsCSSRuleProcessor.h"
#include "nsCSSRuleUtils.h"
#include "nsCSSParser.h"
#include "HTMLLegendElement.h"
#include "nsWrapperCacheInlines.h"
@ -2912,9 +2912,9 @@ FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot,
// We have an element with the right id and it's a strict descendant
// of aRoot. Make sure it really matches the selector.
if (!aMatchInfo ||
nsCSSRuleProcessor::RestrictedSelectorListMatches(element,
aMatchInfo->mMatchContext,
aMatchInfo->mSelectorList)) {
nsCSSRuleUtils::RestrictedSelectorListMatches(element,
aMatchInfo->mMatchContext,
aMatchInfo->mSelectorList)) {
aList.AppendElement(element);
if (onlyFirstMatch) {
return;
@ -2965,9 +2965,9 @@ FindMatchingElements(nsINode* aRoot, nsCSSSelectorList* aSelectorList, T &aList,
cur;
cur = cur->GetNextNode(aRoot)) {
if (cur->IsElement() &&
nsCSSRuleProcessor::RestrictedSelectorListMatches(cur->AsElement(),
matchingContext,
aSelectorList)) {
nsCSSRuleUtils::RestrictedSelectorListMatches(cur->AsElement(),
matchingContext,
aSelectorList)) {
if (onlyFirstMatch) {
aList.AppendElement(cur->AsElement());
return;