From d5e3158cfe21ddc4eb5d8bd3360e4c63076ea98a Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 25 Jan 2024 18:09:38 +0100 Subject: [PATCH] LibWeb: Use PaintableFragment::baseline() in paint_text_decoration() No need to calculate baseline based on glyph height when we can get this information from a fragment. --- .../Ref/reference/images/text-decorations.png | Bin 0 -> 1788 bytes .../Ref/reference/text-decorations-ref.html | 9 ++++ Tests/LibWeb/Ref/text-decorations.html | 39 ++++++++++++++++++ .../LibWeb/Painting/PaintableBox.cpp | 2 +- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Ref/reference/images/text-decorations.png create mode 100644 Tests/LibWeb/Ref/reference/text-decorations-ref.html create mode 100644 Tests/LibWeb/Ref/text-decorations.html diff --git a/Tests/LibWeb/Ref/reference/images/text-decorations.png b/Tests/LibWeb/Ref/reference/images/text-decorations.png new file mode 100644 index 0000000000000000000000000000000000000000..6bcb8a514b4bc760d8be33941754f53d613e7966 GIT binary patch literal 1788 zcmeAS@N?(olHy`uVBq!ia0y~yU{+vYV2a>iU|?X_FMD?l0|VP(PZ!6Kid%2*D*9(< zO0-_o)z;RYICbjO6JAdyPMzwJqAFCWI%$4^s!(L7OIX;ow}L)KlXrf2n%0!CEL-!- zY#U2;kzK(Lf(w}hI5=2Xn3xzF8yp-I6a)k~Ko}}?px$J{A8tNhO& zO=8}ed%Jx}t>2{A+cuY4KV943trB^sdRoEC#xeJN%k+*NWt)_;Z-)Bvb(`&F)53G7y`AE`Jm*&4J$a*o#>SZR!o1&8WURd>-Q4zE z=e953+@kwsbN6-^E^N%%lyQ6h$>{Z)EA8gpPF{D*H_qzmvbQ$h^^Uc&6@8XF;a&71 zcU$i5WU;qa`g4t}zl$^$Y;1gUkJ<9xy?tLbBmFP;?@PV7?$e#!DfJeAenu+ABq-F@ z{doO+`O`;PUvD@+duw$5?d!aWk)K{9#bhbSTkhNX{P9cMS+8gBJ@2^VjKinhb9fp# zSn8gOaBss9N z!OflwbMU{9U8ztBM-;VgjWtIa_?Q@>hC|W_$Y2l#Cz}Ve*&apvIw(8TH6UMsFj^>K3O!=Ma5zSkC=gzsH1FF_MUHx3vIVCg!0IHbc?*IS* literal 0 HcmV?d00001 diff --git a/Tests/LibWeb/Ref/reference/text-decorations-ref.html b/Tests/LibWeb/Ref/reference/text-decorations-ref.html new file mode 100644 index 0000000000..340055c73b --- /dev/null +++ b/Tests/LibWeb/Ref/reference/text-decorations-ref.html @@ -0,0 +1,9 @@ + + diff --git a/Tests/LibWeb/Ref/text-decorations.html b/Tests/LibWeb/Ref/text-decorations.html new file mode 100644 index 0000000000..b69830f702 --- /dev/null +++ b/Tests/LibWeb/Ref/text-decorations.html @@ -0,0 +1,39 @@ + + + + + + + +

Hello

+

Hello

+

Hello

+

Hello

+

Hello

+ + diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 66b697d889..085a4df13b 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -505,7 +505,7 @@ void paint_text_decoration(PaintContext& context, Layout::Node const& text_node, auto& font = fragment.layout_node().first_available_font(); auto fragment_box = fragment.absolute_rect(); CSSPixels glyph_height = CSSPixels::nearest_value_for(font.pixel_size()); - auto baseline = fragment_box.height() / 2 - (glyph_height + 4) / 2 + glyph_height; + auto baseline = fragment.baseline(); auto line_color = text_node.computed_values().text_decoration_color();