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

LibWeb: Make sure CSS::ComputedValues has initial size values

Instead of using Optional<LengthPercentage>, we now use LengthPercentage
for these values. The initial values are all `auto`.

This avoids having to check `has_value()` in a ton of places.
This commit is contained in:
Andreas Kling 2022-07-07 12:36:02 +02:00
parent 734ff422ad
commit cefc931347
9 changed files with 81 additions and 86 deletions

View file

@ -70,8 +70,8 @@ Optional<float> SVGGraphicsElement::stroke_width() const
float viewport_height = 0;
if (auto* svg_svg_element = first_ancestor_of_type<SVGSVGElement>()) {
if (auto* svg_svg_layout_node = svg_svg_element->layout_node()) {
viewport_width = svg_svg_layout_node->computed_values().width().value().resolved(*svg_svg_layout_node, { 0, CSS::Length::Type::Px }).to_px(*svg_svg_layout_node);
viewport_height = svg_svg_layout_node->computed_values().height().value().resolved(*svg_svg_layout_node, { 0, CSS::Length::Type::Px }).to_px(*svg_svg_layout_node);
viewport_width = svg_svg_layout_node->computed_values().width().resolved(*svg_svg_layout_node, { 0, CSS::Length::Type::Px }).to_px(*svg_svg_layout_node);
viewport_height = svg_svg_layout_node->computed_values().height().resolved(*svg_svg_layout_node, { 0, CSS::Length::Type::Px }).to_px(*svg_svg_layout_node);
}
}
auto scaled_viewport_size = CSS::Length::make_px((viewport_width + viewport_height) * 0.5f);