LibWeb: Store CursorStyleValue sub-values directly

Storing these within NumberOrCalculated is unnecessary
This commit is contained in:
Callum Law
2025-10-02 17:00:20 +13:00
committed by Sam Atkins
parent 25192d3c20
commit e772a992be
Notes: github-actions[bot] 2025-10-07 09:51:09 +00:00
3 changed files with 38 additions and 29 deletions

View File

@@ -18,17 +18,14 @@ namespace Web::CSS {
class CursorStyleValue final : public StyleValueWithDefaultOperators<CursorStyleValue> {
public:
static ValueComparingNonnullRefPtr<CursorStyleValue const> create(ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image, Optional<NumberOrCalculated> x, Optional<NumberOrCalculated> y)
static ValueComparingNonnullRefPtr<CursorStyleValue const> create(ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image, RefPtr<StyleValue const> x, RefPtr<StyleValue const> y)
{
VERIFY(x.has_value() == y.has_value());
// We require either both or neither the X and Y parameters
VERIFY((!x && !y) || (x && y));
return adopt_ref(*new (nothrow) CursorStyleValue(move(image), move(x), move(y)));
}
virtual ~CursorStyleValue() override = default;
ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image() const { return m_properties.image; }
Optional<NumberOrCalculated> const& x() const { return m_properties.x; }
Optional<NumberOrCalculated> const& y() const { return m_properties.y; }
Optional<Gfx::ImageCursor> make_image_cursor(Layout::NodeWithStyle const&) const;
virtual String to_string(SerializationMode) const override;
@@ -39,8 +36,8 @@ public:
private:
CursorStyleValue(ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image,
Optional<NumberOrCalculated> x,
Optional<NumberOrCalculated> y)
RefPtr<StyleValue const> x,
RefPtr<StyleValue const> y)
: StyleValueWithDefaultOperators(Type::Cursor)
, m_properties { .image = move(image), .x = move(x), .y = move(y) }
{
@@ -48,8 +45,8 @@ private:
struct Properties {
ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image;
Optional<NumberOrCalculated> x;
Optional<NumberOrCalculated> y;
RefPtr<StyleValue const> x;
RefPtr<StyleValue const> y;
bool operator==(Properties const&) const = default;
} m_properties;