1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:27:45 +00:00

LibWeb: Simplify StyleValue API now that auto isn't a length

Now that LengthStyleValue never contains `auto`, IdentifierStyleValue is
the only type that can hold an identifier. This lets us remove a couple
of virtual methods from StyleValue.

I've kept `has_auto()` and `to_identifier()` for convenience, but they
are now simple non-virtual methods.
This commit is contained in:
Sam Atkins 2023-04-19 12:00:38 +01:00 committed by Andreas Kling
parent 4ddacf4740
commit 0f9f6aef81
6 changed files with 20 additions and 15 deletions

View file

@ -24,9 +24,6 @@ public:
ValueID id() const { return m_id; }
virtual bool has_auto() const override { return m_id == ValueID::Auto; }
virtual bool has_identifier() const override { return true; }
virtual ValueID to_identifier() const override { return m_id; }
virtual bool has_color() const override;
virtual Color to_color(Layout::NodeWithStyle const& node) const override;
virtual ErrorOr<String> to_string() const override;

View file

@ -20,12 +20,9 @@ public:
Length const& length() const { return m_length; }
virtual bool has_auto() const override { return m_length.is_auto(); }
virtual bool has_length() const override { return true; }
virtual bool has_identifier() const override { return has_auto(); }
virtual ErrorOr<String> to_string() const override { return m_length.to_string(); }
virtual Length to_length() const override { return m_length; }
virtual ValueID to_identifier() const override { return has_auto() ? ValueID::Auto : ValueID::Invalid; }
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size, CSSPixels line_height, CSSPixels root_line_height) const override;
bool properties_equal(LengthStyleValue const& other) const { return m_length == other.m_length; }