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

@ -1814,8 +1814,7 @@ LengthOrCalculated Parser::parse_as_sizes_attribute(DOM::Element const& element,
// If it does not parse correctly, or it does parse correctly but the <media-condition> evaluates to false, continue.
TokenStream token_stream { unparsed_size };
auto media_condition = parse_media_condition(token_stream);
auto const* context_window = window();
if (!media_condition || (context_window && media_condition->evaluate(context_window) == MatchResult::False)) {
if (!media_condition || (m_document && media_condition->evaluate(m_document) == MatchResult::False)) {
continue;
}