mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
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
2 changed files with 8 additions and 0 deletions
|
@ -627,6 +627,7 @@ void Document::update_style()
|
||||||
return;
|
return;
|
||||||
if (!needs_full_style_update() && !needs_style_update() && !child_needs_style_update())
|
if (!needs_full_style_update() && !needs_style_update() && !child_needs_style_update())
|
||||||
return;
|
return;
|
||||||
|
evaluate_media_rules();
|
||||||
if (update_style_recursively(*this))
|
if (update_style_recursively(*this))
|
||||||
invalidate_layout();
|
invalidate_layout();
|
||||||
m_needs_full_style_update = false;
|
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!
|
// 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;
|
bool any_media_queries_changed_match_state = false;
|
||||||
for (auto& style_sheet : style_sheets().sheets()) {
|
for (auto& style_sheet : style_sheets().sheets()) {
|
||||||
if (style_sheet.evaluate_media_queries(window()))
|
if (style_sheet.evaluate_media_queries(window()))
|
||||||
|
|
|
@ -345,6 +345,8 @@ private:
|
||||||
|
|
||||||
void tear_down_layout_tree();
|
void tear_down_layout_tree();
|
||||||
|
|
||||||
|
void evaluate_media_rules();
|
||||||
|
|
||||||
ExceptionOr<void> run_the_document_write_steps(String);
|
ExceptionOr<void> run_the_document_write_steps(String);
|
||||||
|
|
||||||
void increment_referencing_node_count()
|
void increment_referencing_node_count()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue