mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +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:
parent
79d8b9ae75
commit
4e35bbffdd
14 changed files with 45 additions and 39 deletions
|
@ -62,18 +62,23 @@ public:
|
|||
|
||||
virtual LayoutNode& inline_wrapper() { return *this; }
|
||||
|
||||
const StyleProperties& style_properties() const { return m_style_properties; }
|
||||
const StyleProperties& style_properties() const
|
||||
{
|
||||
if (m_style_properties)
|
||||
return *m_style_properties;
|
||||
return parent()->style_properties();
|
||||
}
|
||||
|
||||
void inserted_into(LayoutNode&) {}
|
||||
void removed_from(LayoutNode&) {}
|
||||
|
||||
protected:
|
||||
explicit LayoutNode(const Node*, StyleProperties&&);
|
||||
explicit LayoutNode(const Node*, RefPtr<StyleProperties>);
|
||||
|
||||
private:
|
||||
const Node* m_node { nullptr };
|
||||
|
||||
StyleProperties m_style_properties;
|
||||
RefPtr<StyleProperties> m_style_properties;
|
||||
ComputedStyle m_style;
|
||||
Rect m_rect;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue