mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
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:
parent
fd2414ba35
commit
bfd7ac1204
Notes:
github-actions[bot]
2025-02-28 12:51:27 +00:00
Author: https://github.com/AtkinsSJ
Commit: bfd7ac1204
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3644
20 changed files with 297 additions and 170 deletions
|
@ -11,7 +11,6 @@
|
|||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibWeb/CSS/Clip.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
|
||||
|
@ -32,7 +31,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/RectStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ScrollbarGutterStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
|
@ -954,13 +952,30 @@ ContentVisibility ComputedProperties::content_visibility() const
|
|||
return keyword_to_content_visibility(value.to_keyword()).release_value();
|
||||
}
|
||||
|
||||
Cursor ComputedProperties::cursor() const
|
||||
Vector<CursorData> ComputedProperties::cursor() const
|
||||
{
|
||||
// Return the first available cursor.
|
||||
auto const& value = property(PropertyID::Cursor);
|
||||
// FIXME: We don't currently support custom cursors.
|
||||
if (value.is_url())
|
||||
return Cursor::Auto;
|
||||
return keyword_to_cursor(value.to_keyword()).release_value();
|
||||
Vector<CursorData> cursors;
|
||||
if (value.is_value_list()) {
|
||||
for (auto const& item : value.as_value_list().values()) {
|
||||
if (item->is_cursor()) {
|
||||
cursors.append({ item->as_cursor() });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto keyword = keyword_to_cursor(item->to_keyword()); keyword.has_value())
|
||||
cursors.append(keyword.release_value());
|
||||
}
|
||||
} else if (value.is_keyword()) {
|
||||
if (auto keyword = keyword_to_cursor(value.to_keyword()); keyword.has_value())
|
||||
cursors.append(keyword.release_value());
|
||||
}
|
||||
|
||||
if (cursors.is_empty())
|
||||
cursors.append(Cursor::Auto);
|
||||
|
||||
return cursors;
|
||||
}
|
||||
|
||||
Visibility ComputedProperties::visibility() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue