--- a/content/svg/content/src/SVGCircleElement.cpp
+++ b/content/svg/content/src/SVGCircleElement.cpp
@@ -1,17 +1,16 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGCircleElement.h"
#include "mozilla/gfx/2D.h"
#include "nsGkAtoms.h"
-#include "gfxContext.h"
#include "mozilla/dom/SVGCircleElementBinding.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Circle)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@@ -77,27 +76,16 @@ SVGCircleElement::GetLengthInfo()
{
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
ArrayLength(sLengthInfo));
}
//----------------------------------------------------------------------
// nsSVGPathGeometryElement methods
-void
-SVGCircleElement::ConstructPath(gfxContext *aCtx)
-{
- float x, y, r;
-
- GetAnimatedLengthValues(&x, &y, &r, nullptr);
-
- if (r > 0.0f)
- aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI);
-}
-
TemporaryRef<Path>
SVGCircleElement::BuildPath(PathBuilder* aBuilder)
{
float x, y, r;
GetAnimatedLengthValues(&x, &y, &r, nullptr);
if (r <= 0.0f) {
return nullptr;
--- a/content/svg/content/src/SVGCircleElement.h
+++ b/content/svg/content/src/SVGCircleElement.h
@@ -25,17 +25,16 @@ protected:
friend nsresult (::NS_NewSVGCircleElement(nsIContent **aResult,
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
public:
// nsSVGSVGElement methods:
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
// WebIDL
already_AddRefed<SVGAnimatedLength> Cx();
already_AddRefed<SVGAnimatedLength> Cy();
already_AddRefed<SVGAnimatedLength> R();
--- a/content/svg/content/src/SVGEllipseElement.cpp
+++ b/content/svg/content/src/SVGEllipseElement.cpp
@@ -3,17 +3,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGEllipseElement.h"
#include "mozilla/dom/SVGEllipseElementBinding.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/PathHelpers.h"
#include "mozilla/RefPtr.h"
-#include "gfxContext.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Ellipse)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@@ -88,27 +87,16 @@ SVGEllipseElement::GetLengthInfo()
{
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
ArrayLength(sLengthInfo));
}
//----------------------------------------------------------------------
// nsSVGPathGeometryElement methods
-void
-SVGEllipseElement::ConstructPath(gfxContext *aCtx)
-{
- RefPtr<DrawTarget> dt = aCtx->GetDrawTarget();
- RefPtr<PathBuilder> builder = dt->CreatePathBuilder(aCtx->CurrentFillRule());
- RefPtr<Path> path = BuildPath(builder);
- if (path) {
- aCtx->SetPath(path);
- }
-}
-
TemporaryRef<Path>
SVGEllipseElement::BuildPath(PathBuilder* aBuilder)
{
float x, y, rx, ry;
GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr);
if (rx <= 0.0f || ry <= 0.0f) {
return nullptr;
--- a/content/svg/content/src/SVGEllipseElement.h
+++ b/content/svg/content/src/SVGEllipseElement.h
@@ -25,17 +25,16 @@ protected:
friend nsresult (::NS_NewSVGEllipseElement(nsIContent **aResult,
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
public:
// nsSVGSVGElement methods:
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
// WebIDL
already_AddRefed<SVGAnimatedLength> Cx();
already_AddRefed<SVGAnimatedLength> Cy();
already_AddRefed<SVGAnimatedLength> Rx();
--- a/content/svg/content/src/SVGImageElement.cpp
+++ b/content/svg/content/src/SVGImageElement.cpp
@@ -7,17 +7,16 @@
#include "mozilla/EventStates.h"
#include "mozilla/dom/SVGImageElement.h"
#include "mozilla/gfx/2D.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "imgINotificationObserver.h"
-#include "gfxContext.h"
#include "mozilla/dom/SVGImageElementBinding.h"
#include "nsContentUtils.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Image)
using namespace mozilla::gfx;
namespace mozilla {
@@ -222,29 +221,16 @@ SVGImageElement::IsAttributeMapped(const
SVGImageElementBase::IsAttributeMapped(name);
}
//----------------------------------------------------------------------
// nsSVGPathGeometryElement methods
/* For the purposes of the update/invalidation logic pretend to
be a rectangle. */
-void
-SVGImageElement::ConstructPath(gfxContext *aCtx)
-{
- float x, y, width, height;
-
- GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
-
- if (width <= 0 || height <= 0)
- return;
-
- aCtx->Rectangle(gfxRect(x, y, width, height));
-}
-
TemporaryRef<Path>
SVGImageElement::BuildPath(PathBuilder* aBuilder)
{
// We get called in order to get bounds for this element, and for
// hit-testing against it. For that we just pretend to be a rectangle.
float x, y, width, height;
GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
--- a/content/svg/content/src/SVGImageElement.h
+++ b/content/svg/content/src/SVGImageElement.h
@@ -48,17 +48,16 @@ public:
bool aCompileEventHandlers) MOZ_OVERRIDE;
virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE;
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;
// nsSVGSVGElement methods:
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
nsresult CopyInnerTo(mozilla::dom::Element* aDest);
--- a/content/svg/content/src/SVGLineElement.cpp
+++ b/content/svg/content/src/SVGLineElement.cpp
@@ -1,17 +1,16 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGLineElement.h"
#include "mozilla/dom/SVGLineElementBinding.h"
#include "mozilla/gfx/2D.h"
-#include "gfxContext.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Line)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@@ -102,27 +101,16 @@ SVGLineElement::GetMarkPoints(nsTArray<n
GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
float angle = atan2(y2 - y1, x2 - x1);
aMarks->AppendElement(nsSVGMark(x1, y1, angle, nsSVGMark::eStart));
aMarks->AppendElement(nsSVGMark(x2, y2, angle, nsSVGMark::eEnd));
}
-void
-SVGLineElement::ConstructPath(gfxContext *aCtx)
-{
- float x1, y1, x2, y2;
-
- GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
-
- aCtx->MoveTo(gfxPoint(x1, y1));
- aCtx->LineTo(gfxPoint(x2, y2));
-}
-
TemporaryRef<Path>
SVGLineElement::BuildPath(PathBuilder* aBuilder)
{
RefPtr<PathBuilder> pathBuilder = aBuilder ? aBuilder : CreatePathBuilder();
float x1, y1, x2, y2;
GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
--- a/content/svg/content/src/SVGLineElement.h
+++ b/content/svg/content/src/SVGLineElement.h
@@ -27,17 +27,16 @@ protected:
public:
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
virtual bool IsMarkable() MOZ_OVERRIDE { return true; }
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) MOZ_OVERRIDE;
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const;
// WebIDL
already_AddRefed<SVGAnimatedLength> X1();
already_AddRefed<SVGAnimatedLength> Y1();
already_AddRefed<SVGAnimatedLength> X2();
--- a/content/svg/content/src/SVGPathData.cpp
+++ b/content/svg/content/src/SVGPathData.cpp
@@ -14,17 +14,16 @@
#include "nsError.h"
#include "nsString.h"
#include "nsSVGPathDataParser.h"
#include "nsSVGPathGeometryElement.h" // for nsSVGMark
#include <stdarg.h>
#include "nsStyleConsts.h"
#include "SVGContentUtils.h"
#include "SVGPathSegUtils.h"
-#include "gfxContext.h"
#include <algorithm>
using namespace mozilla;
using namespace mozilla::gfx;
static bool IsMoveto(uint16_t aSegType)
{
return aSegType == PATHSEG_MOVETO_ABS ||
@@ -261,51 +260,26 @@ ApproximateZeroLengthSubpathSquareCaps(P
// described in the comment above.
Float tinyLength = aStrokeWidth / 512;
aPB->LineTo(aPoint + Point(tinyLength, 0));
aPB->MoveTo(aPoint);
}
-static void
-ApproximateZeroLengthSubpathSquareCaps(const gfxPoint &aPoint, gfxContext *aCtx)
-{
- // Cairo's fixed point fractional part is 8 bits wide, so its device space
- // coordinate granularity is 1/256 pixels. However, to prevent user space
- // |aPoint| and |aPoint + tinyAdvance| being rounded to the same device
- // coordinates, we double this for |tinyAdvance|:
-
- const gfxSize tinyAdvance = aCtx->DeviceToUser(gfxSize(2.0/256.0, 0.0));
-
- aCtx->MoveTo(aPoint);
- aCtx->LineTo(aPoint + gfxPoint(tinyAdvance.width, tinyAdvance.height));
- aCtx->MoveTo(aPoint);
-}
-
#define MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS_TO_DT \
do { \
if (!subpathHasLength && hasLineCaps && aStrokeWidth > 0 && \
subpathContainsNonMoveTo && \
SVGPathSegUtils::IsValidType(prevSegType) && \
(!IsMoveto(prevSegType) || segType == PATHSEG_CLOSEPATH)) { \
ApproximateZeroLengthSubpathSquareCaps(builder, segStart, aStrokeWidth);\
} \
} while(0)
-#define MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS \
- do { \
- if (capsAreSquare && !subpathHasLength && subpathContainsNonArc && \
- SVGPathSegUtils::IsValidType(prevSegType) && \
- (!IsMoveto(prevSegType) || \
- segType == PATHSEG_CLOSEPATH)) { \
- ApproximateZeroLengthSubpathSquareCaps(segStart, aCtx); \
- } \
- } while(0)
-
TemporaryRef<Path>
SVGPathData::BuildPath(PathBuilder* builder,
uint8_t aStrokeLineCap,
Float aStrokeWidth) const
{
if (mData.IsEmpty() || !IsMoveto(SVGPathSegUtils::DecodeType(mData[0]))) {
return nullptr; // paths without an initial moveto are invalid
}
@@ -530,268 +504,16 @@ SVGPathData::BuildPath(PathBuilder* buil
NS_ABORT_IF_FALSE(prevSegType == segType,
"prevSegType should be left at the final segType");
MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS_TO_DT;
return builder->Finish();
}
-void
-SVGPathData::ConstructPath(gfxContext *aCtx) const
-{
- if (mData.IsEmpty() || !IsMoveto(SVGPathSegUtils::DecodeType(mData[0]))) {
- return; // paths without an initial moveto are invalid
- }
-
- bool capsAreSquare = aCtx->CurrentLineCap() == gfxContext::LINE_CAP_SQUARE;
- bool subpathHasLength = false; // visual length
- bool subpathContainsNonArc = false;
-
- uint32_t segType = PATHSEG_UNKNOWN;
- uint32_t prevSegType = PATHSEG_UNKNOWN;
- gfxPoint pathStart(0.0, 0.0); // start point of [sub]path
- gfxPoint segStart(0.0, 0.0);
- gfxPoint segEnd;
- gfxPoint cp1, cp2; // previous bezier's control points
- gfxPoint tcp1, tcp2; // temporaries
-
- // Regarding cp1 and cp2: If the previous segment was a cubic bezier curve,
- // then cp2 is its second control point. If the previous segment was a
- // quadratic curve, then cp1 is its (only) control point.
-
- uint32_t i = 0;
- while (i < mData.Length()) {
- segType = SVGPathSegUtils::DecodeType(mData[i++]);
- uint32_t argCount = SVGPathSegUtils::ArgCountForType(segType);
-
- switch (segType)
- {
- case PATHSEG_CLOSEPATH:
- // set this early to allow drawing of square caps for "M{x},{y} Z":
- subpathContainsNonArc = true;
- MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS;
- segEnd = pathStart;
- aCtx->ClosePath();
- break;
-
- case PATHSEG_MOVETO_ABS:
- MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS;
- pathStart = segEnd = gfxPoint(mData[i], mData[i+1]);
- aCtx->MoveTo(segEnd);
- subpathHasLength = false;
- subpathContainsNonArc = false;
- break;
-
- case PATHSEG_MOVETO_REL:
- MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS;
- pathStart = segEnd = segStart + gfxPoint(mData[i], mData[i+1]);
- aCtx->MoveTo(segEnd);
- subpathHasLength = false;
- subpathContainsNonArc = false;
- break;
-
- case PATHSEG_LINETO_ABS:
- segEnd = gfxPoint(mData[i], mData[i+1]);
- aCtx->LineTo(segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_LINETO_REL:
- segEnd = segStart + gfxPoint(mData[i], mData[i+1]);
- aCtx->LineTo(segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_CUBIC_ABS:
- cp1 = gfxPoint(mData[i], mData[i+1]);
- cp2 = gfxPoint(mData[i+2], mData[i+3]);
- segEnd = gfxPoint(mData[i+4], mData[i+5]);
- aCtx->CurveTo(cp1, cp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_CUBIC_REL:
- cp1 = segStart + gfxPoint(mData[i], mData[i+1]);
- cp2 = segStart + gfxPoint(mData[i+2], mData[i+3]);
- segEnd = segStart + gfxPoint(mData[i+4], mData[i+5]);
- aCtx->CurveTo(cp1, cp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_QUADRATIC_ABS:
- cp1 = gfxPoint(mData[i], mData[i+1]);
- // Convert quadratic curve to cubic curve:
- tcp1 = segStart + (cp1 - segStart) * 2 / 3;
- segEnd = gfxPoint(mData[i+2], mData[i+3]); // set before setting tcp2!
- tcp2 = cp1 + (segEnd - cp1) / 3;
- aCtx->CurveTo(tcp1, tcp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_QUADRATIC_REL:
- cp1 = segStart + gfxPoint(mData[i], mData[i+1]);
- // Convert quadratic curve to cubic curve:
- tcp1 = segStart + (cp1 - segStart) * 2 / 3;
- segEnd = segStart + gfxPoint(mData[i+2], mData[i+3]); // set before setting tcp2!
- tcp2 = cp1 + (segEnd - cp1) / 3;
- aCtx->CurveTo(tcp1, tcp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_ARC_ABS:
- case PATHSEG_ARC_REL:
- {
- gfxPoint radii(mData[i], mData[i+1]);
- segEnd = gfxPoint(mData[i+5], mData[i+6]);
- if (segType == PATHSEG_ARC_REL) {
- segEnd += segStart;
- }
- if (segEnd != segStart) {
- if (radii.x == 0.0f || radii.y == 0.0f) {
- aCtx->LineTo(segEnd);
- } else {
- nsSVGArcConverter converter(ToPoint(segStart), ToPoint(segEnd),
- ToPoint(radii), mData[i+2],
- mData[i+3] != 0, mData[i+4] != 0);
- Point cp1, cp2, segEnd_;
- while (converter.GetNextSegment(&cp1, &cp2, &segEnd_)) {
- aCtx->CurveTo(ThebesPoint(cp1), ThebesPoint(cp2), ThebesPoint(segEnd_));
- }
- segEnd = ThebesPoint(segEnd_);
- }
- }
- if (!subpathHasLength) {
- // Round to make sure the current comparison doesn't fail due to
- // precision issues:
- // XXX kill after all code is converted to float precision
- segStart = ThebesPoint(ToPoint(segStart));
- subpathHasLength = (segEnd != segStart);
- }
- break;
- }
-
- case PATHSEG_LINETO_HORIZONTAL_ABS:
- segEnd = gfxPoint(mData[i], segStart.y);
- aCtx->LineTo(segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_LINETO_HORIZONTAL_REL:
- segEnd = segStart + gfxPoint(mData[i], 0.0f);
- aCtx->LineTo(segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_LINETO_VERTICAL_ABS:
- segEnd = gfxPoint(segStart.x, mData[i]);
- aCtx->LineTo(segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_LINETO_VERTICAL_REL:
- segEnd = segStart + gfxPoint(0.0f, mData[i]);
- aCtx->LineTo(segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
- cp1 = SVGPathSegUtils::IsCubicType(prevSegType) ? segStart * 2 - cp2 : segStart;
- cp2 = gfxPoint(mData[i], mData[i+1]);
- segEnd = gfxPoint(mData[i+2], mData[i+3]);
- aCtx->CurveTo(cp1, cp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
- cp1 = SVGPathSegUtils::IsCubicType(prevSegType) ? segStart * 2 - cp2 : segStart;
- cp2 = segStart + gfxPoint(mData[i], mData[i+1]);
- segEnd = segStart + gfxPoint(mData[i+2], mData[i+3]);
- aCtx->CurveTo(cp1, cp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
- cp1 = SVGPathSegUtils::IsQuadraticType(prevSegType) ? segStart * 2 - cp1 : segStart;
- // Convert quadratic curve to cubic curve:
- tcp1 = segStart + (cp1 - segStart) * 2 / 3;
- segEnd = gfxPoint(mData[i], mData[i+1]); // set before setting tcp2!
- tcp2 = cp1 + (segEnd - cp1) / 3;
- aCtx->CurveTo(tcp1, tcp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1);
- }
- subpathContainsNonArc = true;
- break;
-
- case PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
- cp1 = SVGPathSegUtils::IsQuadraticType(prevSegType) ? segStart * 2 - cp1 : segStart;
- // Convert quadratic curve to cubic curve:
- tcp1 = segStart + (cp1 - segStart) * 2 / 3;
- segEnd = segStart + gfxPoint(mData[i], mData[i+1]); // changed before setting tcp2!
- tcp2 = cp1 + (segEnd - cp1) / 3;
- aCtx->CurveTo(tcp1, tcp2, segEnd);
- if (!subpathHasLength) {
- subpathHasLength = (segEnd != segStart || segEnd != cp1);
- }
- subpathContainsNonArc = true;
- break;
-
- default:
- NS_NOTREACHED("Bad path segment type");
- return; // according to spec we'd use everything up to the bad seg anyway
- }
- i += argCount;
- prevSegType = segType;
- segStart = segEnd;
- }
-
- NS_ABORT_IF_FALSE(i == mData.Length(), "Very, very bad - mData corrupt");
- NS_ABORT_IF_FALSE(prevSegType == segType,
- "prevSegType should be left at the final segType");
-
- MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS;
-}
-
TemporaryRef<Path>
SVGPathData::ToPathForLengthOrPositionMeasuring() const
{
// Since the path that we return will not be used for painting it doesn't
// matter what we pass to CreatePathBuilder as aFillRule. Hawever, we do want
// to pass something other than NS_STYLE_STROKE_LINECAP_SQUARE as
// aStrokeLineCap to avoid the insertion of extra little lines (by
// ApproximateZeroLengthSubpathSquareCaps), in which case the value that we
--- a/content/svg/content/src/SVGPathData.h
+++ b/content/svg/content/src/SVGPathData.h
@@ -15,17 +15,16 @@
#include "mozilla/gfx/Types.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/RefPtr.h"
#include "nsSVGElement.h"
#include "nsTArray.h"
#include <string.h>
-class gfxContext;
class nsSVGPathDataParser; // IWYU pragma: keep
struct nsSVGMark;
namespace mozilla {
/**
* ATTENTION! WARNING! WATCH OUT!!
@@ -161,17 +160,16 @@ public:
/**
* This returns a path without the extra little line segments that
* ApproximateZeroLengthSubpathSquareCaps can insert if we have square-caps.
* See the comment for that function for more info on that.
*/
TemporaryRef<Path> ToPathForLengthOrPositionMeasuring() const;
- void ConstructPath(gfxContext *aCtx) const;
TemporaryRef<Path> BuildPath(PathBuilder* aBuilder,
uint8_t aCapStyle,
Float aStrokeWidth) const;
const_iterator begin() const { return mData.Elements(); }
const_iterator end() const { return mData.Elements() + mData.Length(); }
// memory reporting methods
--- a/content/svg/content/src/SVGPathElement.cpp
+++ b/content/svg/content/src/SVGPathElement.cpp
@@ -17,18 +17,16 @@
#include "mozilla/RefPtr.h"
#include "nsCOMPtr.h"
#include "nsComputedDOMStyle.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsStyleStruct.h"
#include "SVGContentUtils.h"
-class gfxContext;
-
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Path)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
JSObject*
@@ -329,22 +327,16 @@ SVGPathElement::IsMarkable()
}
void
SVGPathElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
{
mD.GetAnimValue().GetMarkerPositioningData(aMarks);
}
-void
-SVGPathElement::ConstructPath(gfxContext *aCtx)
-{
- mD.GetAnimValue().ConstructPath(aCtx);
-}
-
float
SVGPathElement::GetPathLengthScale(PathLengthScaleForType aFor)
{
NS_ABORT_IF_FALSE(aFor == eForTextPath || aFor == eForStroking,
"Unknown enum");
if (mPathLength.IsExplicitlySet()) {
float authorsPathLengthEstimate = mPathLength.GetAnimValue();
if (authorsPathLengthEstimate > 0) {
--- a/content/svg/content/src/SVGPathElement.h
+++ b/content/svg/content/src/SVGPathElement.h
@@ -11,18 +11,16 @@
#include "nsSVGNumber2.h"
#include "nsSVGPathGeometryElement.h"
#include "SVGAnimatedPathSegList.h"
#include "DOMSVGPathSeg.h"
nsresult NS_NewSVGPathElement(nsIContent **aResult,
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
-class gfxContext;
-
typedef nsSVGPathGeometryElement SVGPathElementBase;
namespace mozilla {
class nsISVGPoint;
namespace dom {
@@ -47,17 +45,16 @@ public:
// nsSVGSVGElement methods:
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
virtual bool AttributeDefinesGeometry(const nsIAtom *aName) MOZ_OVERRIDE;
virtual bool IsMarkable() MOZ_OVERRIDE;
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) MOZ_OVERRIDE;
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;
/**
* This returns a path without the extra little line segments that
* ApproximateZeroLengthSubpathSquareCaps can insert if we have square-caps.
* See the comment for that function for more info on that.
*/
virtual TemporaryRef<Path>
--- a/content/svg/content/src/SVGPathSegUtils.cpp
+++ b/content/svg/content/src/SVGPathSegUtils.cpp
@@ -3,17 +3,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h" // MOZ_ARRAY_LENGTH
#include "SVGPathSegUtils.h"
#include "gfx2DGlue.h"
-#include "gfxPoint.h"
#include "nsSVGPathDataParser.h"
#include "nsTextFormatter.h"
using namespace mozilla;
using namespace mozilla::gfx;
static const float PATH_SEG_LENGTH_TOLERANCE = 0.0000001f;
static const uint32_t MAX_RECURSION = 10;
--- a/content/svg/content/src/SVGPolygonElement.cpp
+++ b/content/svg/content/src/SVGPolygonElement.cpp
@@ -1,16 +1,15 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGPolygonElement.h"
#include "mozilla/dom/SVGPolygonElementBinding.h"
-#include "gfxContext.h"
#include "SVGContentUtils.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Polygon)
namespace mozilla {
namespace dom {
JSObject*
@@ -53,19 +52,10 @@ SVGPolygonElement::GetMarkPoints(nsTArra
startMark->angle = SVGContentUtils::AngleBisect(angle, startMark->angle);
// for a polygon (as opposed to a polyline) there's an implicit extra point
// co-located with the start point that nsSVGPolyElement::GetMarkPoints
// doesn't return
aMarks->AppendElement(nsSVGMark(startMark->x, startMark->y, startMark->angle,
nsSVGMark::eEnd));
}
-void
-SVGPolygonElement::ConstructPath(gfxContext *aCtx)
-{
- SVGPolygonElementBase::ConstructPath(aCtx);
- // the difference between a polyline and a polygon is that the
- // polygon is closed:
- aCtx->ClosePath();
-}
-
} // namespace dom
} // namespace mozilla
--- a/content/svg/content/src/SVGPolygonElement.h
+++ b/content/svg/content/src/SVGPolygonElement.h
@@ -23,17 +23,16 @@ protected:
explicit SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
virtual JSObject* WrapNode(JSContext *cx) MOZ_OVERRIDE;
friend nsresult (::NS_NewSVGPolygonElement(nsIContent **aResult,
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
public:
// nsSVGPathGeometryElement methods:
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) MOZ_OVERRIDE;
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGPolygonElement_h
--- a/content/svg/content/src/SVGRectElement.cpp
+++ b/content/svg/content/src/SVGRectElement.cpp
@@ -1,16 +1,15 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGRectElement.h"
#include "nsGkAtoms.h"
-#include "gfxContext.h"
#include "mozilla/dom/SVGRectElementBinding.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/PathHelpers.h"
#include <algorithm>
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Rect)
using namespace mozilla::gfx;
@@ -104,59 +103,16 @@ SVGRectElement::GetLengthInfo()
{
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
ArrayLength(sLengthInfo));
}
//----------------------------------------------------------------------
// nsSVGPathGeometryElement methods
-void
-SVGRectElement::ConstructPath(gfxContext *aCtx)
-{
- float x, y, width, height, rx, ry;
-
- GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr);
-
- /* In a perfect world, this would be handled by the DOM, and
- return a DOM exception. */
- if (width <= 0 || height <= 0)
- return;
-
- rx = std::max(rx, 0.0f);
- ry = std::max(ry, 0.0f);
-
- /* optimize the no rounded corners case */
- if (rx == 0 && ry == 0) {
- aCtx->Rectangle(gfxRect(x, y, width, height));
- return;
- }
-
- /* If either the 'rx' or the 'ry' attribute isn't set, then we
- have to set it to the value of the other. */
- bool hasRx = mLengthAttributes[ATTR_RX].IsExplicitlySet();
- bool hasRy = mLengthAttributes[ATTR_RY].IsExplicitlySet();
- if (hasRx && !hasRy)
- ry = rx;
- else if (hasRy && !hasRx)
- rx = ry;
-
- /* Clamp rx and ry to half the rect's width and height respectively. */
- float halfWidth = width/2;
- float halfHeight = height/2;
- if (rx > halfWidth)
- rx = halfWidth;
- if (ry > halfHeight)
- ry = halfHeight;
-
- gfxSize corner(rx, ry);
- aCtx->RoundedRectangle(gfxRect(x, y, width, height),
- gfxCornerSizes(corner, corner, corner, corner));
-}
-
TemporaryRef<Path>
SVGRectElement::BuildPath(PathBuilder* aBuilder)
{
float x, y, width, height, rx, ry;
GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr);
if (width <= 0 || height <= 0) {
return nullptr;
--- a/content/svg/content/src/SVGRectElement.h
+++ b/content/svg/content/src/SVGRectElement.h
@@ -25,17 +25,16 @@ protected:
friend nsresult (::NS_NewSVGRectElement(nsIContent **aResult,
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
public:
// nsSVGSVGElement methods:
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
// WebIDL
already_AddRefed<SVGAnimatedLength> X();
already_AddRefed<SVGAnimatedLength> Y();
already_AddRefed<SVGAnimatedLength> Height();
--- a/content/svg/content/src/nsSVGPathGeometryElement.h
+++ b/content/svg/content/src/nsSVGPathGeometryElement.h
@@ -21,18 +21,16 @@ struct nsSVGMark {
};
float x, y, angle;
Type type;
nsSVGMark(float aX, float aY, float aAngle, Type aType) :
x(aX), y(aY), angle(aAngle), type(aType) {}
};
-class gfxContext;
-
typedef mozilla::dom::SVGGraphicsElement nsSVGPathGeometryElementBase;
class nsSVGPathGeometryElement : public nsSVGPathGeometryElementBase
{
protected:
typedef mozilla::gfx::FillRule FillRule;
typedef mozilla::gfx::Float Float;
typedef mozilla::gfx::Path Path;
@@ -51,17 +49,16 @@ public:
*
* This could be moved up to a more general class so it can be used for non-leaf
* elements, but that would require care and for now there's no need.
*/
bool GeometryDependsOnCoordCtx();
virtual bool IsMarkable();
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
- virtual void ConstructPath(gfxContext *aCtx) = 0;
/**
* Returns a Path that can be used to paint, hit-test or calculate bounds for
* this element. May return nullptr if there is no [valid] path.
*/
virtual mozilla::TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) = 0;
virtual mozilla::TemporaryRef<Path> GetPathForLengthOrPositionMeasuring();
--- a/content/svg/content/src/nsSVGPolyElement.cpp
+++ b/content/svg/content/src/nsSVGPolyElement.cpp
@@ -1,16 +1,15 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsSVGPolyElement.h"
#include "DOMSVGPointList.h"
-#include "gfxContext.h"
#include "mozilla/gfx/2D.h"
#include "SVGContentUtils.h"
using namespace mozilla;
using namespace mozilla::gfx;
//----------------------------------------------------------------------
// nsISupports methods
@@ -116,30 +115,16 @@ nsSVGPolyElement::GetMarkPoints(nsTArray
px = x;
py = y;
}
aMarks->LastElement().angle = prevAngle;
aMarks->LastElement().type = nsSVGMark::eEnd;
}
-void
-nsSVGPolyElement::ConstructPath(gfxContext *aCtx)
-{
- const SVGPointList &points = mPoints.GetAnimValue();
-
- if (!points.Length())
- return;
-
- aCtx->MoveTo(points[0]);
- for (uint32_t i = 1; i < points.Length(); ++i) {
- aCtx->LineTo(points[i]);
- }
-}
-
TemporaryRef<Path>
nsSVGPolyElement::BuildPath(PathBuilder* aBuilder)
{
const SVGPointList &points = mPoints.GetAnimValue();
if (points.IsEmpty()) {
return nullptr;
}
--- a/content/svg/content/src/nsSVGPolyElement.h
+++ b/content/svg/content/src/nsSVGPolyElement.h
@@ -7,18 +7,16 @@
#define NS_SVGPOLYELEMENT_H_
#include "mozilla/Attributes.h"
#include "nsSVGPathGeometryElement.h"
#include "SVGAnimatedPointList.h"
typedef nsSVGPathGeometryElement nsSVGPolyElementBase;
-class gfxContext;
-
namespace mozilla {
class DOMSVGPointList;
}
class nsSVGPolyElement : public nsSVGPolyElementBase
{
protected:
explicit nsSVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
@@ -42,17 +40,16 @@ public:
// nsSVGElement methods:
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
virtual bool AttributeDefinesGeometry(const nsIAtom *aName) MOZ_OVERRIDE;
virtual bool IsMarkable() MOZ_OVERRIDE { return true; }
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) MOZ_OVERRIDE;
- virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual mozilla::TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;
// WebIDL
already_AddRefed<mozilla::DOMSVGPointList> Points();
already_AddRefed<mozilla::DOMSVGPointList> AnimatedPoints();
protected:
SVGAnimatedPointList mPoints;
--- a/content/svg/content/src/nsSVGTransform.cpp
+++ b/content/svg/content/src/nsSVGTransform.cpp
@@ -109,19 +109,19 @@ nsSVGTransform::SetScale(float aSx, floa
mOriginY = 0.f;
}
void
nsSVGTransform::SetRotate(float aAngle, float aCx, float aCy)
{
mType = SVG_TRANSFORM_ROTATE;
mMatrix.Reset();
- mMatrix.Translate(gfxPoint(aCx, aCy));
+ mMatrix.Translate(aCx, aCy);
mMatrix.Rotate(aAngle*kRadPerDegree);
- mMatrix.Translate(gfxPoint(-aCx, -aCy));
+ mMatrix.Translate(-aCx, -aCy);
mAngle = aAngle;
mOriginX = aCx;
mOriginY = aCy;
}
nsresult
nsSVGTransform::SetSkewX(float aAngle)
{
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -751,40 +751,16 @@ nsSVGPathGeometryFrame::Render(gfxContex
}
drawTarget->Stroke(path, strokePattern, strokeOptions,
DrawOptions(1.0f, CompositionOp::OP_OVER, aaMode));
}
}
}
void
-nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext,
- const Matrix &aTransform)
-{
- if (aTransform.IsSingular()) {
- aContext->SetMatrix(gfxMatrix());
- aContext->NewPath();
- return;
- }
-
- aContext->SetMatrix(
- aContext->CurrentMatrix().PreMultiply(ThebesMatrix(aTransform)).
- NudgeToIntegers());
-
- // Hack to let SVGPathData::ConstructPath know if we have square caps:
- const nsStyleSVG* style = StyleSVG();
- if (style->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_SQUARE) {
- aContext->SetLineCap(gfxContext::LINE_CAP_SQUARE);
- }
-
- aContext->NewPath();
- static_cast<nsSVGPathGeometryElement*>(mContent)->ConstructPath(aContext);
-}
-
-void
nsSVGPathGeometryFrame::PaintMarkers(nsRenderingContext* aContext,
const gfxMatrix& aTransform)
{
gfxTextContextPaint *contextPaint =
(gfxTextContextPaint*)aContext->GetDrawTarget()->GetUserData(&gfxTextContextPaint::sUserDataKey);
if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
MarkerProperties properties = GetMarkerProperties(this);
--- a/layout/svg/nsSVGPathGeometryFrame.h
+++ b/layout/svg/nsSVGPathGeometryFrame.h
@@ -106,17 +106,16 @@ protected:
virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) MOZ_OVERRIDE;
virtual nsRect GetCoveredRegion() MOZ_OVERRIDE;
virtual void ReflowSVG() MOZ_OVERRIDE;
virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags) MOZ_OVERRIDE;
virtual bool IsDisplayContainer() MOZ_OVERRIDE { return false; }
- void GeneratePath(gfxContext *aContext, const Matrix &aTransform);
/**
* This function returns a set of bit flags indicating which parts of the
* element (fill, stroke, bounds) should intercept pointer events. It takes
* into account the type of element and the value of the 'pointer-events'
* property on the element.
*/
virtual uint16_t GetHitTestFlags();
private: