LibWeb: Absolutize internal lengths in all StyleValues

StyleValue now has a virtual visit_lengths() that allows us to update
all CSS lengths during the absolutization phase.
This commit is contained in:
Andreas Kling 2021-09-23 20:15:26 +02:00
commit 3dc6f0bc47
Notes: sideshowbarker 2024-07-18 03:28:44 +09:00
2 changed files with 28 additions and 8 deletions

View file

@ -818,13 +818,12 @@ void StyleResolver::absolutize_values(StyleProperties& style, DOM::Element const
float root_font_size = 10;
for (auto& it : style.properties()) {
if (!it.value->is_length())
continue;
auto length = it.value->to_length();
if (length.is_relative()) {
auto px = length.relative_length_to_px(viewport_rect, font_metrics, root_font_size);
it.value = LengthStyleValue::create(CSS::Length::make_px(px));
}
it.value->visit_lengths([&](Length& length) {
if (length.is_absolute() || length.is_relative()) {
auto px = length.to_px(viewport_rect, font_metrics, root_font_size);
length = Length::make_px(px);
}
});
}
}