Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0ef6313a07733f8c2b24b0f2e6b42f0fde114172
      
https://github.com/WebKit/WebKit/commit/0ef6313a07733f8c2b24b0f2e6b42f0fde114172
  Author: Antti Koivisto <[email protected]>
  Date:   2026-04-16 (Thu, 16 Apr 2026)

  Changed paths:
    M Source/WebCore/css/SelectorChecker.cpp
    M Source/WebCore/style/AttributeChangeInvalidation.cpp
    M Source/WebCore/style/ChildChangeInvalidation.cpp
    M Source/WebCore/style/ClassChangeInvalidation.cpp
    M Source/WebCore/style/HasSelectorFilter.cpp
    M Source/WebCore/style/HasSelectorFilter.h
    M Source/WebCore/style/IdChangeInvalidation.cpp
    M Source/WebCore/style/PseudoClassChangeInvalidation.cpp
    M Source/WebCore/style/RuleFeature.cpp
    M Source/WebCore/style/RuleFeature.h
    M Source/WebCore/style/StyleInvalidator.cpp
    M Source/WebCore/style/StyleInvalidator.h
    M Source/WebCore/style/StyleScope.cpp
    M Source/WebCore/style/StyleScopeRuleSets.cpp

  Log Message:
  -----------
  [:has() perf] Replace MatchElement enum with a struct
https://bugs.webkit.org/show_bug.cgi?id=312473
rdar://174922238

Reviewed by Alan Baradlay.

Replace the current single enum value with a two-enum value struct.

struct MatchElement { Relation relation; Markable<HasRelation> hasRelation; }

This way we can describe both the position of :has() and the type of the 
selector within it in a natural manner.
This patch just does the mechanincal change, except for adding a simple 
optimization for the direct sibling
:has(+ .changed) case.

* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchHasPseudoClass const):
* Source/WebCore/style/AttributeChangeInvalidation.cpp:
(WebCore::Style::AttributeChangeInvalidation::invalidateStyle):
* Source/WebCore/style/ChildChangeInvalidation.cpp:
(WebCore::Style::ChildChangeInvalidation::invalidateForChangedElement):
(WebCore::Style::needsDescendantTraversal):
* Source/WebCore/style/ClassChangeInvalidation.cpp:
(WebCore::Style::ClassChangeInvalidation::computeInvalidation):
* Source/WebCore/style/HasSelectorFilter.cpp:
(WebCore::Style::HasSelectorFilter::typeForMatchElement): Deleted.
* Source/WebCore/style/HasSelectorFilter.h:
(WebCore::Style::HasSelectorFilter::type const):
* Source/WebCore/style/IdChangeInvalidation.cpp:
(WebCore::Style::IdChangeInvalidation::invalidateStyle):
* Source/WebCore/style/PseudoClassChangeInvalidation.cpp:
(WebCore::Style::PseudoClassChangeInvalidation::collectRuleSets):
* Source/WebCore/style/RuleFeature.cpp:
(WebCore::Style::isSiblingOrSubject):
(WebCore::Style::computeNextRelation):
(WebCore::Style::toHasRelation):
(WebCore::Style::computeHasArgumentRelation):
(WebCore::Style::computeSubSelectorMatchElement):
(WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector):
(WebCore::Style::RuleFeatureSet::collectFeatures):
(WebCore::Style::RuleFeatureSet::add):
(WebCore::Style::isHasPseudoClassMatchElement): Deleted.
(WebCore::Style::isScopeBreaking): Deleted.
(WebCore::Style::computeNextMatchElement): Deleted.
(WebCore::Style::computeNextHasPseudoClassMatchElement): Deleted.
(WebCore::Style::computeHasPseudoClassMatchElement): Deleted.
* Source/WebCore/style/RuleFeature.h:
(WebCore::Style::MatchElement::hash const):
(WebCore::Style::RuleFeatureSet::usesRelation const):
(WebCore::Style::RuleFeatureSet::setUsesRelation):
(WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector):
(WebCore::Style::RuleFeatureSet::usesMatchElement const): Deleted.
(WebCore::Style::RuleFeatureSet::setUsesMatchElement): Deleted.
(WebCore::Style::RuleFeatureSet::usesHasPseudoClass const): Deleted.
* Source/WebCore/style/StyleInvalidator.cpp:
(WebCore::Style::Invalidator::invalidateStyleWithMatchElement):
(WebCore::Style::Invalidator::invalidateWithMatchElementRuleSets):
(WebCore::Style::Invalidator::invalidateWithScopeBreakingHasPseudoClassRuleSet):
* Source/WebCore/style/StyleInvalidator.h:
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::resolver):
(WebCore::Style::Scope::updateActiveStyleSheets):
* Source/WebCore/style/StyleScopeRuleSets.cpp:
(WebCore::Style::ensureInvalidationRuleSets):
(WebCore::Style::ScopeRuleSets::selectorsForStyleAttribute const):

Canonical link: https://commits.webkit.org/311387@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to