mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
LibWeb: Compute containing block boxes once at start of layout
We now cache the containing block (box) once at the start of layout, which allows Layout::Node::containing_block() to return instantly instead of doing tree traversal. Removes a 0.7% profile item on Speedometer 3.
This commit is contained in:
parent
3b4a184f1a
commit
28d564197c
Notes:
github-actions[bot]
2025-04-18 23:15:12 +00:00
Author: https://github.com/awesomekling
Commit: 28d564197c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4400
4 changed files with 32 additions and 17 deletions
|
@ -127,8 +127,10 @@ public:
|
|||
bool is_grid_item() const { return m_is_grid_item; }
|
||||
void set_grid_item(bool b) { m_is_grid_item = b; }
|
||||
|
||||
Box const* containing_block() const;
|
||||
Box* containing_block() { return const_cast<Box*>(const_cast<Node const*>(this)->containing_block()); }
|
||||
[[nodiscard]] GC::Ptr<Box const> containing_block() const { return m_containing_block; }
|
||||
[[nodiscard]] GC::Ptr<Box> containing_block() { return m_containing_block; }
|
||||
|
||||
void recompute_containing_block(Badge<DOM::Document>);
|
||||
|
||||
[[nodiscard]] Box const* static_position_containing_block() const;
|
||||
[[nodiscard]] Box* static_position_containing_block() { return const_cast<Box*>(const_cast<Node const*>(this)->static_position_containing_block()); }
|
||||
|
@ -200,6 +202,8 @@ private:
|
|||
GC::Ref<DOM::Node> m_dom_node;
|
||||
PaintableList m_paintable;
|
||||
|
||||
GC::Ptr<Box> m_containing_block;
|
||||
|
||||
GC::Ptr<DOM::Element> m_pseudo_element_generator;
|
||||
|
||||
bool m_anonymous { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue