diff --git a/dom/svg/SVGCircleElement.cpp b/dom/svg/SVGCircleElement.cpp index 1ba06f2aa33a..1cd9680fb8d1 100644 --- a/dom/svg/SVGCircleElement.cpp +++ b/dom/svg/SVGCircleElement.cpp @@ -82,8 +82,8 @@ SVGCircleElement::GetLengthInfo() // nsSVGPathGeometryElement methods bool -SVGCircleElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) +SVGCircleElement::GetGeometryBounds( + Rect* aBounds, const StrokeOptions& aStrokeOptions, const Matrix& aTransform) { float x, y, r; GetAnimatedLengthValues(&x, &y, &r, nullptr); @@ -97,8 +97,8 @@ SVGCircleElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, if (aTransform.IsRectilinear()) { // Optimize the case where we can treat the circle as a rectangle and // still get tight bounds. - if (aStrokeWidth > 0.f) { - r += aStrokeWidth / 2.f; + if (aStrokeOptions.mLineWidth > 0.f) { + r += aStrokeOptions.mLineWidth / 2.f; } Rect rect(x - r, y - r, 2 * r, 2 * r); *aBounds = aTransform.TransformBounds(rect); diff --git a/dom/svg/SVGCircleElement.h b/dom/svg/SVGCircleElement.h index 064e5d0b65f5..52415cd2567f 100644 --- a/dom/svg/SVGCircleElement.h +++ b/dom/svg/SVGCircleElement.h @@ -30,8 +30,8 @@ public: virtual bool HasValidDimensions() const MOZ_OVERRIDE; // nsSVGPathGeometryElement methods: - virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) MOZ_OVERRIDE; + virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions, + const Matrix& aTransform) MOZ_OVERRIDE; virtual TemporaryRef BuildPath(PathBuilder* aBuilder) MOZ_OVERRIDE; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/dom/svg/SVGEllipseElement.cpp b/dom/svg/SVGEllipseElement.cpp index f23ccd943a48..713018332df5 100644 --- a/dom/svg/SVGEllipseElement.cpp +++ b/dom/svg/SVGEllipseElement.cpp @@ -93,8 +93,8 @@ SVGEllipseElement::GetLengthInfo() // nsSVGPathGeometryElement methods bool -SVGEllipseElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) +SVGEllipseElement::GetGeometryBounds( + Rect* aBounds, const StrokeOptions& aStrokeOptions, const Matrix& aTransform) { float x, y, rx, ry; GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr); @@ -108,9 +108,9 @@ SVGEllipseElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, if (aTransform.IsRectilinear()) { // Optimize the case where we can treat the ellipse as a rectangle and // still get tight bounds. - if (aStrokeWidth > 0.f) { - rx += aStrokeWidth / 2.f; - ry += aStrokeWidth / 2.f; + if (aStrokeOptions.mLineWidth > 0.f) { + rx += aStrokeOptions.mLineWidth / 2.f; + ry += aStrokeOptions.mLineWidth / 2.f; } Rect rect(x - rx, y - ry, 2 * rx, 2 * ry); *aBounds = aTransform.TransformBounds(rect); diff --git a/dom/svg/SVGEllipseElement.h b/dom/svg/SVGEllipseElement.h index 5eefc20c9df9..0efddb6a85ee 100644 --- a/dom/svg/SVGEllipseElement.h +++ b/dom/svg/SVGEllipseElement.h @@ -30,8 +30,8 @@ public: virtual bool HasValidDimensions() const MOZ_OVERRIDE; // nsSVGPathGeometryElement methods: - virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) MOZ_OVERRIDE; + virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions, + const Matrix& aTransform) MOZ_OVERRIDE; virtual TemporaryRef BuildPath(PathBuilder* aBuilder) MOZ_OVERRIDE; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp index f28c53827aba..32a0f03dc8a5 100644 --- a/dom/svg/SVGImageElement.cpp +++ b/dom/svg/SVGImageElement.cpp @@ -225,8 +225,8 @@ SVGImageElement::IsAttributeMapped(const nsIAtom* name) const /* For the purposes of the update/invalidation logic pretend to be a rectangle. */ bool -SVGImageElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) +SVGImageElement::GetGeometryBounds( + Rect* aBounds, const StrokeOptions& aStrokeOptions, const Matrix& aTransform) { Rect rect; GetAnimatedLengthValues(&rect.x, &rect.y, &rect.width, diff --git a/dom/svg/SVGImageElement.h b/dom/svg/SVGImageElement.h index 548a1662fad6..010b157a06fc 100644 --- a/dom/svg/SVGImageElement.h +++ b/dom/svg/SVGImageElement.h @@ -53,8 +53,8 @@ public: NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const MOZ_OVERRIDE; // nsSVGPathGeometryElement methods: - virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle cap, const Matrix& aTransform) MOZ_OVERRIDE; + virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions, + const Matrix& aTransform) MOZ_OVERRIDE; virtual TemporaryRef BuildPath(PathBuilder* aBuilder) MOZ_OVERRIDE; // nsSVGSVGElement methods: diff --git a/dom/svg/SVGLineElement.cpp b/dom/svg/SVGLineElement.cpp index e645f5fd5be2..6b64bd84ae1d 100644 --- a/dom/svg/SVGLineElement.cpp +++ b/dom/svg/SVGLineElement.cpp @@ -127,26 +127,26 @@ SVGLineElement::BuildPath(PathBuilder* aBuilder) } bool -SVGLineElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) +SVGLineElement::GetGeometryBounds( + Rect* aBounds, const StrokeOptions& aStrokeOptions, const Matrix& aTransform) { float x1, y1, x2, y2; GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr); - if (aStrokeWidth <= 0) { + if (aStrokeOptions.mLineWidth <= 0) { *aBounds = Rect(aTransform * Point(x1, y1), Size()); aBounds->ExpandToEnclose(aTransform * Point(x2, y2)); return true; } - if (aCapStyle == CapStyle::ROUND) { + if (aStrokeOptions.mLineCap == CapStyle::ROUND) { if (!aTransform.IsRectilinear()) { // TODO: handle this case. return false; } Rect bounds(Point(x1, y1), Size()); bounds.ExpandToEnclose(Point(x2, y2)); - bounds.Inflate(aStrokeWidth / 2.f); + bounds.Inflate(aStrokeOptions.mLineWidth / 2.f); *aBounds = aTransform.TransformBounds(bounds); return true; } @@ -155,20 +155,20 @@ SVGLineElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, Float xDelta; Float yDelta; - if (aCapStyle == CapStyle::BUTT) { + if (aStrokeOptions.mLineCap == CapStyle::BUTT) { if (length == 0.f) { xDelta = yDelta = 0.f; } else { - Float ratio = aStrokeWidth / 2.f / length; + Float ratio = aStrokeOptions.mLineWidth / 2.f / length; xDelta = ratio * (y2 - y1); yDelta = ratio * (x2 - x1); } } else { - MOZ_ASSERT(aCapStyle == CapStyle::SQUARE); + MOZ_ASSERT(aStrokeOptions.mLineCap == CapStyle::SQUARE); if (length == 0.f) { - xDelta = yDelta = aStrokeWidth / 2.f; + xDelta = yDelta = aStrokeOptions.mLineWidth / 2.f; } else { - Float ratio = aStrokeWidth / 2.f / length; + Float ratio = aStrokeOptions.mLineWidth / 2.f / length; xDelta = yDelta = ratio * (fabs(y2 - y1) + fabs(x2 - x1)); } } diff --git a/dom/svg/SVGLineElement.h b/dom/svg/SVGLineElement.h index ddb63d13b6f9..4581d2d25e34 100644 --- a/dom/svg/SVGLineElement.h +++ b/dom/svg/SVGLineElement.h @@ -34,8 +34,8 @@ public: virtual void GetMarkPoints(nsTArray *aMarks) MOZ_OVERRIDE; virtual void GetAsSimplePath(SimplePath* aSimplePath) MOZ_OVERRIDE; virtual TemporaryRef BuildPath(PathBuilder* aBuilder) MOZ_OVERRIDE; - virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle cap, const Matrix& aTransform) MOZ_OVERRIDE; + virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions, + const Matrix& aTransform) MOZ_OVERRIDE; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/dom/svg/SVGRectElement.cpp b/dom/svg/SVGRectElement.cpp index ef82fe75b042..14bc28fb60b1 100644 --- a/dom/svg/SVGRectElement.cpp +++ b/dom/svg/SVGRectElement.cpp @@ -111,8 +111,8 @@ SVGRectElement::GetLengthInfo() // nsSVGPathGeometryElement methods bool -SVGRectElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) +SVGRectElement::GetGeometryBounds( + Rect* aBounds, const StrokeOptions& aStrokeOptions, const Matrix& aTransform) { Rect rect; Float rx, ry; @@ -137,8 +137,8 @@ SVGRectElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, } } - if (aStrokeWidth > 0.f) { - rect.Inflate(aStrokeWidth / 2.f); + if (aStrokeOptions.mLineWidth > 0.f) { + rect.Inflate(aStrokeOptions.mLineWidth / 2.f); } *aBounds = aTransform.TransformBounds(rect); diff --git a/dom/svg/SVGRectElement.h b/dom/svg/SVGRectElement.h index ec97daae3e5e..c93959df64e3 100644 --- a/dom/svg/SVGRectElement.h +++ b/dom/svg/SVGRectElement.h @@ -30,8 +30,8 @@ public: virtual bool HasValidDimensions() const MOZ_OVERRIDE; // nsSVGPathGeometryElement methods: - virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) MOZ_OVERRIDE; + virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions, + const Matrix& aTransform) MOZ_OVERRIDE; virtual void GetAsSimplePath(SimplePath* aSimplePath) MOZ_OVERRIDE; virtual TemporaryRef BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE; diff --git a/dom/svg/nsSVGPathGeometryElement.h b/dom/svg/nsSVGPathGeometryElement.h index 3145f7fc6efe..90e2be12d04a 100644 --- a/dom/svg/nsSVGPathGeometryElement.h +++ b/dom/svg/nsSVGPathGeometryElement.h @@ -40,6 +40,7 @@ protected: typedef mozilla::gfx::Point Point; typedef mozilla::gfx::PathBuilder PathBuilder; typedef mozilla::gfx::Rect Rect; + typedef mozilla::gfx::StrokeOptions StrokeOptions; public: explicit nsSVGPathGeometryElement(already_AddRefed& aNodeInfo); @@ -77,8 +78,8 @@ public: * shapes and simple transforms where the Moz2D Path backends can fail to * produce the clean integer bounds that content authors expect in some cases. */ - virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) { + virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions, + const Matrix& aTransform) { return false; } diff --git a/dom/svg/nsSVGPolyElement.cpp b/dom/svg/nsSVGPolyElement.cpp index e1914a9d4ef8..7c14d55aba36 100644 --- a/dom/svg/nsSVGPolyElement.cpp +++ b/dom/svg/nsSVGPolyElement.cpp @@ -121,8 +121,8 @@ nsSVGPolyElement::GetMarkPoints(nsTArray *aMarks) } bool -nsSVGPolyElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) +nsSVGPolyElement::GetGeometryBounds( + Rect* aBounds, const StrokeOptions& aStrokeOptions, const Matrix& aTransform) { const SVGPointList &points = mPoints.GetAnimValue(); @@ -132,7 +132,7 @@ nsSVGPolyElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, return true; } - if (aStrokeWidth > 0) { + if (aStrokeOptions.mLineWidth > 0) { // We don't handle stroke-miterlimit etc. yet return false; } diff --git a/dom/svg/nsSVGPolyElement.h b/dom/svg/nsSVGPolyElement.h index f8313187ed6e..f63c13990e1d 100644 --- a/dom/svg/nsSVGPolyElement.h +++ b/dom/svg/nsSVGPolyElement.h @@ -45,8 +45,8 @@ public: virtual bool AttributeDefinesGeometry(const nsIAtom *aName) MOZ_OVERRIDE; virtual bool IsMarkable() MOZ_OVERRIDE { return true; } virtual void GetMarkPoints(nsTArray *aMarks) MOZ_OVERRIDE; - virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth, - CapStyle aCapStyle, const Matrix& aTransform) MOZ_OVERRIDE; + virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions, + const Matrix& aTransform) MOZ_OVERRIDE; // WebIDL already_AddRefed Points(); diff --git a/layout/svg/nsSVGPathGeometryFrame.cpp b/layout/svg/nsSVGPathGeometryFrame.cpp index 2481c8495f27..d038dd513b0f 100644 --- a/layout/svg/nsSVGPathGeometryFrame.cpp +++ b/layout/svg/nsSVGPathGeometryFrame.cpp @@ -480,8 +480,7 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace, } Rect simpleBounds; gotSimpleBounds = element->GetGeometryBounds(&simpleBounds, - strokeOptions.mLineWidth, - strokeOptions.mLineCap, + strokeOptions, aToBBoxUserspace); if (gotSimpleBounds) { bbox = simpleBounds;