LibWeb/CSS: Implement CursorStyleValue

A cursor is an image, with an optional x,y hotspot.

We know that a CursorStyleValue's bitmap never needs to change size, so
we create the ShareableBitmap once and then cache it, so that we don't
have to repeatedly create an FD for it or do the work of painting.

To avoid repainting that bitmap, we cache the values that were used to
create it - what currentColor is and its length resolution context -
and only repaint when those change.
This commit is contained in:
Sam Atkins 2025-02-21 13:04:20 +00:00 committed by Andreas Kling
commit d127d412c8
Notes: github-actions[bot] 2025-02-28 12:51:42 +00:00
6 changed files with 207 additions and 2 deletions

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
@ -97,6 +97,7 @@ public:
Content,
Counter,
CounterDefinitions,
Cursor,
CustomIdent,
Display,
Easing,
@ -193,6 +194,10 @@ public:
CounterDefinitionsStyleValue const& as_counter_definitions() const;
CounterDefinitionsStyleValue& as_counter_definitions() { return const_cast<CounterDefinitionsStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_counter_definitions()); }
bool is_cursor() const { return type() == Type::Cursor; }
CursorStyleValue const& as_cursor() const;
CursorStyleValue& as_cursor() { return const_cast<CursorStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_cursor()); }
bool is_custom_ident() const { return type() == Type::CustomIdent; }
CustomIdentStyleValue const& as_custom_ident() const;
CustomIdentStyleValue& as_custom_ident() { return const_cast<CustomIdentStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_custom_ident()); }