Skip to content

Commit

Permalink
LibWeb: Do not floor SVG offset in SVGPathPaintable
Browse files Browse the repository at this point in the history
Resolves a FIXME and improves the visuals of https://tweakers.net :^)
  • Loading branch information
gmta committed Oct 22, 2024
1 parent 14c3bff commit faa4367
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<style>
* {
margin: 0;
}
body {
background-color: white;
}
</style>
<img src="../images/svg-path-offset-rounding-ref.png">
9 changes: 9 additions & 0 deletions Tests/LibWeb/Screenshot/svg-path-offset-rounding.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<link rel="match" href="reference/svg-path-offset-rounding-ref.html" />
<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>
3 changes: 1 addition & 2 deletions Userland/Libraries/LibWeb/Painting/SVGPathPaintable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit faa4367

Please sign in to comment.