1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

LibWeb: Stop putting the FormattingState nodes in a slow hash map

Instead, put them in a Vector<OwnPtr<NodeState>>. Each layout node
has a unique index into the vector. It's a simple serial ID assigned
during layout tree construction. Every new layout restarts the sequence
at 0 for the next ICB.

This is a huge layout speed improvement on all content.
This commit is contained in:
Andreas Kling 2022-07-11 17:12:58 +02:00
parent f6a97ff7d5
commit 0cacaf025d
6 changed files with 45 additions and 45 deletions

View file

@ -606,11 +606,13 @@ void Document::update_layout()
auto viewport_rect = browsing_context()->viewport_rect();
if (!m_layout_root) {
m_next_layout_node_serial_id = 0;
Layout::TreeBuilder tree_builder;
m_layout_root = static_ptr_cast<Layout::InitialContainingBlock>(tree_builder.build(*this));
}
Layout::FormattingState formatting_state;
formatting_state.nodes.resize(layout_node_count());
Layout::BlockFormattingContext root_formatting_context(formatting_state, *m_layout_root, nullptr);
auto& icb = static_cast<Layout::InitialContainingBlock&>(*m_layout_root);

View file

@ -61,6 +61,9 @@ public:
virtual ~Document() override;
size_t next_layout_node_serial_id(Badge<Layout::Node>) { return m_next_layout_node_serial_id++; }
size_t layout_node_count() const { return m_next_layout_node_serial_id; }
String cookie(Cookie::Source = Cookie::Source::NonHttp);
void set_cookie(String const&, Cookie::Source = Cookie::Source::NonHttp);
@ -391,6 +394,8 @@ private:
unsigned m_referencing_node_count { 0 };
size_t m_next_layout_node_serial_id { 0 };
OwnPtr<CSS::StyleComputer> m_style_computer;
RefPtr<CSS::StyleSheetList> m_style_sheets;
RefPtr<Node> m_hovered_node;