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
commit bfd7ac1204
Notes: github-actions[bot] 2025-02-28 12:51:27 +00:00
20 changed files with 297 additions and 170 deletions

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 42 tests
36 Pass
6 Fail
40 Pass
2 Fail
Pass e.style['cursor'] = "auto" should set the property value
Pass e.style['cursor'] = "default" should set the property value
Pass e.style['cursor'] = "none" should set the property value
@ -40,9 +40,9 @@ Pass e.style['cursor'] = "row-resize" should set the property value
Pass e.style['cursor'] = "all-scroll" should set the property value
Pass e.style['cursor'] = "zoom-in" should set the property value
Pass e.style['cursor'] = "zoom-out" should set the property value
Fail e.style['cursor'] = "url(\"https://example.com/\"), alias" should set the property value
Fail e.style['cursor'] = "url(\"https://example.com/\") 1 calc(2 + 0), copy" should set the property value
Fail e.style['cursor'] = "url(\"https://example.com/\"), url(\"https://example.com/\") 3 -4, move" should set the property value
Fail e.style['cursor'] = "url(\"https://example.com/\") 5 6, grab" should set the property value
Pass e.style['cursor'] = "url(\"https://example.com/\"), alias" should set the property value
Pass e.style['cursor'] = "url(\"https://example.com/\") 1 calc(2 + 0), copy" should set the property value
Pass e.style['cursor'] = "url(\"https://example.com/\"), url(\"https://example.com/\") 3 -4, move" should set the property value
Pass e.style['cursor'] = "url(\"https://example.com/\") 5 6, grab" should set the property value
Fail e.style['cursor'] = "image-set(\"https://example.com/\" 1x) 5 6, grab" should set the property value
Fail e.style['cursor'] = "image-set(\"https://example.com/\" 1x, \"https://example.com/highres\" 2x) 5 6, grab" should set the property value