LibWeb+WebContent+UI: Support image cursors

The `cursor` property accepts a list of possible cursors, which behave
as a fallback: We use whichever cursor is the first available one. This
is a little complicated because initially, any remote images have not
loaded, so we need to use the fallback standard cursor, and then switch
to another when it loads.

So, ComputedValues stores a Vector of cursors, and then in EventHandler
we scan down that list until we find a cursor that's ready for use.

The spec defines cursors as being `<url>`, but allows for `<image>`
instead. That includes functions like `linear-gradient()`.

This commit implements image cursors in the Qt UI, but not AppKit.
This commit is contained in:
Sam Atkins
2025-02-20 12:17:29 +00:00
committed by Andreas Kling
parent fd2414ba35
commit bfd7ac1204
20 changed files with 297 additions and 170 deletions

View File

@@ -251,9 +251,9 @@ void PageClient::set_viewport_size(Web::DevicePixelSize const& size)
m_pending_set_browser_zoom_request = false;
}
void PageClient::page_did_request_cursor_change(Gfx::StandardCursor cursor)
void PageClient::page_did_request_cursor_change(Gfx::Cursor const& cursor)
{
client().async_did_request_cursor_change(m_id, (u32)cursor);
client().async_did_request_cursor_change(m_id, cursor);
}
void PageClient::page_did_layout()

View File

@@ -114,7 +114,7 @@ private:
virtual Web::CSS::PreferredColorScheme preferred_color_scheme() const override { return m_preferred_color_scheme; }
virtual Web::CSS::PreferredContrast preferred_contrast() const override { return m_preferred_contrast; }
virtual Web::CSS::PreferredMotion preferred_motion() const override { return m_preferred_motion; }
virtual void page_did_request_cursor_change(Gfx::StandardCursor) override;
virtual void page_did_request_cursor_change(Gfx::Cursor const&) override;
virtual void page_did_layout() override;
virtual void page_did_change_title(ByteString const&) override;
virtual void page_did_change_url(URL::URL const&) override;

View File

@@ -1,5 +1,6 @@
#include <LibCore/AnonymousBuffer.h>
#include <LibGfx/Color.h>
#include <LibGfx/Cursor.h>
#include <LibGfx/ShareableBitmap.h>
#include <LibURL/URL.h>
#include <LibWeb/Cookie/Cookie.h>
@@ -24,7 +25,7 @@ endpoint WebContentClient
did_finish_loading(u64 page_id, URL::URL url) =|
did_request_refresh(u64 page_id) =|
did_paint(u64 page_id, Gfx::IntRect content_rect, i32 bitmap_id) =|
did_request_cursor_change(u64 page_id, i32 cursor_type) =|
did_request_cursor_change(u64 page_id, Gfx::Cursor cursor) =|
did_change_title(u64 page_id, ByteString title) =|
did_change_url(u64 page_id, URL::URL url) =|
did_request_tooltip_override(u64 page_id, Gfx::IntPoint position, ByteString title) =|