1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

LibWeb: Move rect-in-coordinate-space helper to Layout::Box

This commit is contained in:
Andreas Kling 2022-01-23 12:54:20 +01:00
parent 29589378ff
commit 83a6e698a0
2 changed files with 16 additions and 16 deletions

View file

@ -164,6 +164,20 @@ public:
virtual void before_children_paint(PaintContext&, PaintPhase) override;
virtual void after_children_paint(PaintContext&, PaintPhase) override;
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& ancestor_box)
{
auto rect = margin_box_as_relative_rect();
for (auto const* current = parent(); current; current = current->parent()) {
if (current == &ancestor_box)
break;
if (is<Box>(*current)) {
auto offset = static_cast<Box const&>(*current).effective_offset();
rect.translate_by(offset);
}
}
return rect;
}
protected:
Box(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
: NodeWithStyleAndBoxModelMetrics(document, node, move(style))