From e013306df841276392dfde199ddb110311f3df88 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 5 Sep 2023 12:04:00 +0200 Subject: [PATCH] LibWeb: Allow font-size: 0 Zero is a valid font-size value, and should result in no text being visible. We now match the behavior of other engines. --- Tests/LibWeb/Layout/expected/font-size-zero.txt | 14 ++++++++++++++ Tests/LibWeb/Layout/input/font-size-zero.html | 5 +++++ Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 3 +-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/font-size-zero.txt create mode 100644 Tests/LibWeb/Layout/input/font-size-zero.html diff --git a/Tests/LibWeb/Layout/expected/font-size-zero.txt b/Tests/LibWeb/Layout/expected/font-size-zero.txt new file mode 100644 index 0000000000..c3c51f660b --- /dev/null +++ b/Tests/LibWeb/Layout/expected/font-size-zero.txt @@ -0,0 +1,14 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x16 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x0 children: not-inline + BlockContainer
at (8,8) content-size 784x0 children: inline + line 0 width: 0, height: 0, bottom: 0, baseline: 0 + frag 0 from TextNode start: 0, length: 21, rect: [8,8 0x0] + "should not be visible" + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x16] + PaintableWithLines (BlockContainer) [8,8 784x0] + PaintableWithLines (BlockContainer
) [8,8 784x0] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/font-size-zero.html b/Tests/LibWeb/Layout/input/font-size-zero.html new file mode 100644 index 0000000000..4a0aba6ab5 --- /dev/null +++ b/Tests/LibWeb/Layout/input/font-size-zero.html @@ -0,0 +1,5 @@ +
should not be visible diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index f65f4a66c2..2ac2ccebb5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -2223,8 +2223,7 @@ RefPtr StyleComputer::compute_font_for_style_values(DOM::Elemen } if (maybe_length.has_value()) { auto px = maybe_length.value().to_px(length_resolution_context).to_int(); - if (px != 0) - font_size_in_px = px; + font_size_in_px = px; } }