From 755d938498cee759aad4aed98e8c457fc5176284 Mon Sep 17 00:00:00 2001 From: Kostya Farber Date: Sun, 27 Oct 2024 13:13:48 +0000 Subject: [PATCH] LibWeb: Add word spacing to tab size correctly We should be adding the computed value for word spacing not letter spacing twice. --- .../Layout/expected/tab-size-spacing-001.txt | 24 +++++++++++++ .../Layout/input/tab-size-spacing-001.html | 34 +++++++++++++++++++ .../LibWeb/Layout/InlineLevelIterator.cpp | 2 +- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/tab-size-spacing-001.txt create mode 100644 Tests/LibWeb/Layout/input/tab-size-spacing-001.html diff --git a/Tests/LibWeb/Layout/expected/tab-size-spacing-001.txt b/Tests/LibWeb/Layout/expected/tab-size-spacing-001.txt new file mode 100644 index 000000000000..bfed282d3177 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/tab-size-spacing-001.txt @@ -0,0 +1,24 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x39 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x23 children: not-inline + BlockContainer at (186,10) content-size 16x16 positioned [BFC] children: not-inline + BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline + TextNode <#text> + BlockContainer at (8,8) content-size 784x23 children: inline + frag 0 from TextNode start: 0, length: 1, rect: [8,17 148x14] baseline: 10.890625 + " " + frag 1 from BlockContainer start: 0, length: 0, rect: [156,8 20x20] baseline: 20 + TextNode <#text> + BlockContainer at (156,8) content-size 20x20 inline-block [BFC] children: not-inline + BlockContainer <(anonymous)> at (8,31) content-size 784x0 children: inline + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x39] + PaintableWithLines (BlockContainer) [8,8 784x23] + PaintableWithLines (BlockContainer
.ref) [184,8 20x20] + PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0] + PaintableWithLines (BlockContainer
.test) [8,8 784x23] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer) [156,8 20x20] + PaintableWithLines (BlockContainer(anonymous)) [8,31 784x0] diff --git a/Tests/LibWeb/Layout/input/tab-size-spacing-001.html b/Tests/LibWeb/Layout/input/tab-size-spacing-001.html new file mode 100644 index 000000000000..77f1e4b0d23f --- /dev/null +++ b/Tests/LibWeb/Layout/input/tab-size-spacing-001.html @@ -0,0 +1,34 @@ + + + +
+
diff --git a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp index 4e630da7b322..cc683b65f448 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp @@ -266,7 +266,7 @@ Optional InlineLevelIterator::next_without_lookahead( auto computed_word_spacing = text_node.computed_values().word_spacing(); auto letter_spacing = computed_letter_spacing.resolved(resolution_context).to_px(text_node); - auto word_spacing = computed_letter_spacing.resolved(resolution_context).to_px(text_node); + auto word_spacing = computed_word_spacing.resolved(resolution_context).to_px(text_node); return CSSPixels::nearest_value_for(tab_number * (chunk.font->glyph_width(' ') + word_spacing.to_float() + letter_spacing.to_float())); });