/* * 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, RefPtr x, RefPtr y) { // 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; Optional make_image_cursor(Layout::NodeWithStyle const&) const; virtual String to_string(SerializationMode) const override; virtual ValueComparingNonnullRefPtr absolutized(ComputationContext const&) const override; bool properties_equal(CursorStyleValue const& other) const { return m_properties == other.m_properties; } private: CursorStyleValue(ValueComparingNonnullRefPtr image, RefPtr x, RefPtr y) : StyleValueWithDefaultOperators(Type::Cursor) , m_properties { .image = move(image), .x = move(x), .y = move(y) } { } struct Properties { ValueComparingNonnullRefPtr image; RefPtr x; RefPtr 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; }; }