1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibWeb: Add PercentageStyleValue, and parse it

This is in a slightly weird state, where Percentages are sometimes
Lengths and sometimes not, which I will be cleaning up in subsequent
commits, in an attempt not to change all of LibWeb in one go. :^)
This commit is contained in:
Sam Atkins 2022-01-14 17:09:02 +00:00 committed by Andreas Kling
parent 0bb5bda23e
commit ea0f6b42f0
5 changed files with 188 additions and 68 deletions

View file

@ -176,6 +176,30 @@ private:
[[nodiscard]] RefPtr<PropertyOwningCSSStyleDeclaration> convert_to_declaration(NonnullRefPtr<StyleBlockRule>);
[[nodiscard]] Optional<StyleProperty> convert_to_style_property(StyleDeclarationRule const&);
class Dimension {
public:
Dimension(Length&& value)
: m_value(move(value))
{
}
Dimension(Percentage&& value)
: m_value(move(value))
{
}
bool is_length() const;
Length length() const;
bool is_percentage() const;
Percentage percentage() const;
bool is_length_percentage() const;
LengthPercentage length_percentage() const;
private:
Variant<Length, Percentage> m_value;
};
Optional<Dimension> parse_dimension(StyleComponentValueRule const&);
Optional<Color> parse_color(StyleComponentValueRule const&);
Optional<Length> parse_length(StyleComponentValueRule const&);
@ -189,7 +213,7 @@ private:
RefPtr<StyleValue> parse_css_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_builtin_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_dynamic_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_length_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_dimension_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_numeric_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_identifier_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_color_value(StyleComponentValueRule const&);