mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +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;
|
||||
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()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue