1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:37:35 +00:00

LibWeb: Don't assume repeat() contents are Tokens

This stops `grid-template-rows: repeat({})` from crashing.
This commit is contained in:
Sam Atkins 2023-11-21 11:40:10 +00:00 committed by Andreas Kling
parent 5e54ff1858
commit 1f6e13d8fe
3 changed files with 18 additions and 5 deletions

View file

@ -0,0 +1,12 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x0 children: not-inline
BlockContainer <div> 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<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x0] overflow: [8,16 784x0]
PaintableWithLines (BlockContainer<DIV>) [8,8 784x0]
PaintableWithLines (BlockContainer(anonymous)) [8,16 784x0]

View file

@ -0,0 +1 @@
<div style="grid-template-rows: repeat({})"></div>

View file

@ -5102,14 +5102,14 @@ Optional<CSS::GridRepeat> Parser::parse_repeat(Vector<ComponentValue> const& com
part_one_tokens.skip_whitespace();
if (!part_one_tokens.has_next_token())
return {};
auto current_token = part_one_tokens.next_token().token();
auto& current_token = part_one_tokens.next_token();
auto repeat_count = 0;
if (current_token.is(Token::Type::Number) && current_token.number().is_integer() && current_token.number_value() > 0)
repeat_count = current_token.number_value();
else if (current_token.is(Token::Type::Ident) && current_token.ident().equals_ignoring_ascii_case("auto-fill"sv))
if (current_token.is(Token::Type::Number) && current_token.token().number().is_integer() && current_token.token().number_value() > 0)
repeat_count = current_token.token().number_value();
else if (current_token.is_ident("auto-fill"sv))
is_auto_fill = true;
else if (current_token.is(Token::Type::Ident) && current_token.ident().equals_ignoring_ascii_case("auto-fit"sv))
else if (current_token.is_ident("auto-fit"sv))
is_auto_fit = true;
// The second argument is a track list, which is repeated that number of times.