1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:08:10 +00:00

LibWeb: Stop allowing position:relative to affect layout

Relatively positioned boxes should not affect the *layout* of their
siblings. So instead of applying relative inset as a layout-time
translation on the box, we now perform the adjustment at the paintable
level instead.

This makes position:relative actually work as expected, and exposes some
new bugs we need to take care of for Acid2. :^)
This commit is contained in:
Andreas Kling 2022-03-27 15:29:00 +02:00
parent 153370e7f4
commit c49c036c84
2 changed files with 12 additions and 6 deletions

View file

@ -59,11 +59,18 @@ void PaintableBox::set_content_size(Gfx::FloatSize const& size)
Gfx::FloatPoint PaintableBox::effective_offset() const
{
Gfx::FloatPoint offset;
if (m_containing_line_box_fragment.has_value()) {
auto const& fragment = containing_block()->paint_box()->line_boxes()[m_containing_line_box_fragment->line_box_index].fragments()[m_containing_line_box_fragment->fragment_index];
return fragment.offset();
offset = fragment.offset();
} else {
offset = m_offset;
}
return m_offset;
if (layout_box().computed_values().position() == CSS::Position::Relative) {
auto const& inset = layout_box().box_model().inset;
offset.translate_by(inset.left, inset.top);
}
return offset;
}
Gfx::FloatRect PaintableBox::compute_absolute_rect() const