mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 13:02:09 +02:00
CSSStyleSheet::evaluate_media_queries previously flagged "no recorded result yet" as a match-state change, so every freshly-loaded sheet fired MediaQueryChangedMatchState on the first pass through Document::evaluate_media_rules. For sheets added through adoptedStyleSheets that piled an extra full-document style invalidation on top of the AdoptedStyleSheetsList one, recomputing every element a second time for nothing. Drop the !has_value() leg so the very first evaluation establishes the baseline silently. The sheet's rules already entered the cascade through StyleSheetListAddSheet, AdoptedStyleSheetsList, or invalidate_owners, each of which performs its own targeted invalidation. Two callers relied on the implicit "first eval forces a refresh" behavior to handle freshly-mutated state: - invalidate_owners resets m_did_match, then leans on the next eval to repopulate it. With the new semantics it must also re-evaluate the sheet eagerly so MediaList::matches() and inner @media state are fresh before the next rule cache build reads them. - The adoptedStyleSheets on_set callback didn't evaluate at all, relying on Document::evaluate_media_rules to populate MediaList::m_matches. That worked accidentally because the false flip retriggered invalidate_rule_cache after the matches had been populated. Mirror StyleSheetList::add_sheet by evaluating the sheet at adopt time so the rule cache build sees the correct match state even if it runs first (e.g. via a :has() invalidation pass).
26 KiB
26 KiB