mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 04:13:11 +00:00
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))
This commit is contained in:
parent
ce2b88e7cc
commit
1b55ff6f4c
4
Tests/LibWeb/Layout/expected/css-var-in-calc-block.txt
Normal file
4
Tests/LibWeb/Layout/expected/css-var-in-calc-block.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (1,1) content-size 798x270 [BFC] children: not-inline
|
||||
BlockContainer <body> at (10,10) content-size 780x252 children: not-inline
|
||||
BlockContainer <div> at (11,11) content-size 250x250 children: not-inline
|
10
Tests/LibWeb/Layout/input/css-var-in-calc-block.html
Normal file
10
Tests/LibWeb/Layout/input/css-var-in-calc-block.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
<!doctype html><style>
|
||||
* {
|
||||
border: 1px solid black;
|
||||
}
|
||||
div {
|
||||
--five: 5;
|
||||
width: calc(50px * (var(--five)));
|
||||
height: calc(50px * (0 + var(--five)));
|
||||
}
|
||||
</style><div>
|
|
@ -836,6 +836,16 @@ bool StyleComputer::expand_variables(DOM::Element& element, Optional<CSS::Select
|
|||
|
||||
while (source.has_next_token()) {
|
||||
auto const& value = source.next_token();
|
||||
if (value.is_block()) {
|
||||
auto const& source_block = value.block();
|
||||
Vector<Parser::ComponentValue> 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<Parser::Block> block = Parser::Block::create(source_block.token(), move(block_values));
|
||||
dest.empend(block);
|
||||
continue;
|
||||
}
|
||||
if (!value.is_function()) {
|
||||
dest.empend(value);
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue