no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / svg / SVGPathElement.h
blob362ba1bfcc2559feee746c9c4351a9557ae5c7a2
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);
19 namespace mozilla::dom {
21 using SVGPathElementBase = SVGGeometryElement;
23 class SVGPathElement final : public SVGPathElementBase {
24 using Path = mozilla::gfx::Path;
26 protected:
27 friend nsresult(::NS_NewSVGPathElement(
28 nsIContent** aResult,
29 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
30 JSObject* WrapNode(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
31 explicit SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
33 void GetAsSimplePath(SimplePath* aSimplePath) override;
35 public:
36 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
38 // nsIContent interface
39 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override;
41 // SVGSVGElement methods:
42 bool HasValidDimensions() const override;
44 // SVGGeometryElement methods:
45 bool AttributeDefinesGeometry(const nsAtom* aName) override;
46 bool IsMarkable() override;
47 void GetMarkPoints(nsTArray<SVGMark>* aMarks) override;
49 * Note: This function maps d attribute to CSS d property, and we don't flush
50 * style in this function because some callers don't need it, so if the caller
51 * needs style to be flushed (e.g. DOM APIs), the caller should flush style
52 * before calling this.
54 already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
56 /**
57 * This returns a path without the extra little line segments that
58 * ApproximateZeroLengthSubpathSquareCaps can insert if we have square-caps.
59 * See the comment for that function for more info on that.
61 * Note: This function maps d attribute to CSS d property, and we don't flush
62 * style in this function because some callers don't need it, so if the caller
63 * needs style to be flushed (e.g. DOM APIs), the caller should flush style
64 * before calling this.
66 already_AddRefed<Path> GetOrBuildPathForMeasuring() override;
68 bool GetDistancesFromOriginToEndsOfVisibleSegments(
69 FallibleTArray<double>* aOutput) override;
71 bool IsClosedLoop() const override;
73 // nsIContent interface
74 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
76 SVGAnimatedPathSegList* GetAnimPathSegList() override { return &mD; }
78 nsStaticAtom* GetPathDataAttrName() const override { return nsGkAtoms::d; }
80 // WebIDL
81 MOZ_CAN_RUN_SCRIPT uint32_t GetPathSegAtLength(float distance);
82 already_AddRefed<DOMSVGPathSegClosePath> CreateSVGPathSegClosePath();
83 already_AddRefed<DOMSVGPathSegMovetoAbs> CreateSVGPathSegMovetoAbs(float x,
84 float y);
85 already_AddRefed<DOMSVGPathSegMovetoRel> CreateSVGPathSegMovetoRel(float x,
86 float y);
87 already_AddRefed<DOMSVGPathSegLinetoAbs> CreateSVGPathSegLinetoAbs(float x,
88 float y);
89 already_AddRefed<DOMSVGPathSegLinetoRel> CreateSVGPathSegLinetoRel(float x,
90 float y);
91 already_AddRefed<DOMSVGPathSegCurvetoCubicAbs>
92 CreateSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1,
93 float x2, float y2);
94 already_AddRefed<DOMSVGPathSegCurvetoCubicRel>
95 CreateSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1,
96 float x2, float y2);
97 already_AddRefed<DOMSVGPathSegCurvetoQuadraticAbs>
98 CreateSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
99 already_AddRefed<DOMSVGPathSegCurvetoQuadraticRel>
100 CreateSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1);
101 already_AddRefed<DOMSVGPathSegArcAbs> CreateSVGPathSegArcAbs(
102 float x, float y, float r1, float r2, float angle, bool largeArcFlag,
103 bool sweepFlag);
104 already_AddRefed<DOMSVGPathSegArcRel> CreateSVGPathSegArcRel(
105 float x, float y, float r1, float r2, float angle, bool largeArcFlag,
106 bool sweepFlag);
107 already_AddRefed<DOMSVGPathSegLinetoHorizontalAbs>
108 CreateSVGPathSegLinetoHorizontalAbs(float x);
109 already_AddRefed<DOMSVGPathSegLinetoHorizontalRel>
110 CreateSVGPathSegLinetoHorizontalRel(float x);
111 already_AddRefed<DOMSVGPathSegLinetoVerticalAbs>
112 CreateSVGPathSegLinetoVerticalAbs(float y);
113 already_AddRefed<DOMSVGPathSegLinetoVerticalRel>
114 CreateSVGPathSegLinetoVerticalRel(float y);
115 already_AddRefed<DOMSVGPathSegCurvetoCubicSmoothAbs>
116 CreateSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
117 already_AddRefed<DOMSVGPathSegCurvetoCubicSmoothRel>
118 CreateSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2);
119 already_AddRefed<DOMSVGPathSegCurvetoQuadraticSmoothAbs>
120 CreateSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
121 already_AddRefed<DOMSVGPathSegCurvetoQuadraticSmoothRel>
122 CreateSVGPathSegCurvetoQuadraticSmoothRel(float x, float y);
123 already_AddRefed<DOMSVGPathSegList> PathSegList();
124 already_AddRefed<DOMSVGPathSegList> AnimatedPathSegList();
126 static bool IsDPropertyChangedViaCSS(const ComputedStyle& aNewStyle,
127 const ComputedStyle& aOldStyle);
129 protected:
130 SVGAnimatedPathSegList mD;
133 } // namespace mozilla::dom
135 #endif // DOM_SVG_SVGPATHELEMENT_H_