mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
LibHTML: Add a convenient way to get from any layout node to the root
This commit is contained in:
parent
2946b0e2d4
commit
715d7a8532
4 changed files with 31 additions and 0 deletions
|
@ -63,6 +63,26 @@ const Document& LayoutNode::document() const
|
|||
return node()->document();
|
||||
}
|
||||
|
||||
Document& LayoutNode::document()
|
||||
{
|
||||
if (is_anonymous())
|
||||
return parent()->document();
|
||||
// FIXME: Remove this const_cast once we give up on the idea of a const link from layout tree to DOM tree.
|
||||
return const_cast<Node*>(node())->document();
|
||||
}
|
||||
|
||||
const LayoutDocument& LayoutNode::root() const
|
||||
{
|
||||
ASSERT(document().layout_node());
|
||||
return *document().layout_node();
|
||||
}
|
||||
|
||||
LayoutDocument& LayoutNode::root()
|
||||
{
|
||||
ASSERT(document().layout_node());
|
||||
return *document().layout_node();
|
||||
}
|
||||
|
||||
void LayoutNode::split_into_lines(LayoutBlock& container)
|
||||
{
|
||||
for_each_child([&](auto& child) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue