Skip to content

Commit 2477a8e

Browse files
Calme1709AtkinsSJ
authored andcommitted
LibWeb: Use property_initial_value rather than hardcoded default value
1 parent d6371fe commit 2477a8e

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5167,6 +5167,8 @@ RefPtr<StyleValue const> Parser::parse_scroll_timeline_value(TokenStream<Compone
51675167
auto transaction = tokens.begin_transaction();
51685168

51695169
do {
5170+
static auto default_axis = property_initial_value(PropertyID::ScrollTimelineAxis)->as_value_list().values()[0];
5171+
51705172
tokens.discard_whitespace();
51715173

51725174
auto maybe_name = parse_css_value_for_property(PropertyID::ScrollTimelineName, tokens);
@@ -5179,7 +5181,7 @@ RefPtr<StyleValue const> Parser::parse_scroll_timeline_value(TokenStream<Compone
51795181
tokens.discard_whitespace();
51805182

51815183
if (tokens.next_token().is(Token::Type::Comma)) {
5182-
axes.append(KeywordStyleValue::create(Keyword::Block));
5184+
axes.append(default_axis);
51835185
tokens.discard_a_token();
51845186

51855187
// Disallow trailing commas
@@ -5190,7 +5192,7 @@ RefPtr<StyleValue const> Parser::parse_scroll_timeline_value(TokenStream<Compone
51905192
}
51915193

51925194
if (!tokens.has_next_token()) {
5193-
axes.append(KeywordStyleValue::create(Keyword::Block));
5195+
axes.append(default_axis);
51945196
break;
51955197
}
51965198

@@ -6333,17 +6335,11 @@ RefPtr<StyleValue const> Parser::parse_view_timeline_value(TokenStream<Component
63336335
VERIFY(name);
63346336
names.append(name.release_nonnull());
63356337

6336-
// FIXME: Use the first entry in property_initial_value() to get the initial values for these longhands once
6337-
// we always parse them as lists.
6338-
if (axis)
6339-
axes.append(axis.release_nonnull());
6340-
else
6341-
axes.append(KeywordStyleValue::create(Keyword::Block));
6338+
static auto default_axis = property_initial_value(PropertyID::ViewTimelineAxis)->as_value_list().values()[0];
6339+
static auto default_inset = property_initial_value(PropertyID::ViewTimelineInset)->as_value_list().values()[0];
63426340

6343-
if (inset)
6344-
insets.append(inset.release_nonnull());
6345-
else
6346-
insets.append(StyleValueList::create({ KeywordStyleValue::create(Keyword::Auto), KeywordStyleValue::create(Keyword::Auto) }, StyleValueList::Separator::Space));
6341+
axes.append(axis ? axis.release_nonnull() : default_axis);
6342+
insets.append(inset ? inset.release_nonnull() : default_inset);
63476343
};
63486344

63496345
tokens.discard_whitespace();

0 commit comments

Comments
 (0)