mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Defer invalidation sets processing until update_style()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This change converts `Node::invalidate_style()` (invalidation sets overload) from eagerly doing tree traversal that marks elements affected by invalidation set to instead adding "pending invalidation sets" into `StyleInvalidator`, processing of which is deferred until the next `update_style()`. By doing that we sometimes substantially reduce amount of work done performing tree traversal that marks elements for style recalculation. Improves performance on Discord, were according to my measurements we were previously spending 20% of time in style invalidation, but now it's down to <1%.
This commit is contained in:
parent
8cbe27b2f9
commit
b0ef7f4427
Notes:
github-actions[bot]
2025-07-16 22:44:27 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: b0ef7f4427
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5474
6 changed files with 82 additions and 18 deletions
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibWeb/CSS/InvalidationSet.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
@ -16,7 +17,23 @@ class StyleInvalidator : public GC::Cell {
|
|||
GC_DECLARE_ALLOCATOR(StyleInvalidator);
|
||||
|
||||
public:
|
||||
void invalidate(Node& node);
|
||||
void add_pending_invalidation(GC::Ref<Node>, CSS::InvalidationSet&&, bool invalidate_elements_that_use_css_custom_properties);
|
||||
bool has_pending_invalidations() const { return !m_pending_invalidations.is_empty(); }
|
||||
|
||||
virtual void visit_edges(Cell::Visitor& visitor) override;
|
||||
|
||||
private:
|
||||
void perform_pending_style_invalidations(Node& node, bool invalidate_entire_subtree);
|
||||
|
||||
struct PendingInvalidation {
|
||||
bool invalidate_elements_that_use_css_custom_properties { false };
|
||||
CSS::InvalidationSet invalidation_set;
|
||||
};
|
||||
HashMap<GC::Ref<Node>, PendingInvalidation> m_pending_invalidations;
|
||||
|
||||
Vector<CSS::InvalidationSet> m_subtree_invalidation_sets;
|
||||
bool m_invalidate_elements_that_use_css_custom_properties { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue