LibWeb: Evaluate @media CSS rules when updating style
In case we have new @media rules, we need to make sure we've evaluated them before actually recomputing styles for the document.
This commit is contained in:
parent
80ed2ab557
commit
618b857457
Notes:
sideshowbarker
2024-07-17 17:03:07 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/618b857457
2 changed files with 8 additions and 0 deletions
|
@ -627,6 +627,7 @@ void Document::update_style()
|
|||
return;
|
||||
if (!needs_full_style_update() && !needs_style_update() && !child_needs_style_update())
|
||||
return;
|
||||
evaluate_media_rules();
|
||||
if (update_style_recursively(*this))
|
||||
invalidate_layout();
|
||||
m_needs_full_style_update = false;
|
||||
|
@ -1375,6 +1376,11 @@ void Document::evaluate_media_queries_and_report_changes()
|
|||
}
|
||||
|
||||
// Also not in the spec, but this is as good a place as any to evaluate @media rules!
|
||||
evaluate_media_rules();
|
||||
}
|
||||
|
||||
void Document::evaluate_media_rules()
|
||||
{
|
||||
bool any_media_queries_changed_match_state = false;
|
||||
for (auto& style_sheet : style_sheets().sheets()) {
|
||||
if (style_sheet.evaluate_media_queries(window()))
|
||||
|
|
|
@ -345,6 +345,8 @@ private:
|
|||
|
||||
void tear_down_layout_tree();
|
||||
|
||||
void evaluate_media_rules();
|
||||
|
||||
ExceptionOr<void> run_the_document_write_steps(String);
|
||||
|
||||
void increment_referencing_node_count()
|
||||
|
|
Loading…
Add table
Reference in a new issue