LibWeb: Account for x-axis in static position for inline items

..and delay static position calculation in IFC until trailing
whitespace are removed, because otherwise it's not possible to correctly
calculate x offset.
This commit is contained in:
Aliaksandr Kalenik 2024-09-21 19:46:37 +02:00 committed by Andreas Kling
commit 91b2cd7d31
Notes: github-actions[bot] 2024-09-21 18:11:42 +00:00
4 changed files with 69 additions and 2 deletions

View file

@ -260,6 +260,8 @@ void InlineFormattingContext::generate_line_boxes()
// axis, so that we can add it to the first non-whitespace chunk.
CSSPixels leading_margin_from_collapsible_whitespace = 0;
Vector<Box const*> absolute_boxes;
for (;;) {
auto item_opt = iterator.next();
if (!item_opt.has_value())
@ -307,8 +309,8 @@ void InlineFormattingContext::generate_line_boxes()
case InlineLevelIterator::Item::Type::AbsolutelyPositionedElement:
if (is<Box>(*item.node)) {
auto const& box = static_cast<Layout::Box const&>(*item.node);
auto& box_state = m_state.get_mutable(box);
box_state.set_static_position_rect(calculate_static_position_rect(box));
// Calculation of static position for absolute boxes is delayed until trailing whitespaces are removed.
absolute_boxes.append(&box);
}
break;
@ -410,6 +412,11 @@ void InlineFormattingContext::generate_line_boxes()
apply_justification_to_fragments(text_justify, line_box, is_last_line);
}
}
for (auto* box : absolute_boxes) {
auto& box_state = m_state.get_mutable(*box);
box_state.set_static_position_rect(calculate_static_position_rect(*box));
}
}
bool InlineFormattingContext::any_floats_intrude_at_y(CSSPixels y) const