Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: aa73fff0f62234af069fdab28c58d154f275fe0a
      
https://github.com/WebKit/WebKit/commit/aa73fff0f62234af069fdab28c58d154f275fe0a
  Author: Cole Carley <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/page/QuirkMatch.cpp
    M Source/WebCore/page/QuirkMatch.h
    M Source/WebCore/page/Quirks.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/QuirkMatch.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/Quirks.cpp

  Log Message:
  -----------
  [Quirks] Clean up the QuirksMatch API
https://bugs.webkit.org/show_bug.cgi?id=322538
rdar://185834375

Reviewed by Brent Fulgham.

This patch addresses some of the rough edges around the QuirkMatch API.

I renamed some things:
QuirkCondition -> QuirkEnvironment
host() -> topHost()
registrableDomain() -> topRegistrableDomain()
domainWithPublicSuffix() -> topDomainWithPublicSuffix()
documentDomain() -> documentRegistrableDomain()

I introduced QuirkPatternList to combine the single and multiple pattern cases.
Now, you can pass one or multiple patterns to domain(), documentDomainIs(),
and hostIs(), which allowed me to remove domains(), documentDomainIsOneOf(), and
hostIsOneOf().

I removed the quirkBehaviors() function in favor of a new QuirkBehaviors class
that wraps a QuirkBitSet. It has a constructor that takes an initializer list,
which cleans up the quirk table significantly.

I also introduced a new QuirkMatch::when() to go along with the
QuirkMatch::exceptWhen(). These now take any structure defined in the
QuirkRefinement namespace. The refinements are stored in a RefinementSet which
is either in QuirkMatch::m_refinements or QuirkMatch::m_exception.

This cleans up the QuirkMatch interface to look like this:
     QuirkMatch::anyTopLevelDomain("apple"_s).when(pathStartsWith("/store"_s))
     
QuirkMatch::domain("wix.com"_s).exceptWhen(pathStartsWith("/website/templates/"_s))

Tests: Tools/TestWebKitAPI/Tests/WebCore/QuirkMatch.cpp
       Tools/TestWebKitAPI/Tests/WebCore/Quirks.cpp

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/page/QuirkMatch.cpp: Added.
(WebCore::QuirkMatchContext::topRegistrableDomain const):
(WebCore::QuirkMatchContext::topDomainWithoutPublicSuffix const):
(WebCore::QuirkMatchContext::documentRegistrableDomain const):
(WebCore::QuirkMatch::RefinementSet::matchesPathPattern const):
(WebCore::QuirkMatch::RefinementSet::matches const):
(WebCore::QuirkMatch::matchesSite const):
(WebCore::QuirkMatch::matches const):
(WebCore::Quirk::apply const):
* Source/WebCore/page/QuirkMatch.h:
(WebCore::QuirkMatchContext::QuirkMatchContext):
(WebCore::QuirkPatternList::QuirkPatternList):
(WebCore::QuirkPatternList::isEmpty const):
(WebCore::QuirkPatternList::contains const):
(WebCore::QuirkPatternList::containsMatching const):
(WebCore::QuirkRefinement::pathContains):
(WebCore::QuirkRefinement::pathStartsWith):
(WebCore::QuirkRefinement::pathOrFragmentContains):
(WebCore::QuirkRefinement::documentDomainIs):
(WebCore::QuirkRefinement::hostIs):
(WebCore::QuirkRefinement::embedded):
(WebCore::QuirkRefinement::smallScreen):
(WebCore::QuirkRefinement::tubularApp):
(WebCore::QuirkRefinement::lensApp):
(WebCore::QuirkMatch::domain):
(WebCore::QuirkMatch::host):
(WebCore::QuirkMatch::hostOrSubdomainOf):
(WebCore::QuirkMatch::anyTopLevelDomain):
(WebCore::QuirkMatch::anySite):
(WebCore::QuirkMatch::when):
(WebCore::QuirkMatch::exceptWhen):
(WebCore::QuirkMatch::setPathPattern):
(WebCore::QuirkMatch::applyRefinement):
(WebCore::QuirkMatch::QuirkMatch):
(WebCore::QuirkBehaviors::QuirkBehaviors):
(WebCore::QuirkMatch::domains): Deleted.
(WebCore::QuirkMatch::hostEndingWith): Deleted.
(WebCore::QuirkMatch::pathContains): Deleted.
(WebCore::QuirkMatch::pathStartsWith): Deleted.
(WebCore::QuirkMatch::pathOrFragmentContains): Deleted.
(WebCore::QuirkMatch::onlyIf): Deleted.
(WebCore::QuirkMatch::documentDomainIs): Deleted.
(WebCore::QuirkMatch::documentDomainIsOneOf): Deleted.
(WebCore::QuirkMatch::hostIsOneOf): Deleted.
(WebCore::QuirkMatch::onlyIfEmbedded): Deleted.
(WebCore::QuirkMatch::matches const): Deleted.
(WebCore::QuirkMatch::PatternList::PatternList): Deleted.
(WebCore::QuirkMatch::PatternList::isEmpty const): Deleted.
(WebCore::QuirkMatch::Refinements::isEmpty const): Deleted.
(WebCore::QuirkMatch::setPathConstraint): Deleted.
(WebCore::QuirkMatch::anyPattern const): Deleted.
(WebCore::QuirkMatch::matchesSite const): Deleted.
(WebCore::QuirkMatch::matchesRefinements const): Deleted.
(WebCore::QuirkMatch::anyOf): Deleted.
(WebCore::QuirkMatch::matchesPathConstraint const): Deleted.
(WebCore::quirkBehaviors): Deleted.
(WebCore::Quirk::apply const): Deleted.
* Source/WebCore/page/Quirks.cpp:
* Tools/TestWebKitAPI/Tests/WebCore/QuirkMatch.cpp:
(TestWebKitAPI::matchesURL):
(TestWebKitAPI::TEST(QuirkMatchTest, DomainsMatchesAnyPatternInTheList)):
(TestWebKitAPI::TEST(QuirkMatchTest, HostOrSubdomainOfCoversShardedHosts)):
(TestWebKitAPI::TEST(QuirkMatchTest, PathContainsMatchesAnywhereInThePath)):
(TestWebKitAPI::TEST(QuirkMatchTest, PathStartsWithIsAnchored)):
(TestWebKitAPI::TEST(QuirkMatchTest, PathOrFragmentContainsSearchesBoth)):
(TestWebKitAPI::TEST(QuirkMatchTest, EnvironmentIsANDedWithTheSiteMatch)):
(TestWebKitAPI::TEST(QuirkMatchTest, DocumentDomainIsMatchesEmbeddedDocuments)):
(TestWebKitAPI::TEST(QuirkMatchTest, DocumentDomainIsAcceptsASinglePattern)):
(TestWebKitAPI::TEST(QuirkMatchTest, 
AnySiteWithOnlyIfEmbeddedMatchesEmbedsAnywhereButNeverTheTopDocument)):
(TestWebKitAPI::TEST(QuirkMatchTest, ExceptWhenCarvesOutPagesOfAMatchedSite)):
(TestWebKitAPI::TEST(QuirkMatchTest, ExceptWhenCarvesOutHostsOfAMatchedSite)):
(TestWebKitAPI::TEST(QuirkMatchTest, ExceptWhenCarvesOutASingleHost)):
(TestWebKitAPI::TEST(QuirkMatchTest, HostIsNarrowsAMatchToOneHost)):
(TestWebKitAPI::TEST(QuirkMatchTest, 
ExceptWhenTakesEveryRefinementIncludingEmbeddedDocuments)):
(TestWebKitAPI::TEST(QuirkMatchTest, 
ExceptWhenAndTheMatchKeepSeparateRefinements)):
(TestWebKitAPI::TEST(QuirkMatchTest, 
ExceptWhenRequiresEveryRefinementToExclude)):
(TestWebKitAPI::TEST(QuirkMatchTest, RefinementsOfDifferentKindsAreAllANDed)):
(TestWebKitAPI::TEST(QuirkMatchTest, EnvironmentStacksWithAPathRefinement)):
(TestWebKitAPI::TEST(QuirkMatchTest, ContextDerivesValuesFromTheRightURL)):
(TestWebKitAPI::TEST(QuirkMatchTest, ContextCachesDerivedValues)):
(TestWebKitAPI::TEST(QuirkMatchTest, URLsWithoutAHostMatchNothing)):
(TestWebKitAPI::TEST(QuirkMatchTest, HostEndingWithIgnoresLabelBoundaries)): 
Deleted.
(TestWebKitAPI::TEST(QuirkMatchTest, OnlyTheLastPathConstraintIsKept)): Deleted.
(TestWebKitAPI::TEST(QuirkMatchTest, ConditionIsANDedWithTheSiteMatch)): 
Deleted.
(TestWebKitAPI::TEST(QuirkMatchTest, 
DocumentDomainIsOneOfMatchesEmbeddedDocuments)): Deleted.
(TestWebKitAPI::TEST(QuirkMatchTest, 
DocumentDomainIsMatchesASingleEmbeddedDomain)): Deleted.
(TestWebKitAPI::TEST(QuirkMatchTest, ExceptWhenWithNothingChainedIsANoOp)): 
Deleted.
(TestWebKitAPI::TEST(QuirkMatchTest, ConditionStacksWithAPathRefinement)): 
Deleted.
* Tools/TestWebKitAPI/Tests/WebCore/Quirks.cpp:
(TestWebKitAPI::resolveQuirksForTopURL):

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



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

Reply via email to