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_SVGGRADIENTELEMENT_H_
8 #define DOM_SVG_SVGGRADIENTELEMENT_H_
10 #include "SVGAnimatedEnumeration.h"
11 #include "SVGAnimatedLength.h"
12 #include "SVGAnimatedString.h"
13 #include "SVGAnimatedTransformList.h"
14 #include "mozilla/dom/SVGElement.h"
15 #include "mozilla/UniquePtr.h"
17 nsresult
NS_NewSVGLinearGradientElement(
18 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
19 nsresult
NS_NewSVGRadialGradientElement(
20 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
23 class SVGGradientFrame
;
24 class SVGLinearGradientFrame
;
25 class SVGRadialGradientFrame
;
29 class DOMSVGAnimatedTransformList
;
31 //--------------------- Gradients------------------------
33 using SVGGradientElementBase
= SVGElement
;
35 class SVGGradientElement
: public SVGGradientElementBase
{
36 friend class mozilla::SVGGradientFrame
;
39 explicit SVGGradientElement(
40 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
41 JSObject
* WrapNode(JSContext
* aCx
,
42 JS::Handle
<JSObject
*> aGivenProto
) override
= 0;
46 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
= 0;
48 SVGAnimatedTransformList
* GetAnimatedTransformList(
49 uint32_t aFlags
= 0) override
;
50 nsStaticAtom
* GetTransformListAttrName() const override
{
51 return nsGkAtoms::gradientTransform
;
53 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* aAttribute
) const override
;
56 already_AddRefed
<DOMSVGAnimatedEnumeration
> GradientUnits();
57 already_AddRefed
<DOMSVGAnimatedTransformList
> GradientTransform();
58 already_AddRefed
<DOMSVGAnimatedEnumeration
> SpreadMethod();
59 already_AddRefed
<DOMSVGAnimatedString
> Href();
62 EnumAttributesInfo
GetEnumInfo() override
;
63 StringAttributesInfo
GetStringInfo() override
;
65 enum { GRADIENTUNITS
, SPREADMETHOD
};
66 SVGAnimatedEnumeration mEnumAttributes
[2];
67 static SVGEnumMapping sSpreadMethodMap
[];
68 static EnumInfo sEnumInfo
[2];
70 enum { HREF
, XLINK_HREF
};
71 SVGAnimatedString mStringAttributes
[2];
72 static StringInfo sStringInfo
[2];
74 // SVGGradientElement values
75 UniquePtr
<SVGAnimatedTransformList
> mGradientTransform
;
78 //---------------------Linear Gradients------------------------
80 using SVGLinearGradientElementBase
= SVGGradientElement
;
82 class SVGLinearGradientElement final
: public SVGLinearGradientElementBase
{
83 friend class mozilla::SVGLinearGradientFrame
;
84 friend nsresult(::NS_NewSVGLinearGradientElement(
86 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
89 explicit SVGLinearGradientElement(
90 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
91 virtual JSObject
* WrapNode(JSContext
* aCx
,
92 JS::Handle
<JSObject
*> aGivenProto
) override
;
95 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
98 already_AddRefed
<DOMSVGAnimatedLength
> X1();
99 already_AddRefed
<DOMSVGAnimatedLength
> Y1();
100 already_AddRefed
<DOMSVGAnimatedLength
> X2();
101 already_AddRefed
<DOMSVGAnimatedLength
> Y2();
104 LengthAttributesInfo
GetLengthInfo() override
;
106 enum { ATTR_X1
, ATTR_Y1
, ATTR_X2
, ATTR_Y2
};
107 SVGAnimatedLength mLengthAttributes
[4];
108 static LengthInfo sLengthInfo
[4];
111 //-------------------------- Radial Gradients ----------------------------
113 using SVGRadialGradientElementBase
= SVGGradientElement
;
115 class SVGRadialGradientElement final
: public SVGRadialGradientElementBase
{
116 friend class mozilla::SVGRadialGradientFrame
;
117 friend nsresult(::NS_NewSVGRadialGradientElement(
118 nsIContent
** aResult
,
119 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
122 explicit SVGRadialGradientElement(
123 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
124 virtual JSObject
* WrapNode(JSContext
* aCx
,
125 JS::Handle
<JSObject
*> aGivenProto
) override
;
128 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
131 already_AddRefed
<DOMSVGAnimatedLength
> Cx();
132 already_AddRefed
<DOMSVGAnimatedLength
> Cy();
133 already_AddRefed
<DOMSVGAnimatedLength
> R();
134 already_AddRefed
<DOMSVGAnimatedLength
> Fx();
135 already_AddRefed
<DOMSVGAnimatedLength
> Fy();
136 already_AddRefed
<DOMSVGAnimatedLength
> Fr();
139 LengthAttributesInfo
GetLengthInfo() override
;
141 enum { ATTR_CX
, ATTR_CY
, ATTR_R
, ATTR_FX
, ATTR_FY
, ATTR_FR
};
142 SVGAnimatedLength mLengthAttributes
[6];
143 static LengthInfo sLengthInfo
[6];
147 } // namespace mozilla
149 #endif // DOM_SVG_SVGGRADIENTELEMENT_H_