mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibWeb: Skip :has() invalidation in update_style when nothing is pending
Add a document-level boolean flag that tracks whether any :has() invalidations have been scheduled. This avoids iterating over all shadow roots just to check is_empty() on each style scope when no :has() invalidations are pending, which is the common case during scrolling on complex pages like Reddit. Results in ~10% reduction of is_empty() calls in profiles when scrolling on Reddit.
This commit is contained in:
committed by
Alexander Kalenik
parent
38e53b5600
commit
eea9837438
Notes:
github-actions[bot]
2026-02-10 23:30:01 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/eea98374386 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7872
@@ -1690,10 +1690,13 @@ void Document::update_style()
|
||||
// style change event. [CSS-Transitions-2]
|
||||
m_transition_generation++;
|
||||
|
||||
style_scope().invalidate_style_of_elements_affected_by_has();
|
||||
for_each_shadow_root([&](auto& shadow_root) {
|
||||
shadow_root.style_scope().invalidate_style_of_elements_affected_by_has();
|
||||
});
|
||||
if (m_needs_invalidation_of_elements_affected_by_has) {
|
||||
m_needs_invalidation_of_elements_affected_by_has = false;
|
||||
style_scope().invalidate_style_of_elements_affected_by_has();
|
||||
for_each_shadow_root([&](auto& shadow_root) {
|
||||
shadow_root.style_scope().invalidate_style_of_elements_affected_by_has();
|
||||
});
|
||||
}
|
||||
|
||||
if (!m_style_invalidator->has_pending_invalidations() && !needs_full_style_update() && !needs_style_update() && !child_needs_style_update())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user