mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Parse the scroll-timeline shorthand CSS property
The remaining failing tests in scroll-timeline-shorthand.html are due to either: a) incorrect tests, see web-platform-tests/wpt#56181 or; b) a wider issue where we collapse coordinating value list longhand properties to a single value when we shouldn't.
This commit is contained in:
parent
992b0a4dc6
commit
13ce2d1857
Notes:
github-actions[bot]
2025-11-28 13:26:23 +00:00
Author: https://github.com/Calme1709
Commit: 13ce2d1857
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6912
Reviewed-by: https://github.com/AtkinsSJ ✅
8 changed files with 261 additions and 3 deletions
|
|
@ -745,6 +745,8 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue const>> Parser::parse_css_value(Pr
|
|||
return parse_all_as(tokens, [this](auto& tokens) { return parse_translate_value(tokens); });
|
||||
case PropertyID::Scale:
|
||||
return parse_all_as(tokens, [this](auto& tokens) { return parse_scale_value(tokens); });
|
||||
case PropertyID::ScrollTimeline:
|
||||
return parse_all_as(tokens, [this](auto& tokens) { return parse_scroll_timeline_value(tokens); });
|
||||
case PropertyID::ScrollTimelineAxis:
|
||||
case PropertyID::ScrollTimelineName:
|
||||
return parse_all_as(tokens, [this, property_id](auto& tokens) { return parse_simple_comma_separated_value_list(property_id, tokens); });
|
||||
|
|
@ -5182,6 +5184,73 @@ RefPtr<StyleValue const> Parser::parse_scale_value(TokenStream<ComponentValue>&
|
|||
return TransformationStyleValue::create(PropertyID::Scale, TransformFunction::Scale3d, { maybe_x.release_nonnull(), maybe_y.release_nonnull(), maybe_z.release_nonnull() });
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/scroll-animations-1/#scroll-timeline-shorthand
|
||||
RefPtr<StyleValue const> Parser::parse_scroll_timeline_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// [ <'scroll-timeline-name'> <'scroll-timeline-axis'>? ]#
|
||||
StyleValueVector names;
|
||||
StyleValueVector axes;
|
||||
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
||||
do {
|
||||
tokens.discard_whitespace();
|
||||
|
||||
auto maybe_name = parse_css_value_for_property(PropertyID::ScrollTimelineName, tokens);
|
||||
|
||||
if (!maybe_name)
|
||||
return nullptr;
|
||||
|
||||
names.append(maybe_name.release_nonnull());
|
||||
|
||||
tokens.discard_whitespace();
|
||||
|
||||
if (tokens.next_token().is(Token::Type::Comma)) {
|
||||
axes.append(KeywordStyleValue::create(Keyword::Block));
|
||||
tokens.discard_a_token();
|
||||
|
||||
// Disallow trailing commas
|
||||
if (!tokens.has_next_token())
|
||||
return nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!tokens.has_next_token()) {
|
||||
axes.append(KeywordStyleValue::create(Keyword::Block));
|
||||
break;
|
||||
}
|
||||
|
||||
auto maybe_axis = parse_css_value_for_property(PropertyID::ScrollTimelineAxis, tokens);
|
||||
|
||||
if (!maybe_axis)
|
||||
return nullptr;
|
||||
|
||||
axes.append(maybe_axis.release_nonnull());
|
||||
|
||||
tokens.discard_whitespace();
|
||||
|
||||
if (tokens.next_token().is(Token::Type::Comma)) {
|
||||
tokens.discard_a_token();
|
||||
|
||||
// Disallow trailing commas
|
||||
if (!tokens.has_next_token())
|
||||
return nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tokens.has_next_token())
|
||||
return nullptr;
|
||||
} while (tokens.has_next_token());
|
||||
|
||||
transaction.commit();
|
||||
|
||||
return ShorthandStyleValue::create(PropertyID::ScrollTimeline,
|
||||
{ PropertyID::ScrollTimelineName, PropertyID::ScrollTimelineAxis },
|
||||
{ StyleValueList::create(move(names), StyleValueList::Separator::Comma), StyleValueList::create(move(axes), StyleValueList::Separator::Comma) });
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-scrollbars/#propdef-scrollbar-color
|
||||
RefPtr<StyleValue const> Parser::parse_scrollbar_color_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue