diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-05-17 17:23:42 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-25 06:36:10 +0200 |
commit | bcacc2357ec7b365da5a9f5e5551b6184771151f (patch) | |
tree | 0874011fbd5c15802f3a7399749835f1c29133d4 /Userland/Libraries/LibWeb/CSS/Selector.cpp | |
parent | da4b2d9ca367e8370ff69f0e734969781c11eff0 (diff) | |
download | serenity-bcacc2357ec7b365da5a9f5e5551b6184771151f.zip |
LibWeb: Implement smarter CSS StyleValue parsing
We know what types and identifiers a property can accept, so we can use
that information to only parse things that can be accepted. This solves
some awkward ambiguity problems that we have now or will face in the
future, including:
- Is `0` a number or a length with no unit?
- Is `3.5` a number or a ratio?
- Is `bottom` an identifier, or a custom-ident?
Two CSS Parser methods are introduced here:
`parse_css_value_for_property()` attempts to parse a StyleValue that the
property can accept, skipping any types that it doesn't want.
`parse_css_value_for_properties()` does the same, but takes multiple
PropertyIDs and additionally returns which one the parsed StyleValue is
for. This is intended for parsing shorthands, so you can give it a list
of longhands you haven't yet parsed.
Subsequent commits will actually use these new methods.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Selector.cpp')
0 files changed, 0 insertions, 0 deletions