diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-27 15:29:00 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-27 18:16:08 +0200 |
commit | c49c036c840177bdd052a68cd99d39df06d79d70 (patch) | |
tree | d87f940267bb75ed39eb56a60793a3add6d66690 /Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | |
parent | 153370e7f4dd0b556f21c69ba346c99077e761d7 (diff) | |
download | serenity-c49c036c840177bdd052a68cd99d39df06d79d70.zip |
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. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting/PaintableBox.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 1f533ed309..007d884869 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -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; + } + 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 m_offset; + return offset; } Gfx::FloatRect PaintableBox::compute_absolute_rect() const |