LibWeb: Use document's viewport when resolving lengths in media queries

Previously we would always use the window's viewport which was incorrect
if we were within an iframe.

This is likely applicable to all uses of
`Length::ResolutionContext::for_window`.
This commit is contained in:
Callum Law 2025-10-07 00:54:19 +13:00 committed by Sam Atkins
commit 05c336ea4e
Notes: github-actions[bot] 2025-10-07 09:34:36 +00:00
23 changed files with 198 additions and 83 deletions

View file

@ -85,16 +85,12 @@ bool MediaQueryList::matches() const
bool MediaQueryList::evaluate()
{
auto window = m_document->window();
if (!window)
return false;
if (m_media.is_empty())
return true;
bool now_matches = false;
for (auto& media : m_media) {
now_matches = now_matches || media->evaluate(*window);
now_matches = now_matches || media->evaluate(m_document);
}
return now_matches;