/* * Copyright (c) 2025, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace Web::CSS { class CursorStyleValue final : public StyleValueWithDefaultOperators { public: static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr image, Optional x, Optional y) { VERIFY(x.has_value() == y.has_value()); return adopt_ref(*new (nothrow) CursorStyleValue(move(image), move(x), move(y))); } virtual ~CursorStyleValue() override = default; ValueComparingNonnullRefPtr image() const { return m_properties.image; } Optional const& x() const { return m_properties.x; } Optional const& y() const { return m_properties.y; } Optional make_image_cursor(Layout::NodeWithStyle const&) const; virtual String to_string(SerializationMode) const override; bool properties_equal(CursorStyleValue const& other) const { return m_properties == other.m_properties; } private: CursorStyleValue(ValueComparingNonnullRefPtr image, Optional x, Optional y) : StyleValueWithDefaultOperators(Type::Cursor) , m_properties { .image = move(image), .x = move(x), .y = move(y) } { } struct Properties { ValueComparingNonnullRefPtr image; Optional x; Optional y; bool operator==(Properties const&) const = default; } m_properties; // Data that can affect the bitmap rendering. struct CacheKey { Length::ResolutionContext length_resolution_context; Gfx::Color current_color; bool operator==(CacheKey const&) const = default; }; mutable Optional m_cache_key; mutable Optional m_cached_bitmap; }; }