mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:57:42 +00:00
LibWeb: Resolve relative offsets *once* after layout
Instead of applying relative offsets (like position:relative insets) during painting and hit testing, we now do a pass at the end of layout and assign the final resolved offsets to paintables. This makes painting and hit testing easier since they don't have to think about relative offsets, and it also fixes a bug where offsets were not applied to text fragments inside inline-flow elements that were themselves position:relative.
This commit is contained in:
parent
481fdfee68
commit
25a3d0d643
6 changed files with 117 additions and 24 deletions
|
@ -117,19 +117,7 @@ void PaintableBox::set_content_size(CSSPixelSize size)
|
|||
|
||||
CSSPixelPoint PaintableBox::effective_offset() const
|
||||
{
|
||||
CSSPixelPoint offset;
|
||||
if (containing_block() && m_containing_line_box_fragment.has_value()) {
|
||||
auto& paintable_with_lines = *verify_cast<PaintableWithLines>(containing_block()->paintable_box());
|
||||
auto const& fragment = paintable_with_lines.line_boxes()[m_containing_line_box_fragment->line_box_index].fragments()[m_containing_line_box_fragment->fragment_index];
|
||||
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 offset;
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
CSSPixelRect PaintableBox::compute_absolute_rect() const
|
||||
|
@ -176,11 +164,6 @@ CSSPixelRect PaintableBox::absolute_paint_rect() const
|
|||
return *m_absolute_paint_rect;
|
||||
}
|
||||
|
||||
void PaintableBox::set_containing_line_box_fragment(Optional<Layout::LineBoxFragmentCoordinate> fragment_coordinate)
|
||||
{
|
||||
m_containing_line_box_fragment = move(fragment_coordinate);
|
||||
}
|
||||
|
||||
StackingContext* PaintableBox::enclosing_stacking_context()
|
||||
{
|
||||
for (auto* ancestor = layout_box().parent(); ancestor; ancestor = ancestor->parent()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue