mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-02 14:19:15 +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: b92abe5c26
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1034
2 changed files with 4 additions and 2 deletions
|
@ -308,13 +308,14 @@ bool CSSStyleSheet::evaluate_media_queries(HTML::Window const& window)
|
||||||
{
|
{
|
||||||
bool any_media_queries_changed_match_state = false;
|
bool any_media_queries_changed_match_state = false;
|
||||||
|
|
||||||
bool did_match = m_media->matches();
|
|
||||||
bool now_matches = m_media->evaluate(window);
|
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;
|
any_media_queries_changed_match_state = true;
|
||||||
if (now_matches && m_rules->evaluate_media_queries(window))
|
if (now_matches && m_rules->evaluate_media_queries(window))
|
||||||
any_media_queries_changed_match_state = true;
|
any_media_queries_changed_match_state = true;
|
||||||
|
|
||||||
|
m_did_match = now_matches;
|
||||||
|
|
||||||
return any_media_queries_changed_match_state;
|
return any_media_queries_changed_match_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ private:
|
||||||
JS::GCPtr<DOM::Document const> m_constructor_document;
|
JS::GCPtr<DOM::Document const> m_constructor_document;
|
||||||
bool m_constructed { false };
|
bool m_constructed { false };
|
||||||
bool m_disallow_modification { false };
|
bool m_disallow_modification { false };
|
||||||
|
Optional<bool> m_did_match;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue