summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp9
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp2
3 files changed, 10 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp
index 9f8becb24f..af4fb3fe83 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp
@@ -32,7 +32,14 @@ void SVGFormattingContext::run(Box& box, LayoutMode)
if (is<SVGGeometryBox>(descendant)) {
auto& geometry_box = static_cast<SVGGeometryBox&>(descendant);
auto& path = geometry_box.dom_node().get_path();
- geometry_box.set_content_size(path.bounding_box().size());
+ auto bounding_box = path.bounding_box();
+
+ // Stroke increases the path's size by stroke_width/2 per side.
+ auto stroke_width = geometry_box.dom_node().stroke_width().value_or(0);
+ bounding_box.inflate(stroke_width, stroke_width);
+
+ geometry_box.set_offset(bounding_box.top_left());
+ geometry_box.set_content_size(bounding_box.size());
total_bounding_box = total_bounding_box.united(path.bounding_box());
}
diff --git a/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp
index 756016361f..0f6c4a774f 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp
@@ -32,7 +32,7 @@ void SVGGeometryBox::paint(PaintContext& context, PaintPhase phase)
Gfx::AntiAliasingPainter painter { context.painter() };
auto& svg_context = context.svg_context();
- auto offset = absolute_position();
+ auto offset = svg_context.svg_element_position();
painter.translate(offset);
if (auto fill_color = geometry_element.fill_color().value_or(svg_context.fill_color()); fill_color.alpha() > 0) {
diff --git a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
index ce051bb9b7..5c941bfed1 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
@@ -19,7 +19,7 @@ void SVGSVGBox::before_children_paint(PaintContext& context, PaintPhase phase)
return;
if (!context.has_svg_context())
- context.set_svg_context(SVGContext());
+ context.set_svg_context(SVGContext(absolute_rect()));
SVGGraphicsBox::before_children_paint(context, phase);
}