mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 21:20:18 +00:00
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:
parent
c33be71df9
commit
05c336ea4e
Notes:
github-actions[bot]
2025-10-07 09:34:36 +00:00
Author: https://github.com/Calme1709
Commit: 05c336ea4e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6412
Reviewed-by: https://github.com/AtkinsSJ ✅
23 changed files with 198 additions and 83 deletions
|
@ -137,6 +137,18 @@ Length::ResolutionContext Length::ResolutionContext::for_window(HTML::Window con
|
|||
};
|
||||
}
|
||||
|
||||
Length::ResolutionContext Length::ResolutionContext::for_document(DOM::Document const& document)
|
||||
{
|
||||
auto const& initial_font = document.style_computer().initial_font();
|
||||
Gfx::FontPixelMetrics const& initial_font_metrics = initial_font.pixel_metrics();
|
||||
Length::FontMetrics font_metrics { CSSPixels { initial_font.pixel_size() }, initial_font_metrics, InitialValues::line_height() };
|
||||
return Length::ResolutionContext {
|
||||
.viewport_rect = document.navigable()->viewport_rect(),
|
||||
.font_metrics = font_metrics,
|
||||
.root_font_metrics = font_metrics,
|
||||
};
|
||||
}
|
||||
|
||||
Length::ResolutionContext Length::ResolutionContext::for_layout_node(Layout::Node const& node)
|
||||
{
|
||||
Layout::Node const* root_layout_node;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue