1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibWeb: Respect font-size specified by CSS in "em" length calculations

"5em" means 5*font-size, but by forcing "em" to mean the presentation
size of the bitmap font actually used, we broke a bunch of layouts that
depended on a correct interpretation of "em".

This means that "em" units will no longer be relative to the exact
size of the bitmap font in use, but I think that's a compromise we'll
have to make, since accurate layouts are more important.

This yields a visual progression on both ACID2 and ACID3. :^)
This commit is contained in:
Andreas Kling 2022-02-21 16:24:12 +01:00
parent 2615728d6b
commit c61747fb2a
6 changed files with 32 additions and 13 deletions

View file

@ -153,12 +153,13 @@ bool MediaFeature::compare(DOM::Window const& window, MediaFeatureValue left, Co
// FIXME: This isn't right - we want to query the initial-value font, which is the one used
// if no author styles are defined.
auto const& font = window.associated_document().root().layout_node()->font();
auto& root_layout_node = *window.associated_document().root().layout_node();
auto const& font = root_layout_node.font();
Gfx::FontMetrics const& font_metrics = font.metrics('M');
float root_font_size = font.presentation_size();
float root_font_size = root_layout_node.computed_values().font_size();
left_px = left.length().to_px(viewport_rect, font_metrics, root_font_size);
right_px = right.length().to_px(viewport_rect, font_metrics, root_font_size);
left_px = left.length().to_px(viewport_rect, font_metrics, root_font_size, root_font_size);
right_px = right.length().to_px(viewport_rect, font_metrics, root_font_size, root_font_size);
}
switch (comparison) {