mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:08:10 +00:00
LibWeb: Add Painting::Box and move things from Layout::Box into it
The "paintable" state in Layout::Box was actually not safe to access until after layout had been performed. As a first step towards making this harder to mess up accidentally, this patch moves painting information from Layout::Box to a new class: Painting::Box. Every layout can have a corresponding paint box, and it holds the final used metrics determined by layout. The paint box is created and populated by FormattingState::commit(). I've also added DOM::Node::paint_box() as a convenient way to access the paint box (if available) of a given DOM node. Going forward, I believe this will allow us to better separate data that belongs to layout vs painting, and also open up opportunities for naturally invalidating caches in the paint box (since it's reconstituted by every layout.)
This commit is contained in:
parent
db404af6df
commit
a4d51b3dc2
35 changed files with 365 additions and 293 deletions
|
@ -1010,4 +1010,13 @@ size_t Node::length() const
|
|||
return child_count();
|
||||
}
|
||||
|
||||
Painting::Box const* Node::paint_box() const
|
||||
{
|
||||
if (!layout_node())
|
||||
return nullptr;
|
||||
if (!layout_node()->is_box())
|
||||
return nullptr;
|
||||
return static_cast<Layout::Box const&>(*layout_node()).m_paint_box;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue