diff --git a/Tests/LibWeb/Layout/expected/grid/grid-row-start-non-token-parts-crash.txt b/Tests/LibWeb/Layout/expected/grid/grid-row-start-non-token-parts-crash.txt
new file mode 100644
index 0000000000..9c6f931a1f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/grid/grid-row-start-non-token-parts-crash.txt
@@ -0,0 +1,12 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+ BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline
+ BlockContainer
at (8,8) content-size 784x0 children: not-inline
+ BlockContainer at (8,8) content-size 784x0 children: not-inline
+ BlockContainer <(anonymous)> at (8,16) content-size 784x0 children: inline
+ TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+ PaintableWithLines (BlockContainer) [0,0 800x600]
+ PaintableWithLines (BlockContainer) [8,8 784x0] overflow: [8,16 784x0]
+ PaintableWithLines (BlockContainer
) [8,8 784x0]
+ PaintableWithLines (BlockContainer(anonymous)) [8,16 784x0]
diff --git a/Tests/LibWeb/Layout/input/grid/grid-row-start-non-token-parts-crash.html b/Tests/LibWeb/Layout/input/grid/grid-row-start-non-token-parts-crash.html
new file mode 100644
index 0000000000..37bc2d2279
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/grid-row-start-non-token-parts-crash.html
@@ -0,0 +1 @@
+
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index f65dd61cd9..a3f47a182a 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -5345,42 +5345,32 @@ RefPtr
Parser::parse_grid_track_placement(Vector con
// |
// [ && ? ] |
// [ span && [ || ] ]
- auto is_auto = [](Token token) -> bool {
- if (token.is(Token::Type::Ident) && token.ident().equals_ignoring_ascii_case("auto"sv))
- return true;
- return false;
- };
- auto is_span = [](Token token) -> bool {
- if (token.is(Token::Type::Ident) && token.ident().equals_ignoring_ascii_case("span"sv))
- return true;
- return false;
- };
- auto is_valid_integer = [](Token token) -> bool {
+ auto is_valid_integer = [](auto& token) -> bool {
// An value of zero makes the declaration invalid.
- if (token.is(Token::Type::Number) && token.number().is_integer() && token.number_value() != 0)
+ if (token.is(Token::Type::Number) && token.token().number().is_integer() && token.token().number_value() != 0)
return true;
return false;
};
- auto is_identifier = [](Token token) -> bool {
+ auto is_identifier = [](auto& token) -> bool {
// The additionally excludes the keywords span and auto.
- if (token.is(Token::Type::Ident) && !token.ident().equals_ignoring_ascii_case("span"sv) && !token.ident().equals_ignoring_ascii_case("auto"sv))
+ if (token.is(Token::Type::Ident) && !token.token().ident().equals_ignoring_ascii_case("span"sv) && !token.token().ident().equals_ignoring_ascii_case("auto"sv))
return true;
return false;
};
auto tokens = TokenStream { component_values };
tokens.skip_whitespace();
- auto current_token = tokens.next_token().token();
+ auto current_token = tokens.next_token();
if (!tokens.has_next_token()) {
- if (is_auto(current_token))
+ if (current_token.is_ident("auto"sv))
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_auto());
- if (is_span(current_token))
+ if (current_token.is_ident("span"sv))
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_span(1));
if (is_valid_integer(current_token))
- return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_line(static_cast(current_token.number_value()), {}));
+ return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_line(static_cast(current_token.token().number_value()), {}));
if (is_identifier(current_token)) {
- auto maybe_string = String::from_utf8(current_token.ident());
+ auto maybe_string = String::from_utf8(current_token.token().ident());
if (!maybe_string.is_error())
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_line({}, maybe_string.value()));
}
@@ -5391,9 +5381,9 @@ RefPtr Parser::parse_grid_track_placement(Vector con
auto span_or_position_value = 0;
String identifier_value;
while (true) {
- if (is_auto(current_token))
+ if (current_token.is_ident("auto"sv))
return nullptr;
- if (is_span(current_token)) {
+ if (current_token.is_ident("span"sv)) {
if (span_value == false)
span_value = true;
else
@@ -5401,13 +5391,13 @@ RefPtr Parser::parse_grid_track_placement(Vector con
}
if (is_valid_integer(current_token)) {
if (span_or_position_value == 0)
- span_or_position_value = static_cast(current_token.number_value());
+ span_or_position_value = static_cast(current_token.token().number_value());
else
return nullptr;
}
if (is_identifier(current_token)) {
if (identifier_value.is_empty()) {
- auto maybe_string = String::from_utf8(current_token.ident());
+ auto maybe_string = String::from_utf8(current_token.token().ident());
if (maybe_string.is_error())
return nullptr;
identifier_value = maybe_string.release_value();
@@ -5417,7 +5407,7 @@ RefPtr Parser::parse_grid_track_placement(Vector con
}
tokens.skip_whitespace();
if (tokens.has_next_token())
- current_token = tokens.next_token().token();
+ current_token = tokens.next_token();
else
break;
}