From f4b7047e113382798d5d91adc673a99c80f7e739 Mon Sep 17 00:00:00 2001 From: Callum Law Date: Sun, 9 Aug 2026 21:57:18 +1200 Subject: [PATCH] LibGfx: Include all contours in `PathImplSkia::length()` --- Libraries/LibGfx/PathSkia.cpp | 6 +++++- .../svg-path-get-total-length-multiple-subpaths.txt | 1 + .../svg-path-get-total-length-multiple-subpaths.html | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/SVG/svg-path-get-total-length-multiple-subpaths.txt create mode 100644 Tests/LibWeb/Text/input/SVG/svg-path-get-total-length-multiple-subpaths.html diff --git a/Libraries/LibGfx/PathSkia.cpp b/Libraries/LibGfx/PathSkia.cpp index e6967c73af298..1c0ca8568622b 100644 --- a/Libraries/LibGfx/PathSkia.cpp +++ b/Libraries/LibGfx/PathSkia.cpp @@ -345,7 +345,11 @@ Gfx::FloatRect PathImplSkia::bounding_box() const float PathImplSkia::length() const { SkPathMeasure path_measure(sk_path(), false); - return path_measure.getLength(); + float length = 0; + do { + length += path_measure.getLength(); + } while (path_measure.nextContour()); + return length; } bool PathImplSkia::contains(FloatPoint point, Gfx::WindingRule winding_rule) const diff --git a/Tests/LibWeb/Text/expected/SVG/svg-path-get-total-length-multiple-subpaths.txt b/Tests/LibWeb/Text/expected/SVG/svg-path-get-total-length-multiple-subpaths.txt new file mode 100644 index 0000000000000..52bd8e43afb01 --- /dev/null +++ b/Tests/LibWeb/Text/expected/SVG/svg-path-get-total-length-multiple-subpaths.txt @@ -0,0 +1 @@ +120 diff --git a/Tests/LibWeb/Text/input/SVG/svg-path-get-total-length-multiple-subpaths.html b/Tests/LibWeb/Text/input/SVG/svg-path-get-total-length-multiple-subpaths.html new file mode 100644 index 0000000000000..4828b5be1e488 --- /dev/null +++ b/Tests/LibWeb/Text/input/SVG/svg-path-get-total-length-multiple-subpaths.html @@ -0,0 +1,10 @@ + + + + + +