Replace CSSSyntaxParser with CSSValueParser in data type sinks#55754
Open
NickGerleman wants to merge 2 commits intofacebook:mainfrom
Open
Replace CSSSyntaxParser with CSSValueParser in data type sinks#55754NickGerleman wants to merge 2 commits intofacebook:mainfrom
NickGerleman wants to merge 2 commits intofacebook:mainfrom
Conversation
Summary: Previously, CSS compound data types used two separate types: `CSSCompoundDataType<T1, T2, ...>` as an empty marker struct for template parameter deduction, and `CSSVariantWithTypes<CSSCompoundDataType<T1, T2, ...>>` which resolved to `std::variant<T1, T2, ...>` for actual storage. This resulted in redundant type aliases like `CSSTransformFunctionVariant`. This change makes `CSSCompoundDataType<T1, T2, ...>` a `using` alias for `std::variant<T1, T2, ...>` directly, so one type serves both roles: template parameter deduction for parsing AND storage. - Change `CSSCompoundDataType` from a marker struct to a `using` alias for `std::variant` - Replace `CSSValidCompoundDataType` concept with `is_variant_of_data_types` trait that pattern-matches `std::variant` where all types satisfy `CSSDataType` - Update `merge_data_types` and `merge_variant` specializations to use `std::variant` directly - Store `AllowedTypesT` directly in `CSSList` compound type specialization (since it IS now the variant) - Remove redundant `CSSTransformFunctionVariant`, `CSSFilterFunctionVariant`, and `CSSBackgroundImageVariant` aliases - Update all downstream references in conversions Changelog: [Internal] Differential Revision: D94347088
Summary: Previously, CSSDataTypeParser sinks received a raw CSSSyntaxParser& reference, which exposed low-level tokenization APIs (consumeComponentValue with lambdas, consumeToken, etc.) that data type parsers should not use directly. This made it unclear what operations are appropriate when implementing a new CSS data type. This change promotes detail::CSSValueParser to a public CSSValueParser class that wraps CSSSyntaxParser and exposes only value-level parsing operations: parseNextValue, peekNextValue, consumeWhitespace, consumeDelimiter, isFinished, peekNextTokenIs, and saveState/restoreState for lookahead patterns. All CSSDataTypeParser sink methods now receive CSSValueParser& instead of CSSSyntaxParser&, and use parser.parseNextValue<T>() instead of the free function parseNextCSSValue<T>(parser). Direct consumeComponentValue calls in gradient parsers (CSSBackgroundImage.h) are replaced with keyword set parsing via parseNextValue<KeywordEnum>, with new To/At keywords added to CSSKeyword. The free functions parseCSSProperty, parseNextCSSValue, and peekNextCSSValue remain as convenience wrappers for backward compatibility. Changelog: [Internal] Reviewed By: jorge-cab Differential Revision: D94357104
|
@NickGerleman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D94357104. |
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.
Summary:
Previously, CSSDataTypeParser sinks received a raw CSSSyntaxParser& reference,
which exposed low-level tokenization APIs (consumeComponentValue with lambdas,
consumeToken, etc.) that data type parsers should not use directly. This made
it unclear what operations are appropriate when implementing a new CSS data
type.
This change promotes detail::CSSValueParser to a public CSSValueParser class
that wraps CSSSyntaxParser and exposes only value-level parsing operations:
parseNextValue, peekNextValue, consumeWhitespace, consumeDelimiter, isFinished,
peekNextTokenIs, and saveState/restoreState for lookahead patterns.
All CSSDataTypeParser sink methods now receive CSSValueParser& instead of
CSSSyntaxParser&, and use parser.parseNextValue() instead of the free
function parseNextCSSValue(parser). Direct consumeComponentValue calls in
gradient parsers (CSSBackgroundImage.h) are replaced with keyword set parsing
via parseNextValue, with new To/At keywords added to CSSKeyword.
The free functions parseCSSProperty, parseNextCSSValue, and peekNextCSSValue
remain as convenience wrappers for backward compatibility.
Changelog: [Internal]
Reviewed By: jorge-cab
Differential Revision: D94357104