mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
LibWeb: Implement helpers for parsing CSS numeric types
Frequently we want to parse "anything that's a `<length-percentage>`" or similar, which could be a constant value or a calculation, but didn't have a nice way of doing so. That meant repeating the same "try and parse a dimension, see if it's the right type, then maybe try and parse a calculation and see if that's the right type" boilerplate code. Or more often, forgetting about calculations entirely. These helpers should make that a lot more convenient to do. And they also use TokenStream, so we can eventually drop the old `parse_length()` method.
This commit is contained in:
parent
30dcbc306c
commit
e62d692205
2 changed files with 259 additions and 0 deletions
|
@ -171,6 +171,19 @@ private:
|
|||
Optional<StyleProperty> convert_to_style_property(Declaration const&);
|
||||
|
||||
Optional<Dimension> parse_dimension(ComponentValue const&);
|
||||
Optional<AngleOrCalculated> parse_angle(TokenStream<ComponentValue>&);
|
||||
Optional<AnglePercentage> parse_angle_percentage(TokenStream<ComponentValue>&);
|
||||
Optional<FlexOrCalculated> parse_flex(TokenStream<ComponentValue>&);
|
||||
Optional<FrequencyOrCalculated> parse_frequency(TokenStream<ComponentValue>&);
|
||||
Optional<FrequencyPercentage> parse_frequency_percentage(TokenStream<ComponentValue>&);
|
||||
Optional<IntegerOrCalculated> parse_integer(TokenStream<ComponentValue>&);
|
||||
Optional<LengthOrCalculated> parse_length(TokenStream<ComponentValue>&);
|
||||
Optional<LengthPercentage> parse_length_percentage(TokenStream<ComponentValue>&);
|
||||
Optional<NumberOrCalculated> parse_number(TokenStream<ComponentValue>&);
|
||||
Optional<ResolutionOrCalculated> parse_resolution(TokenStream<ComponentValue>&);
|
||||
Optional<TimeOrCalculated> parse_time(TokenStream<ComponentValue>&);
|
||||
Optional<TimePercentage> parse_time_percentage(TokenStream<ComponentValue>&);
|
||||
|
||||
Optional<Color> parse_rgb_or_hsl_color(StringView function_name, Vector<ComponentValue> const&);
|
||||
Optional<Color> parse_color(ComponentValue const&);
|
||||
Optional<Length> parse_length(ComponentValue const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue