diff --git a/dom/svg/SVGPolyElement.cpp b/dom/svg/SVGPolyElement.cpp index 5cb958af0d76..672cc438bf47 100644 --- a/dom/svg/SVGPolyElement.cpp +++ b/dom/svg/SVGPolyElement.cpp @@ -6,6 +6,7 @@ #include "SVGPolyElement.h" #include "DOMSVGPointList.h" +#include "mozilla/dom/SVGAnimatedLength.h" #include "mozilla/gfx/2D.h" #include "SVGContentUtils.h" @@ -48,13 +49,15 @@ void SVGPolyElement::GetMarkPoints(nsTArray* aMarks) { if (!points.Length()) return; - float px = points[0].mX, py = points[0].mY, prevAngle = 0.0; + float zoom = UserSpaceMetrics::GetZoom(this); + + float px = points[0].mX * zoom, py = points[0].mY * zoom, prevAngle = 0.0; aMarks->AppendElement(SVGMark(px, py, 0, SVGMark::eStart)); for (uint32_t i = 1; i < points.Length(); ++i) { - float x = points[i].mX; - float y = points[i].mY; + float x = points[i].mX * zoom; + float y = points[i].mY * zoom; float angle = std::atan2(y - py, x - px); // Vertex marker. @@ -93,18 +96,20 @@ bool SVGPolyElement::GetGeometryBounds(Rect* aBounds, return false; } + float zoom = UserSpaceMetrics::GetZoom(this); + if (aToBoundsSpace.IsRectilinear()) { // We can avoid transforming each point and just transform the result. // Important for large point lists. - Rect bounds(points[0], Size()); + Rect bounds(points[0] * zoom, Size()); for (uint32_t i = 1; i < points.Length(); ++i) { - bounds.ExpandToEnclose(points[i]); + bounds.ExpandToEnclose(points[i] * zoom); } *aBounds = aToBoundsSpace.TransformBounds(bounds); } else { - *aBounds = Rect(aToBoundsSpace.TransformPoint(points[0]), Size()); + *aBounds = Rect(aToBoundsSpace.TransformPoint(points[0] * zoom), Size()); for (uint32_t i = 1; i < points.Length(); ++i) { - aBounds->ExpandToEnclose(aToBoundsSpace.TransformPoint(points[i])); + aBounds->ExpandToEnclose(aToBoundsSpace.TransformPoint(points[i] * zoom)); } } return true; diff --git a/dom/svg/SVGPolygonElement.cpp b/dom/svg/SVGPolygonElement.cpp index def80151531d..12461a43753f 100644 --- a/dom/svg/SVGPolygonElement.cpp +++ b/dom/svg/SVGPolygonElement.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/SVGPolygonElement.h" #include "mozilla/dom/SVGPolygonElementBinding.h" +#include "mozilla/dom/SVGAnimatedLength.h" #include "mozilla/gfx/2D.h" #include "SVGContentUtils.h" @@ -64,9 +65,11 @@ already_AddRefed SVGPolygonElement::BuildPath(PathBuilder* aBuilder) { return nullptr; } - aBuilder->MoveTo(points[0]); + float zoom = UserSpaceMetrics::GetZoom(this); + + aBuilder->MoveTo(points[0] * zoom); for (uint32_t i = 1; i < points.Length(); ++i) { - aBuilder->LineTo(points[i]); + aBuilder->LineTo(points[i] * zoom); } aBuilder->Close(); diff --git a/dom/svg/SVGPolylineElement.cpp b/dom/svg/SVGPolylineElement.cpp index a657b0cefdd2..c771d40d1499 100644 --- a/dom/svg/SVGPolylineElement.cpp +++ b/dom/svg/SVGPolylineElement.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/SVGPolylineElement.h" #include "mozilla/dom/SVGPolylineElementBinding.h" +#include "mozilla/dom/SVGAnimatedLength.h" #include "mozilla/gfx/2D.h" using namespace mozilla::gfx; @@ -41,9 +42,11 @@ already_AddRefed SVGPolylineElement::BuildPath(PathBuilder* aBuilder) { return nullptr; } - aBuilder->MoveTo(points[0]); + float zoom = UserSpaceMetrics::GetZoom(this); + + aBuilder->MoveTo(points[0] * zoom); for (uint32_t i = 1; i < points.Length(); ++i) { - aBuilder->LineTo(points[i]); + aBuilder->LineTo(points[i] * zoom); } return aBuilder->Finish(); diff --git a/testing/web-platform/tests/css/css-viewport/zoom/svg-ref.html b/testing/web-platform/tests/css/css-viewport/zoom/svg-ref.html index 10bf2decaa74..8959a01f2018 100644 --- a/testing/web-platform/tests/css/css-viewport/zoom/svg-ref.html +++ b/testing/web-platform/tests/css/css-viewport/zoom/svg-ref.html @@ -11,6 +11,9 @@ stroke-width: 40px; stroke: lime; } + polygon, polyline { + fill: lime; + } svg { background-color: red; } @@ -23,5 +26,7 @@ + + diff --git a/testing/web-platform/tests/css/css-viewport/zoom/svg.html b/testing/web-platform/tests/css/css-viewport/zoom/svg.html index 826ce5a80a3b..b5aad837fd80 100644 --- a/testing/web-platform/tests/css/css-viewport/zoom/svg.html +++ b/testing/web-platform/tests/css/css-viewport/zoom/svg.html @@ -4,6 +4,7 @@ +