From 1b55ff6f4ca7940bc65ce860644e146ce9d2a573 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 19 Jun 2023 13:30:57 +0200 Subject: [PATCH] LibWeb: Expand CSS var() inside calc() paren blocks Before this change, this var() would get expanded: calc(10px * var(--one)) But this one would not: calc(10px * (var(--one)) --- Tests/LibWeb/Layout/expected/css-var-in-calc-block.txt | 4 ++++ Tests/LibWeb/Layout/input/css-var-in-calc-block.html | 10 ++++++++++ Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 10 ++++++++++ 3 files changed, 24 insertions(+) create mode 100644 Tests/LibWeb/Layout/expected/css-var-in-calc-block.txt create mode 100644 Tests/LibWeb/Layout/input/css-var-in-calc-block.html diff --git a/Tests/LibWeb/Layout/expected/css-var-in-calc-block.txt b/Tests/LibWeb/Layout/expected/css-var-in-calc-block.txt new file mode 100644 index 0000000000..b9395176a4 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/css-var-in-calc-block.txt @@ -0,0 +1,4 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x270 [BFC] children: not-inline + BlockContainer at (10,10) content-size 780x252 children: not-inline + BlockContainer
at (11,11) content-size 250x250 children: not-inline diff --git a/Tests/LibWeb/Layout/input/css-var-in-calc-block.html b/Tests/LibWeb/Layout/input/css-var-in-calc-block.html new file mode 100644 index 0000000000..8dec5dcb0f --- /dev/null +++ b/Tests/LibWeb/Layout/input/css-var-in-calc-block.html @@ -0,0 +1,10 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 0ed1d65533..c794fa2902 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -836,6 +836,16 @@ bool StyleComputer::expand_variables(DOM::Element& element, Optional block_values; + Parser::TokenStream source_block_contents { source_block.values() }; + if (!expand_variables(element, pseudo_element, property_name, dependencies, source_block_contents, block_values)) + return false; + NonnullRefPtr block = Parser::Block::create(source_block.token(), move(block_values)); + dest.empend(block); + continue; + } if (!value.is_function()) { dest.empend(value); continue;