LibWeb: Propagate margin and offset when computing a box's baseline

When traversing the layout tree to find an appropriate box child to
derive the baseline from. Only the child's margin and offset was being
applied. Now we sum each offset on the recursive call.
This commit is contained in:
BenJilks 2024-07-15 16:07:06 +01:00 committed by Andreas Kling
commit 3c897e7cf3
Notes: sideshowbarker 2024-07-16 17:12:03 +09:00
32 changed files with 134 additions and 80 deletions

View file

@ -1886,7 +1886,7 @@ CSSPixels FormattingContext::box_baseline(Box const& box) const
if (!box_state.line_boxes.is_empty())
return box_state.margin_box_top() + box_state.offset.y() + box_state.line_boxes.last().baseline();
if (auto const* child_box = box_child_to_derive_baseline_from(box)) {
return box_baseline(*child_box);
return box_state.margin_box_top() + box_state.offset.y() + box_baseline(*child_box);
}
// If none of the children have a baseline set, the bottom margin edge of the box is used.
return box_state.margin_box_height();