1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_SVG_SVGPATHELEMENT_H_
8 #define DOM_SVG_SVGPATHELEMENT_H_
10 #include "mozilla/gfx/2D.h"
11 #include "mozilla/RefPtr.h"
12 #include "SVGAnimatedPathSegList.h"
13 #include "SVGGeometryElement.h"
14 #include "DOMSVGPathSeg.h"
16 nsresult
NS_NewSVGPathElement(
17 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
23 using SVGPathElementBase
= SVGGeometryElement
;
25 class SVGPathElement final
: public SVGPathElementBase
{
26 using Path
= mozilla::gfx::Path
;
29 friend nsresult(::NS_NewSVGPathElement(
31 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
32 virtual JSObject
* WrapNode(JSContext
* cx
,
33 JS::Handle
<JSObject
*> aGivenProto
) override
;
34 explicit SVGPathElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
37 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
39 // nsIContent interface
40 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* name
) const override
;
42 // SVGSVGElement methods:
43 virtual bool HasValidDimensions() const override
;
45 // SVGGeometryElement methods:
46 virtual bool AttributeDefinesGeometry(const nsAtom
* aName
) override
;
47 virtual bool IsMarkable() override
;
48 virtual void GetMarkPoints(nsTArray
<SVGMark
>* aMarks
) override
;
49 virtual already_AddRefed
<Path
> BuildPath(PathBuilder
* aBuilder
) override
;
52 * This returns a path without the extra little line segments that
53 * ApproximateZeroLengthSubpathSquareCaps can insert if we have square-caps.
54 * See the comment for that function for more info on that.
56 virtual already_AddRefed
<Path
> GetOrBuildPathForMeasuring() override
;
58 bool GetDistancesFromOriginToEndsOfVisibleSegments(
59 FallibleTArray
<double>* aOutput
) override
{
60 return mD
.GetAnimValue().GetDistancesFromOriginToEndsOfVisibleSegments(
64 // nsIContent interface
65 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
67 virtual SVGAnimatedPathSegList
* GetAnimPathSegList() override
{ return &mD
; }
69 virtual nsStaticAtom
* GetPathDataAttrName() const override
{
74 uint32_t GetPathSegAtLength(float distance
);
75 already_AddRefed
<DOMSVGPathSegClosePath
> CreateSVGPathSegClosePath();
76 already_AddRefed
<DOMSVGPathSegMovetoAbs
> CreateSVGPathSegMovetoAbs(float x
,
78 already_AddRefed
<DOMSVGPathSegMovetoRel
> CreateSVGPathSegMovetoRel(float x
,
80 already_AddRefed
<DOMSVGPathSegLinetoAbs
> CreateSVGPathSegLinetoAbs(float x
,
82 already_AddRefed
<DOMSVGPathSegLinetoRel
> CreateSVGPathSegLinetoRel(float x
,
84 already_AddRefed
<DOMSVGPathSegCurvetoCubicAbs
>
85 CreateSVGPathSegCurvetoCubicAbs(float x
, float y
, float x1
, float y1
,
87 already_AddRefed
<DOMSVGPathSegCurvetoCubicRel
>
88 CreateSVGPathSegCurvetoCubicRel(float x
, float y
, float x1
, float y1
,
90 already_AddRefed
<DOMSVGPathSegCurvetoQuadraticAbs
>
91 CreateSVGPathSegCurvetoQuadraticAbs(float x
, float y
, float x1
, float y1
);
92 already_AddRefed
<DOMSVGPathSegCurvetoQuadraticRel
>
93 CreateSVGPathSegCurvetoQuadraticRel(float x
, float y
, float x1
, float y1
);
94 already_AddRefed
<DOMSVGPathSegArcAbs
> CreateSVGPathSegArcAbs(
95 float x
, float y
, float r1
, float r2
, float angle
, bool largeArcFlag
,
97 already_AddRefed
<DOMSVGPathSegArcRel
> CreateSVGPathSegArcRel(
98 float x
, float y
, float r1
, float r2
, float angle
, bool largeArcFlag
,
100 already_AddRefed
<DOMSVGPathSegLinetoHorizontalAbs
>
101 CreateSVGPathSegLinetoHorizontalAbs(float x
);
102 already_AddRefed
<DOMSVGPathSegLinetoHorizontalRel
>
103 CreateSVGPathSegLinetoHorizontalRel(float x
);
104 already_AddRefed
<DOMSVGPathSegLinetoVerticalAbs
>
105 CreateSVGPathSegLinetoVerticalAbs(float y
);
106 already_AddRefed
<DOMSVGPathSegLinetoVerticalRel
>
107 CreateSVGPathSegLinetoVerticalRel(float y
);
108 already_AddRefed
<DOMSVGPathSegCurvetoCubicSmoothAbs
>
109 CreateSVGPathSegCurvetoCubicSmoothAbs(float x
, float y
, float x2
, float y2
);
110 already_AddRefed
<DOMSVGPathSegCurvetoCubicSmoothRel
>
111 CreateSVGPathSegCurvetoCubicSmoothRel(float x
, float y
, float x2
, float y2
);
112 already_AddRefed
<DOMSVGPathSegCurvetoQuadraticSmoothAbs
>
113 CreateSVGPathSegCurvetoQuadraticSmoothAbs(float x
, float y
);
114 already_AddRefed
<DOMSVGPathSegCurvetoQuadraticSmoothRel
>
115 CreateSVGPathSegCurvetoQuadraticSmoothRel(float x
, float y
);
116 already_AddRefed
<DOMSVGPathSegList
> PathSegList();
117 already_AddRefed
<DOMSVGPathSegList
> AnimatedPathSegList();
120 SVGAnimatedPathSegList mD
;
124 } // namespace mozilla
126 #endif // DOM_SVG_SVGPATHELEMENT_H_