mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 07:33:20 +00:00
LibWeb: Re-evaluate media queries only when things they depend on change
Before this change we were re-evaluating media queries on every frame which adds up in 1-4% in profiles on Discord.
This commit is contained in:
parent
3920194bca
commit
7a34bc2700
Notes:
github-actions[bot]
2025-08-05 15:26:02 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 7a34bc2700
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5722
Reviewed-by: https://github.com/gmta ✅
4 changed files with 17 additions and 3 deletions
|
@ -3412,12 +3412,17 @@ void Document::run_the_scroll_steps()
|
|||
|
||||
void Document::add_media_query_list(GC::Ref<CSS::MediaQueryList> media_query_list)
|
||||
{
|
||||
m_needs_media_query_evaluation = true;
|
||||
m_media_query_lists.append(*media_query_list);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes
|
||||
void Document::evaluate_media_queries_and_report_changes()
|
||||
{
|
||||
if (!m_needs_media_query_evaluation)
|
||||
return;
|
||||
m_needs_media_query_evaluation = false;
|
||||
|
||||
// NOTE: Not in the spec, but we take this opportunity to prune null WeakPtrs.
|
||||
m_media_query_lists.remove_all_matching([](auto& it) {
|
||||
return it.is_null();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue