
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().
24 lines
568 B
C++
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);
|
|
}
|