Allow parser to support generic data types #48718
Open
+1,157
−2,953
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:
This diff looks a bit scary, but it's mostly just structural changes of existing code and some deletion, on a well tested path 😅.
The current parser implementation tries to special case "basic" data types. When I was looking at how to add in support for more complex values, such as lists, function notations, and more compounded types, this distinction ends up not making much sense.
Instead of treating some types as basic, this diff instead moves to a model where a user can declare any structure as a
CSSDataType
, so long as they also supply a parser, which may be visited when iterating through CSS syntax blocks. The user then specifies a list of supported CSS data types to parse, which invokes said parser. E.g.This breaks a whole lot of assumptions I made a year ago, especially around
CSSValueVariant
which must now be able to handle arbitrary values. For now, for the sake of simplicity, I threw this out, and migrated parser code to use plain-oldstd::variant
, which has a downside of being a bit less optimized in terms of storage. I also ended up completely throwing outCSSDeclaredStyle
, since it would majorly need to change, and we're not going to be migrating style storage quite yet. This change also broke theCSSProperties.h
property definitions a bit, which we will need for value processing later. I also opted to delete this for now, but will likely copy bits from it for source history later.Another particular hairy bit, that likely won't bite us in practice, is that some strings may be parseable under different data types. This just adds caller requirement to order the types correctly, instead of precedence being implemented as part of the parser.
Changelog: [Internal]
Differential Revision: D68245734