mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 12:06:07 +00:00
LibWeb: Always run layout and style updates from event loop processing
Before this change, we ran style and layout updates from both event loop processing and update timers. This could have caused missed resize observer updates and unnecessary updating of style or layout more than once before repaint. Also, we can now be sure unnecessary style or layout updates won't happen in `EventLoop::spin_processing_tasks_with_source_until()`.
This commit is contained in:
parent
e09816c37c
commit
96d67ded3e
Notes:
sideshowbarker
2024-07-16 23:44:30 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 96d67ded3e
Pull-request: https://github.com/SerenityOS/serenity/pull/23652
Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 4 additions and 19 deletions
|
@ -356,14 +356,6 @@ Document::Document(JS::Realm& realm, const URL::URL& url)
|
|||
};
|
||||
|
||||
HTML::main_thread_event_loop().register_document({}, *this);
|
||||
|
||||
m_style_update_timer = Core::Timer::create_single_shot(0, [this] {
|
||||
update_style();
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_layout_update_timer = Core::Timer::create_single_shot(0, [this] {
|
||||
update_layout();
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Document::~Document()
|
||||
|
@ -681,16 +673,14 @@ void Document::set_origin(HTML::Origin const& origin)
|
|||
|
||||
void Document::schedule_style_update()
|
||||
{
|
||||
if (m_style_update_timer->is_active())
|
||||
return;
|
||||
m_style_update_timer->start();
|
||||
// NOTE: Update of the style is a step in HTML event loop processing.
|
||||
HTML::main_thread_event_loop().schedule();
|
||||
}
|
||||
|
||||
void Document::schedule_layout_update()
|
||||
{
|
||||
if (m_layout_update_timer->is_active())
|
||||
return;
|
||||
m_layout_update_timer->start();
|
||||
// NOTE: Update of the layout is a step in HTML event loop processing.
|
||||
HTML::main_thread_event_loop().schedule();
|
||||
}
|
||||
|
||||
bool Document::is_child_allowed(Node const& node) const
|
||||
|
@ -1113,7 +1103,6 @@ void Document::update_layout()
|
|||
paintable()->recompute_selection_states();
|
||||
|
||||
m_needs_layout = false;
|
||||
m_layout_update_timer->stop();
|
||||
}
|
||||
|
||||
[[nodiscard]] static CSS::RequiredInvalidationAfterStyleChange update_style_recursively(Node& node)
|
||||
|
@ -1196,7 +1185,6 @@ void Document::update_style()
|
|||
invalidate_stacking_context_tree();
|
||||
}
|
||||
m_needs_full_style_update = false;
|
||||
m_style_update_timer->stop();
|
||||
}
|
||||
|
||||
void Document::update_paint_and_hit_testing_properties_if_needed()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue