mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibWeb/CSS: Update definition for cursor
property
No functional changes. The main difference is renaming the cursor enum
to match the spec term `<cursor-predefined>`, which is a bit more
verbose but clearer in meaning.
Corresponds to 1a57a4025c
This commit is contained in:
parent
c3e470569e
commit
0809eacd97
Notes:
github-actions[bot]
2025-07-09 11:22:44 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0809eacd97
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5367
Reviewed-by: https://github.com/gmta ✅
6 changed files with 51 additions and 49 deletions
|
@ -1061,16 +1061,16 @@ Vector<CursorData> ComputedProperties::cursor() const
|
|||
continue;
|
||||
}
|
||||
|
||||
if (auto keyword = keyword_to_cursor(item->to_keyword()); keyword.has_value())
|
||||
if (auto keyword = keyword_to_cursor_predefined(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())
|
||||
if (auto keyword = keyword_to_cursor_predefined(value.to_keyword()); keyword.has_value())
|
||||
cursors.append(keyword.release_value());
|
||||
}
|
||||
|
||||
if (cursors.is_empty())
|
||||
cursors.append(Cursor::Auto);
|
||||
cursors.append(CursorPredefined::Auto);
|
||||
|
||||
return cursors;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ struct ScrollbarColorData {
|
|||
Color track_color { Color::Transparent };
|
||||
};
|
||||
|
||||
using CursorData = Variant<NonnullRefPtr<CursorStyleValue const>, Cursor>;
|
||||
using CursorData = Variant<NonnullRefPtr<CursorStyleValue const>, CursorPredefined>;
|
||||
|
||||
using ListStyleType = Variant<CounterStyleNameKeyword, String>;
|
||||
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
static CSS::Clip clip() { return CSS::Clip::make_auto(); }
|
||||
static CSS::PreferredColorScheme color_scheme() { return CSS::PreferredColorScheme::Auto; }
|
||||
static CSS::ContentVisibility content_visibility() { return CSS::ContentVisibility::Visible; }
|
||||
static CursorData cursor() { return { CSS::Cursor::Auto }; }
|
||||
static CursorData cursor() { return { CSS::CursorPredefined::Auto }; }
|
||||
static CSS::WhiteSpaceCollapse white_space_collapse() { return CSS::WhiteSpaceCollapse::Collapse; }
|
||||
static CSS::WordBreak word_break() { return CSS::WordBreak::Normal; }
|
||||
static CSS::LengthOrCalculated word_spacing() { return CSS::Length::make_px(0); }
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
"anonymous",
|
||||
"use-credentials"
|
||||
],
|
||||
"cursor": [
|
||||
"cursor-predefined": [
|
||||
"auto",
|
||||
"default",
|
||||
"none",
|
||||
|
|
|
@ -1050,10 +1050,11 @@ RefPtr<CSSStyleValue const> Parser::parse_counter_set_value(TokenStream<Componen
|
|||
return parse_counter_definitions_value(tokens, AllowReversed::No, 0);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-ui-3/#cursor
|
||||
// https://drafts.csswg.org/css-ui-4/#cursor
|
||||
RefPtr<CSSStyleValue const> Parser::parse_cursor_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// [ [<url> [<x> <y>]?,]* <built-in-cursor> ]
|
||||
// <cursor-image>#? <cursor-predefined>
|
||||
// <cursor-image> = <url> <number>{2}?
|
||||
// So, any number of custom cursor definitions, and then a mandatory cursor name keyword, all comma-separated.
|
||||
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
@ -1069,7 +1070,7 @@ RefPtr<CSSStyleValue const> Parser::parse_cursor_value(TokenStream<ComponentValu
|
|||
// Cursor keyword
|
||||
part_tokens.discard_whitespace();
|
||||
auto keyword_value = parse_keyword_value(part_tokens);
|
||||
if (!keyword_value || !keyword_to_cursor(keyword_value->to_keyword()).has_value())
|
||||
if (!keyword_value || !keyword_to_cursor_predefined(keyword_value->to_keyword()).has_value())
|
||||
return {};
|
||||
|
||||
part_tokens.discard_whitespace();
|
||||
|
@ -1079,7 +1080,7 @@ RefPtr<CSSStyleValue const> Parser::parse_cursor_value(TokenStream<ComponentValu
|
|||
cursors.append(keyword_value.release_nonnull());
|
||||
} else {
|
||||
// Custom cursor definition
|
||||
// <url> [<x> <y>]?
|
||||
// <cursor-image> = <url> <number>{2}?
|
||||
// "Conforming user agents may, instead of <url>, support <image> which is a superset."
|
||||
|
||||
part_tokens.discard_whitespace();
|
||||
|
@ -1090,7 +1091,7 @@ RefPtr<CSSStyleValue const> Parser::parse_cursor_value(TokenStream<ComponentValu
|
|||
part_tokens.discard_whitespace();
|
||||
|
||||
if (part_tokens.has_next_token()) {
|
||||
// x and y, which are both <number>
|
||||
// <number>{2}, which are the x and y coordinates of the hotspot
|
||||
auto x = parse_number(part_tokens);
|
||||
part_tokens.discard_whitespace();
|
||||
auto y = parse_number(part_tokens);
|
||||
|
|
|
@ -1386,7 +1386,8 @@
|
|||
"initial": "auto",
|
||||
"valid-types": [
|
||||
"url",
|
||||
"cursor"
|
||||
"cursor-predefined",
|
||||
"number [-∞,∞]"
|
||||
]
|
||||
},
|
||||
"cx": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue