LibWeb: Improve list item marker positioning and alpha/roman text

This commit is a three-parter that is hard to separate without breaking
marker rendering:

  1. Any marker style that results in a string, except for a literal
     string (e.g. `list-style-type: "@"`), should get the string ". "
     appended. We forgot to do this for the alpha and roman types.

  2. Instead of using the "pixel size rounded up" from a font and adding
     an arbitrary 1 to that, we now use the exact pixel size for as long
     as possible to improve our vertical positioning of markers.

  3. Instead of always adding a "default marker width" to the marker
     content width, we now only do this if we did not have text metrics
     available (i.e. the marker style is not a text type). This greatly
     improves horizontal positioning of text markers.
This commit is contained in:
Jelle Raaijmakers 2025-07-15 13:37:13 +02:00 committed by Sam Atkins
commit 788d5368a7
Notes: github-actions[bot] 2025-07-15 18:06:51 +00:00
26 changed files with 152 additions and 129 deletions

View file

@ -9,7 +9,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
ListItemBox <(anonymous)> at (24,26) content-size 768x18 children: inline
frag 0 from TextNode start: 0, length: 11, rect: [24,26 88.703125x18] baseline: 13.796875
"Filler Text"
ListItemMarkerBox <(anonymous)> at (0,26.5) content-size 12x17 children: not-inline
ListItemMarkerBox <(anonymous)> at (0,27) content-size 12x16 children: not-inline
TextNode <#text>
BlockContainer <(anonymous)> at (8,44) content-size 784x0 children: inline
TextNode <#text>
@ -21,7 +21,7 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x18]
TextPaintable (TextNode<#text>)
PaintableWithLines (ListItemBox(anonymous)) [24,26 768x18]
MarkerPaintable (ListItemMarkerBox(anonymous)) [0,26.5 12x17]
MarkerPaintable (ListItemMarkerBox(anonymous)) [0,27 12x16]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [8,44 784x0]