mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Store CursorStyleValue sub-values directly
Storing these within NumberOrCalculated is unnecessary
This commit is contained in:
Notes:
github-actions[bot]
2025-10-07 09:51:09 +00:00
Author: https://github.com/Calme1709 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e772a992be8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6375 Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user