Open pavpanchekha opened 1 week ago
I'm going to try to poke around and see if I can figure this out.
First hint, this FIXME in BlockFormattingContext::compute_auto_height_for_block_level_element
:
FIXME: This is hack. If the last child is a list-item marker box, we ignore it for purposes of height calculation. Perhaps markers should not be considered in-flow(?) Perhaps they should always be the first child of the list-item box instead of the last child.
The marker is indeed the last child, which is pretty weird, but I guess I'm still looking for the layout code itself.
Here's the code handling inside position:
if (marker.list_style_position() == CSS::ListStylePosition::Inside) {
list_item_state.set_content_offset({ final_marker_width, list_item_state.offset.y() });
list_item_state.set_content_width(list_item_state.content_width() - final_marker_width);
}
This doesn't make a lot of sense to me and seems more like the Outside
behavior. I'll keep digging.
Ok, I do think this is the guilty line of code. I think a fix would look like this:
ListItemMarker
's location in its parent depends on its position
, remember to invalidate the layout tree if the position
changes; it's probably better to put it always at the front.Ok, a broader issue seems to be that ListItemBox
is a BlockContainer
, which is correct in general I think, but with list-style-position: inside
it seems to generate inline children too, which means we need to create an anonymous block box inside it first, to hold the marker. Seems to be what Chrome does (reverse engineering only, not looking at code). But if there's already an anonymous block box inside, then we want to stick our marker inside that.
Yeah I think unfortunately tree-building has to read the list item position. I did look and Blink does it this way too (it has different marker classes for the different list style positions).
I reduced a layout issue on https://herbie.uwplse.org/ to the following code block:
The Chrome rendering looks like this:
The
1rem
width is too small to fit the content, which forces the maximum number of line breaks. Because the list haslist-style-position: inside
, the marker (bullet) is the first inline box in the<li>
and therefore the first line is just the bullet and the second line is the word. Here's the standard text:Here's the Ladybird rendering:
It's not just a line breaking issue; if I add a second word to the HTML you get this: