mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 08:11:13 +00:00
LibWeb: Avoid calling matches before evaluate
This commit is contained in:
parent
f7fcde7f60
commit
b92abe5c26
Notes:
github-actions[bot]
2024-08-13 12:13:53 +00:00
Author: https://github.com/vpzomtrrfrt Commit: https://github.com/LadybirdBrowser/ladybird/commit/b92abe5c266 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1034
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue