Skip to content

Conversation

@mdubet
Copy link
Contributor

@mdubet mdubet commented Jan 30, 2025

ce251e4

[CSS] Early return from matching when doing invalidation
https://bugs.webkit.org/show_bug.cgi?id=286721
rdar://138419832

Reviewed by Antti Koivisto.

For invalidation, we generally don't want to collect rules
but just to know if any rule matches. We can optimize for
this use case by early returning on first match.

 * Source/WebCore/style/ElementRuleCollector.cpp:
 (WebCore::Style::ElementRuleCollector::isFirstMatchModeAndHasMatchedAnyRules const):
 (WebCore::Style::ElementRuleCollector::collectMatchingRules):
 (WebCore::Style::ElementRuleCollector::transferMatchedRules):
 (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList):
 (WebCore::Style::ElementRuleCollector::matchAllRules):
 (WebCore::Style::ElementRuleCollector::hasAnyMatchingRules): Deleted.

 Renamed to matchesAnyRules().

 * Source/WebCore/style/ElementRuleCollector.h:
 * Source/WebCore/style/StyleSharingResolver.cpp:
 (WebCore::Style::SharingResolver::styleSharingCandidateMatchesRuleSet const):

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

fc45b11

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@mdubet mdubet self-assigned this Jan 30, 2025
@mdubet mdubet added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Jan 30, 2025
Copy link
Member

@nt1m nt1m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether this is the good approach or not, but here's a style nit

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jan 30, 2025
@mdubet mdubet removed the merging-blocked Applied to prevent a change from being merged label Jan 30, 2025
@mdubet mdubet force-pushed the early-return-selector-matching branch from afab8f2 to 00508c0 Compare January 30, 2025 16:57
Comment on lines 622 to 623
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still do some unnecessary work like hash lookups in ElementRuleCollector::collectMatchingRules after the first match. I think this ok for now though, it can be improved later.

@mdubet mdubet changed the title [CSS] Early return if possible when doing style matching [CSS] Early return from matching when doing invalidation Jan 30, 2025
@mdubet mdubet force-pushed the early-return-selector-matching branch from 00508c0 to 5cc3611 Compare January 30, 2025 20:30
@mdubet mdubet added the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Jan 30, 2025
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jan 31, 2025
@webkit-ews-buildbot
Copy link
Collaborator

Failed mac-AS-debug-wk2 checks. Please resolve failures and re-apply safe-merge-queue label.

Rejecting #39737 from merge queue.

@webkit-ews-buildbot webkit-ews-buildbot removed the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Jan 31, 2025
@webkit-ews-buildbot
Copy link
Collaborator

Safe-Merge-Queue: Build #47392.

@mdubet mdubet added safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks and removed merging-blocked Applied to prevent a change from being merged labels Jan 31, 2025
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jan 31, 2025
@webkit-ews-buildbot
Copy link
Collaborator

Failed mac-AS-debug-wk2 checks. Please resolve failures and re-apply safe-merge-queue label.

Rejecting #39737 from merge queue.

@webkit-ews-buildbot webkit-ews-buildbot removed the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Jan 31, 2025
@webkit-ews-buildbot
Copy link
Collaborator

Safe-Merge-Queue: Build #47431.

@mdubet mdubet removed the merging-blocked Applied to prevent a change from being merged label Jan 31, 2025
@mdubet mdubet force-pushed the early-return-selector-matching branch from 5cc3611 to fc45b11 Compare January 31, 2025 16:41
@mdubet mdubet added the merge-queue Applied to send a pull request to merge-queue label Jan 31, 2025
@mdubet
Copy link
Contributor Author

mdubet commented Jan 31, 2025

mac-AS-debug failures are unrelated

https://bugs.webkit.org/show_bug.cgi?id=286721
rdar://138419832

Reviewed by Antti Koivisto.

For invalidation, we generally don't want to collect rules
but just to know if any rule matches. We can optimize for
this use case by early returning on first match.

 * Source/WebCore/style/ElementRuleCollector.cpp:
 (WebCore::Style::ElementRuleCollector::isFirstMatchModeAndHasMatchedAnyRules const):
 (WebCore::Style::ElementRuleCollector::collectMatchingRules):
 (WebCore::Style::ElementRuleCollector::transferMatchedRules):
 (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList):
 (WebCore::Style::ElementRuleCollector::matchAllRules):
 (WebCore::Style::ElementRuleCollector::hasAnyMatchingRules): Deleted.

 Renamed to matchesAnyRules().

 * Source/WebCore/style/ElementRuleCollector.h:
 * Source/WebCore/style/StyleSharingResolver.cpp:
 (WebCore::Style::SharingResolver::styleSharingCandidateMatchesRuleSet const):

Canonical link: https://commits.webkit.org/289611@main
@webkit-commit-queue webkit-commit-queue force-pushed the early-return-selector-matching branch from fc45b11 to ce251e4 Compare January 31, 2025 18:00
@webkit-commit-queue
Copy link
Collaborator

Committed 289611@main (ce251e4): https://commits.webkit.org/289611@main

Reviewed commits have been landed. Closing PR #39737 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit ce251e4 into WebKit:main Jan 31, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Bugs Unclassified bugs are placed in this component until the correct component can be determined.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants