LibWeb: Avoid calling matches before evaluate

This commit is contained in:
Colin Reeder 2024-08-11 09:34:37 -06:00 committed by Andreas Kling
parent f7fcde7f60
commit b92abe5c26
Notes: github-actions[bot] 2024-08-13 12:13:53 +00:00
2 changed files with 4 additions and 2 deletions

View file

@ -308,13 +308,14 @@ bool CSSStyleSheet::evaluate_media_queries(HTML::Window const& window)
{
bool any_media_queries_changed_match_state = false;
bool did_match = m_media->matches();
bool now_matches = m_media->evaluate(window);
if (did_match != now_matches)
if (!m_did_match.has_value() || m_did_match.value() != now_matches)
any_media_queries_changed_match_state = true;
if (now_matches && m_rules->evaluate_media_queries(window))
any_media_queries_changed_match_state = true;
m_did_match = now_matches;
return any_media_queries_changed_match_state;
}

View file

@ -100,6 +100,7 @@ private:
JS::GCPtr<DOM::Document const> m_constructor_document;
bool m_constructed { false };
bool m_disallow_modification { false };
Optional<bool> m_did_match;
};
}