summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-11-04 20:54:05 +0000
committerLinus Groh <mail@linusgroh.de>2023-01-05 17:42:31 +0100
commit65cdf89a8bd0de699d78f3204291f9c615aee036 (patch)
tree4ff3f3f3b4779ab8a1f95ee7fac8d5fd5843aadf /Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
parentc70dcaefcd4e6f5827d84320fc1fadd77970097c (diff)
downloadserenity-65cdf89a8bd0de699d78f3204291f9c615aee036.zip
LibWeb: Convert Layout Boxes to new pixel units
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
index 5b7398892b..7b6289fbef 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
@@ -25,8 +25,8 @@ RefPtr<Painting::Paintable> SVGSVGBox::create_paintable() const
void SVGSVGBox::prepare_for_replaced_layout()
{
if (dom_node().has_attribute(HTML::AttributeNames::width) && dom_node().has_attribute(HTML::AttributeNames::height)) {
- Optional<float> w;
- Optional<float> h;
+ Optional<CSSPixels> w;
+ Optional<CSSPixels> h;
if (auto width = HTML::parse_dimension_value(dom_node().attribute(HTML::AttributeNames::width))) {
if (width->has_length())
w = width->to_length().to_px(*this);
@@ -38,14 +38,14 @@ void SVGSVGBox::prepare_for_replaced_layout()
if (w.has_value() && h.has_value()) {
set_intrinsic_width(*w);
set_intrinsic_height(*h);
- set_intrinsic_aspect_ratio(*w / *h);
+ set_intrinsic_aspect_ratio(w->value() / h->value());
return;
}
}
- Optional<Gfx::FloatRect> united_rect;
+ Optional<CSSPixelRect> united_rect;
- auto add_to_united_rect = [&](Gfx::FloatRect const& rect) {
+ auto add_to_united_rect = [&](CSSPixelRect const& rect) {
if (united_rect.has_value())
united_rect = united_rect->united(rect);
else
@@ -55,7 +55,7 @@ void SVGSVGBox::prepare_for_replaced_layout()
for_each_in_subtree_of_type<SVGGeometryBox>([&](SVGGeometryBox const& geometry_box) {
auto& dom_node = const_cast<SVG::SVGGeometryElement&>(geometry_box.dom_node());
if (dom_node.has_attribute(HTML::AttributeNames::width) && dom_node.has_attribute(HTML::AttributeNames::height)) {
- Gfx::FloatRect rect;
+ CSSPixelRect rect;
// FIXME: Allow for relative lengths here
rect.set_width(computed_values().width().resolved(*this, CSS::Length::make_px(0)).to_px(*this));
rect.set_height(computed_values().height().resolved(*this, CSS::Length::make_px(0)).to_px(*this));
@@ -64,7 +64,7 @@ void SVGSVGBox::prepare_for_replaced_layout()
}
auto& path = dom_node.get_path();
- auto path_bounding_box = path.bounding_box();
+ auto path_bounding_box = path.bounding_box().to_type<CSSPixels>();
// Stroke increases the path's size by stroke_width/2 per side.
auto stroke_width = geometry_box.dom_node().stroke_width().value_or(0);
@@ -74,7 +74,7 @@ void SVGSVGBox::prepare_for_replaced_layout()
if (maybe_view_box.has_value()) {
auto view_box = maybe_view_box.value();
- Gfx::FloatRect rect(view_box.min_x, view_box.min_y, view_box.width, view_box.height);
+ CSSPixelRect rect(view_box.min_x, view_box.min_y, view_box.width, view_box.height);
add_to_united_rect(rect);
return IterationDecision::Continue;
}
@@ -86,7 +86,7 @@ void SVGSVGBox::prepare_for_replaced_layout()
if (united_rect.has_value()) {
set_intrinsic_width(united_rect->width());
set_intrinsic_height(united_rect->height());
- set_intrinsic_aspect_ratio(united_rect->width() / united_rect->height());
+ set_intrinsic_aspect_ratio(united_rect->width().value() / united_rect->height().value());
}
}