LibWeb: Don't crash when encountering calc() inside a CSS rect() value

This allows us to run the WPT tests under quirks/unitless-length/
without crashing, giving us over 4600 new passing subtests. :^)
This commit is contained in:
Andreas Kling 2024-10-09 13:44:34 +02:00 committed by Tim Ledbetter
parent 5e240f997c
commit 5df6c6eecf
Notes: github-actions[bot] 2024-10-09 13:15:10 +00:00
3 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,10 @@
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: inline
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x0]
PaintableWithLines (BlockContainer<DIV>) [8,8 784x0]

View file

@ -0,0 +1,6 @@
<style>
div {
clip: rect(0, 0, 0, calc(2px));
}
</style>
<div>

View file

@ -2710,7 +2710,10 @@ RefPtr<CSSStyleValue> Parser::parse_rect_value(TokenStream<ComponentValue>& toke
auto maybe_length = parse_length(argument_tokens);
if (!maybe_length.has_value())
return nullptr;
// FIXME: Support calculated lengths
if (maybe_length.value().is_calculated()) {
dbgln("FIXME: Support calculated lengths in rect(): {}", maybe_length.value().calculated()->to_string());
return nullptr;
}
params.append(maybe_length.value().value());
}
argument_tokens.skip_whitespace();