1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 22:15:06 +00:00

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().
This commit is contained in:
Andreas Kling 2019-10-04 12:12:39 +02:00
parent 79d8b9ae75
commit 4e35bbffdd
14 changed files with 45 additions and 39 deletions

View file

@ -3,7 +3,7 @@
#include <LibHTML/Layout/LayoutBlock.h>
#include <LibHTML/Layout/LayoutInline.h>
LayoutBlock::LayoutBlock(const Node* node, StyleProperties&& style_properties)
LayoutBlock::LayoutBlock(const Node* node, NonnullRefPtr<StyleProperties> style_properties)
: LayoutNode(node, move(style_properties))
{
}
@ -15,7 +15,7 @@ LayoutBlock::~LayoutBlock()
LayoutNode& LayoutBlock::inline_wrapper()
{
if (!last_child() || !last_child()->is_block() || last_child()->node() != nullptr) {
append_child(adopt(*new LayoutBlock(nullptr, {})));
append_child(adopt(*new LayoutBlock(nullptr, style_properties())));
}
return *last_child();
}