diff --git a/Tests/LibWeb/Layout/expected/css-attr-typed-fallback.txt b/Tests/LibWeb/Layout/expected/css-attr-typed-fallback.txt index bfe762ec2c..cde1b6a4eb 100644 --- a/Tests/LibWeb/Layout/expected/css-attr-typed-fallback.txt +++ b/Tests/LibWeb/Layout/expected/css-attr-typed-fallback.txt @@ -1,6 +1,6 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline - BlockContainer at (0,0) content-size 800x126 [BFC] children: not-inline - BlockContainer at (8,8) content-size 784x110 children: not-inline + BlockContainer at (0,0) content-size 800x148 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x132 children: not-inline BlockContainer at (9,9) content-size 100x20 children: inline InlineNode <(anonymous)> frag 0 from TextNode start: 0, length: 4, rect: [9,9 41.53125x17] baseline: 13.296875 @@ -8,31 +8,39 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline TextNode <#text> BlockContainer <(anonymous)> at (8,30) content-size 784x0 children: inline TextNode <#text> - BlockContainer at (9,31) content-size 200x20 children: not-inline + BlockContainer at (9,31) content-size 100x20 children: inline + InlineNode <(anonymous)> + TextNode <#text> BlockContainer <(anonymous)> at (8,52) content-size 784x0 children: inline TextNode <#text> - BlockContainer at (9,53) content-size 200x20 children: not-inline + BlockContainer at (9,53) content-size 200x20 children: not-inline BlockContainer <(anonymous)> at (8,74) content-size 784x0 children: inline TextNode <#text> - BlockContainer at (9,75) content-size 100x20 children: not-inline + BlockContainer at (9,75) content-size 200x20 children: not-inline BlockContainer <(anonymous)> at (8,96) content-size 784x0 children: inline TextNode <#text> BlockContainer at (9,97) content-size 100x20 children: not-inline BlockContainer <(anonymous)> at (8,118) content-size 784x0 children: inline TextNode <#text> + BlockContainer at (9,119) content-size 100x20 children: not-inline + BlockContainer <(anonymous)> at (8,140) content-size 784x0 children: inline + TextNode <#text> ViewportPaintable (Viewport<#document>) [0,0 800x600] - PaintableWithLines (BlockContainer) [0,0 800x126] - PaintableWithLines (BlockContainer) [8,8 784x110] + PaintableWithLines (BlockContainer) [0,0 800x148] + PaintableWithLines (BlockContainer) [8,8 784x132] PaintableWithLines (BlockContainer
.string) [8,8 102x22] InlinePaintable (InlineNode(anonymous)) TextPaintable (TextNode<#text>) PaintableWithLines (BlockContainer(anonymous)) [8,30 784x0] - PaintableWithLines (BlockContainer
.length) [8,30 202x22] + PaintableWithLines (BlockContainer
.string-no-fallback) [8,30 102x22] + InlinePaintable (InlineNode(anonymous)) PaintableWithLines (BlockContainer(anonymous)) [8,52 784x0] - PaintableWithLines (BlockContainer
.px) [8,52 202x22] + PaintableWithLines (BlockContainer
.length) [8,52 202x22] PaintableWithLines (BlockContainer(anonymous)) [8,74 784x0] - PaintableWithLines (BlockContainer
.color) [8,74 102x22] + PaintableWithLines (BlockContainer
.px) [8,74 202x22] PaintableWithLines (BlockContainer(anonymous)) [8,96 784x0] PaintableWithLines (BlockContainer
.color) [8,96 102x22] PaintableWithLines (BlockContainer(anonymous)) [8,118 784x0] + PaintableWithLines (BlockContainer
.color) [8,118 102x22] + PaintableWithLines (BlockContainer(anonymous)) [8,140 784x0] diff --git a/Tests/LibWeb/Layout/input/css-attr-typed-fallback.html b/Tests/LibWeb/Layout/input/css-attr-typed-fallback.html index 56f4e90676..949b020c7e 100644 --- a/Tests/LibWeb/Layout/input/css-attr-typed-fallback.html +++ b/Tests/LibWeb/Layout/input/css-attr-typed-fallback.html @@ -9,6 +9,9 @@ .string::before { content: attr(foo string, "WHF!"); } + .string-no-fallback::before { + content: attr(foo string); + } .length { width: attr(foo length, 200px); } @@ -20,6 +23,7 @@ }
+
diff --git a/Tests/LibWeb/Ref/css-attr-typed-fallback.html b/Tests/LibWeb/Ref/css-attr-typed-fallback.html index 56f4e90676..949b020c7e 100644 --- a/Tests/LibWeb/Ref/css-attr-typed-fallback.html +++ b/Tests/LibWeb/Ref/css-attr-typed-fallback.html @@ -9,6 +9,9 @@ .string::before { content: attr(foo string, "WHF!"); } + .string-no-fallback::before { + content: attr(foo string); + } .length { width: attr(foo length, 200px); } @@ -20,6 +23,7 @@ }
+
diff --git a/Tests/LibWeb/Ref/css-attr-typed.html b/Tests/LibWeb/Ref/css-attr-typed.html index 469e1186bb..58ee1944fd 100644 --- a/Tests/LibWeb/Ref/css-attr-typed.html +++ b/Tests/LibWeb/Ref/css-attr-typed.html @@ -20,6 +20,7 @@ }
+
diff --git a/Tests/LibWeb/Ref/reference/css-attr-typed-ref.html b/Tests/LibWeb/Ref/reference/css-attr-typed-ref.html index cefc680839..9e014c4791 100644 --- a/Tests/LibWeb/Ref/reference/css-attr-typed-ref.html +++ b/Tests/LibWeb/Ref/reference/css-attr-typed-ref.html @@ -16,6 +16,7 @@ }
WHF!
+
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 1c2d7e47b1..8f34b3975c 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -7450,6 +7450,12 @@ bool Parser::substitute_attr_function(DOM::Element& element, FlyString const& pr if (has_fallback_values) return expand_unresolved_values(element, property_name, attr_contents, dest); + if (attribute_type.equals_ignoring_ascii_case("string"_fly_string)) { + // If the argument is string, defaults to the empty string if omitted + dest.empend(Token::create_string({})); + return true; + } + // 3. Otherwise, the property containing the attr() function is invalid at computed-value time. return false; }