Implement "VisitFlow" - #1263
Merged
Merged
Conversation
keithamus
enabled auto-merge (squash)
July 4, 2026 09:05
keithamus
force-pushed
the
implement-visitflow
branch
from
July 4, 2026 09:06
c67e61c to
7cec54f
Compare
Currently the AST traversal visitor pattern walks the entire tree, even when it doesn't strictly need to. This is bad for performance, which is especially wasteful as we precompute alot of metadata while building the AST. This also means some code (e.g. reduce_colors) needs to manage its own control flow to avoid "over reducing" some nodes. Really we should be able to skip descending into subtrees. This change refactors the Visit code to return a ControlFlow type, with subtype enums that control how visitors should descend into the tree. Each visit method can either break (stop the whole visit flow), skip children (so only the exit_ fires) or descend (the default). This also refactors the various consumers to take advantage of this new feature, including the selector engine in csskit_ast.
keithamus
force-pushed
the
implement-visitflow
branch
from
July 4, 2026 09:09
7cec54f to
ec58c93
Compare
✅ CI passed
|
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 4, 2026
## [0.0.27] - 2026-07-04 ### Other Changes - Fuzz: minimize corpus, and do so on nightly fuzz build (#1257) ([#1257](#1257)) - CI: Ensure benches build (#1259) ([#1259](#1259)) ### Css_ast - css_ast/css_parse: Improve peeking robustness. (#1238) ([#1238](#1238)) - Regenerate css_ast/src/values from csswg drafts (#1242) ([#1242](#1242)) - Regenerate css_ast/src/values from csswg drafts (#1254) ([#1254](#1254)) - fuzz: new parser findings 2026-06-19 (#1232) ([#1232](#1232)) - css_ast: Refactor assert_specificity to use closure pattern (#1261) ([#1261](#1261)) - css_ast: derive(ToSpan) on WebkitFunctionalPseudoClass (#1262) ([#1262](#1262)) - Implement "VisitFlow" (#1263) ([#1263](#1263)) ### Css_parse - fuzz: new parser findings 2026-07-01 (#1260) ([#1260](#1260)) ### Csskit - chore(deps): update dependencies (patch) (#1243) ([#1243](#1243)) ### Csskit_derives - chore(deps): update rust crate itertools to 0.15.0 (#1246) ([#1246](#1246)) ### Csskit_vscode - chore(deps): update dependencies to v1.68.0 (#1247) ([#1247](#1247)) - fix(deps): update dependencies (patch) (#1255) ([#1255](#1255)) [forcebuild]
Merged
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 4, 2026
## [0.0.27] - 2026-07-04 ### Other Changes - Fuzz: minimize corpus, and do so on nightly fuzz build (#1257) ([#1257](#1257)) - CI: Ensure benches build (#1259) ([#1259](#1259)) ### Css_ast - css_ast/css_parse: Improve peeking robustness. (#1238) ([#1238](#1238)) - Regenerate css_ast/src/values from csswg drafts (#1242) ([#1242](#1242)) - Regenerate css_ast/src/values from csswg drafts (#1254) ([#1254](#1254)) - fuzz: new parser findings 2026-06-19 (#1232) ([#1232](#1232)) - css_ast: Refactor assert_specificity to use closure pattern (#1261) ([#1261](#1261)) - css_ast: derive(ToSpan) on WebkitFunctionalPseudoClass (#1262) ([#1262](#1262)) - Implement "VisitFlow" (#1263) ([#1263](#1263)) ### Css_parse - fuzz: new parser findings 2026-07-01 (#1260) ([#1260](#1260)) ### Csskit - chore(deps): update dependencies (patch) (#1243) ([#1243](#1243)) ### Csskit_derives - chore(deps): update rust crate itertools to 0.15.0 (#1246) ([#1246](#1246)) ### Csskit_vscode - chore(deps): update dependencies to v1.68.0 (#1247) ([#1247](#1247)) - fix(deps): update dependencies (patch) (#1255) ([#1255](#1255))
keithamus
added a commit
that referenced
this pull request
Jul 4, 2026
## [0.0.27] - 2026-07-04 ### Other Changes - Fuzz: minimize corpus, and do so on nightly fuzz build (#1257) ([#1257](#1257)) - CI: Ensure benches build (#1259) ([#1259](#1259)) ### Css_ast - css_ast/css_parse: Improve peeking robustness. (#1238) ([#1238](#1238)) - Regenerate css_ast/src/values from csswg drafts (#1242) ([#1242](#1242)) - Regenerate css_ast/src/values from csswg drafts (#1254) ([#1254](#1254)) - fuzz: new parser findings 2026-06-19 (#1232) ([#1232](#1232)) - css_ast: Refactor assert_specificity to use closure pattern (#1261) ([#1261](#1261)) - css_ast: derive(ToSpan) on WebkitFunctionalPseudoClass (#1262) ([#1262](#1262)) - Implement "VisitFlow" (#1263) ([#1263](#1263)) ### Css_parse - fuzz: new parser findings 2026-07-01 (#1260) ([#1260](#1260)) ### Csskit - chore(deps): update dependencies (patch) (#1243) ([#1243](#1243)) ### Csskit_derives - chore(deps): update rust crate itertools to 0.15.0 (#1246) ([#1246](#1246)) ### Csskit_vscode - chore(deps): update dependencies to v1.68.0 (#1247) ([#1247](#1247)) - fix(deps): update dependencies (patch) (#1255) ([#1255](#1255))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the AST traversal visitor pattern walks the entire tree, even when it
doesn't strictly need to. This is bad for performance, which is especially
wasteful as we precompute alot of metadata while building the AST. This also
means some code (e.g. reduce_colors) needs to manage its own control flow to
avoid "over reducing" some nodes. Really we should be able to skip descending
into subtrees.
This change refactors the Visit code to return a ControlFlow type, with subtype
enums that control how visitors should descend into the tree. Each visit method
can either break (stop the whole visit flow), skip children (so only the exit_
fires) or descend (the default). This also refactors the various consumers to
take advantage of this new feature, including the selector engine in csskit_ast.