mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibWeb: Give SVG geometry elements a position
This makes the selected-in-the-inspector outline appear in the right place. We take the stroke-width into account when producing the bounding box, which makes the fit nice and snug. :^)
This commit is contained in:
parent
ae93aeb414
commit
aba8774c9c
4 changed files with 16 additions and 4 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue