mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Support non-fixed <random-value-sharing>
This works by generating random values using XorShift128PlusRNG at compute time and then caching them on the document using the relevant random-caching-key
This commit is contained in:
parent
86e6aa0291
commit
12e8f503aa
Notes:
github-actions[bot]
2025-12-01 11:01:47 +00:00
Author: https://github.com/Calme1709
Commit: 12e8f503aa
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6707
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/gmta
15 changed files with 226 additions and 54 deletions
|
|
@ -3798,6 +3798,9 @@ RefPtr<RandomValueSharingStyleValue const> Parser::parse_random_value_sharing(To
|
|||
|
||||
tokens.discard_whitespace();
|
||||
|
||||
if (!tokens.has_next_token())
|
||||
return nullptr;
|
||||
|
||||
// fixed <number [0,1]>
|
||||
if (tokens.next_token().is_ident("fixed"sv)) {
|
||||
tokens.discard_a_token();
|
||||
|
|
@ -3820,8 +3823,51 @@ RefPtr<RandomValueSharingStyleValue const> Parser::parse_random_value_sharing(To
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// FIXME: Support non-fixed values
|
||||
return nullptr;
|
||||
// [ [ auto | <dashed-ident> ] || element-shared ]
|
||||
bool has_explicit_auto = false;
|
||||
Optional<FlyString> dashed_ident;
|
||||
bool element_shared = false;
|
||||
|
||||
while (tokens.has_next_token()) {
|
||||
if (auto maybe_dashed_ident_value = parse_dashed_ident_value(tokens)) {
|
||||
if (has_explicit_auto || dashed_ident.has_value())
|
||||
return nullptr;
|
||||
|
||||
dashed_ident = maybe_dashed_ident_value->custom_ident();
|
||||
|
||||
tokens.discard_whitespace();
|
||||
continue;
|
||||
}
|
||||
|
||||
auto maybe_keyword_value = parse_keyword_value(tokens);
|
||||
|
||||
if (maybe_keyword_value && maybe_keyword_value->to_keyword() == Keyword::Auto) {
|
||||
if (has_explicit_auto || dashed_ident.has_value())
|
||||
return nullptr;
|
||||
|
||||
has_explicit_auto = true;
|
||||
|
||||
tokens.discard_whitespace();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (maybe_keyword_value && maybe_keyword_value->to_keyword() == Keyword::ElementShared) {
|
||||
if (element_shared)
|
||||
return nullptr;
|
||||
|
||||
element_shared = true;
|
||||
|
||||
tokens.discard_whitespace();
|
||||
continue;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!dashed_ident.has_value())
|
||||
return RandomValueSharingStyleValue::create_auto(random_value_sharing_auto_name(), element_shared);
|
||||
|
||||
return RandomValueSharingStyleValue::create_dashed_ident(dashed_ident.value(), element_shared);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-values-4/#typedef-dashed-ident
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue