ladybird/Libraries/LibHTML/Layout/LayoutDocument.cpp
Andreas Kling 4e35bbffdd LibHTML: LayoutText should always use parent's style properties
This patch makes StyleProperties heap-allocated and ref-counted so that
a LayoutNode can be without one. The ref-counting also allows anonymous
blocks to share style with their parent block.

LayoutText never needs a StyleProperties, since text always inherits
style from its parent element. This is handled by style_properties().
2019-10-04 12:12:39 +02:00

24 lines
568 B
C++

#include <LibHTML/Layout/LayoutDocument.h>
LayoutDocument::LayoutDocument(const Document& document, NonnullRefPtr<StyleProperties> style_properties)
: LayoutBlock(&document, move(style_properties))
{
}
LayoutDocument::~LayoutDocument()
{
}
void LayoutDocument::layout()
{
rect().set_width(style().size().width());
LayoutNode::layout();
int lowest_bottom = 0;
for_each_child([&](auto& child) {
if (child.rect().bottom() > lowest_bottom)
lowest_bottom = child.rect().bottom();
});
rect().set_bottom(lowest_bottom);
}