mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +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
|
|
@ -145,22 +145,28 @@ void PageClient::set_palette_impl(Gfx::PaletteImpl& impl)
|
|||
void PageClient::set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme)
|
||||
{
|
||||
m_preferred_color_scheme = color_scheme;
|
||||
if (auto* document = page().top_level_browsing_context().active_document())
|
||||
if (auto* document = page().top_level_browsing_context().active_document()) {
|
||||
document->invalidate_style(Web::DOM::StyleInvalidationReason::SettingsChange);
|
||||
document->set_needs_media_query_evaluation();
|
||||
}
|
||||
}
|
||||
|
||||
void PageClient::set_preferred_contrast(Web::CSS::PreferredContrast contrast)
|
||||
{
|
||||
m_preferred_contrast = contrast;
|
||||
if (auto* document = page().top_level_browsing_context().active_document())
|
||||
if (auto* document = page().top_level_browsing_context().active_document()) {
|
||||
document->invalidate_style(Web::DOM::StyleInvalidationReason::SettingsChange);
|
||||
document->set_needs_media_query_evaluation();
|
||||
}
|
||||
}
|
||||
|
||||
void PageClient::set_preferred_motion(Web::CSS::PreferredMotion motion)
|
||||
{
|
||||
m_preferred_motion = motion;
|
||||
if (auto* document = page().top_level_browsing_context().active_document())
|
||||
if (auto* document = page().top_level_browsing_context().active_document()) {
|
||||
document->invalidate_style(Web::DOM::StyleInvalidationReason::SettingsChange);
|
||||
document->set_needs_media_query_evaluation();
|
||||
}
|
||||
}
|
||||
|
||||
void PageClient::set_is_scripting_enabled(bool is_scripting_enabled)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue