LibWeb: Do not floor SVG offset in SVGPathPaintable

Resolves a FIXME and improves the visuals of https://tweakers.net :^)
This commit is contained in:
Jelle Raaijmakers 2024-10-22 12:01:03 +02:00 committed by Tim Flynn
commit e4533e5595
Notes: github-actions[bot] 2024-10-22 11:38:50 +00:00
4 changed files with 26 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,9 @@
<style>
* {
margin: 0;
}
body {
background-color: white;
}
</style>
<img src="../images/svg-path-offset-rounding-ref.png">

View file

@ -0,0 +1,16 @@
<!doctype html>
<link rel="match" href="reference/svg-path-offset-rounding-ref.html" />
<style>
body {
padding-left: 10.6px;
}
</style>
<body>
<svg width="34" height="22" viewBox="0 0 34 22">
<path
d="M -0.2 0 L 34 0 L 34 22 L -0.2 22 Z"
fill="none"
stroke="#000000"
></path>
</svg>
</body>

View file

@ -65,10 +65,9 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const
auto const* svg_node = layout_box().first_ancestor_of_type<Layout::SVGSVGBox>();
auto svg_element_rect = svg_node->paintable_box()->absolute_rect();
// FIXME: This should not be trucated to an int.
DisplayListRecorderStateSaver save_painter { context.display_list_recorder() };
auto offset = context.floored_device_point(svg_element_rect.location()).to_type<int>().to_type<float>();
auto offset = context.rounded_device_point(svg_element_rect.location()).to_type<int>().to_type<float>();
auto maybe_view_box = svg_node->dom_node().view_box();
auto paint_transform = computed_transforms().svg_to_device_pixels_transform(context);