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
parent 9cbd8a82c7
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,6 +1,6 @@
/*
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
*
@ -25,6 +25,7 @@
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
#include <LibWeb/CSS/StyleValues/CounterStyleValue.h>
#include <LibWeb/CSS/StyleValues/CursorStyleValue.h>
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
@ -146,6 +147,12 @@ CounterDefinitionsStyleValue const& CSSStyleValue::as_counter_definitions() cons
return static_cast<CounterDefinitionsStyleValue const&>(*this);
}
CursorStyleValue const& CSSStyleValue::as_cursor() const
{
VERIFY(is_cursor());
return static_cast<CursorStyleValue const&>(*this);
}
CustomIdentStyleValue const& CSSStyleValue::as_custom_ident() const
{
VERIFY(is_custom_ident());