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 virtual SVGAnimatedTransformList
* GetAnimatedTransformList(
49 uint32_t aFlags
= 0) override
;
50 nsStaticAtom
* GetTransformListAttrName() const override
{
51 return nsGkAtoms::gradientTransform
;
55 already_AddRefed
<DOMSVGAnimatedEnumeration
> GradientUnits();
56 already_AddRefed
<DOMSVGAnimatedTransformList
> GradientTransform();
57 already_AddRefed
<DOMSVGAnimatedEnumeration
> SpreadMethod();
58 already_AddRefed
<DOMSVGAnimatedString
> Href();
61 EnumAttributesInfo
GetEnumInfo() override
;
62 StringAttributesInfo
GetStringInfo() override
;
64 enum { GRADIENTUNITS
, SPREADMETHOD
};
65 SVGAnimatedEnumeration mEnumAttributes
[2];
66 static SVGEnumMapping sSpreadMethodMap
[];
67 static EnumInfo sEnumInfo
[2];
69 enum { HREF
, XLINK_HREF
};
70 SVGAnimatedString mStringAttributes
[2];
71 static StringInfo sStringInfo
[2];
73 // SVGGradientElement values
74 UniquePtr
<SVGAnimatedTransformList
> mGradientTransform
;
77 //---------------------Linear Gradients------------------------
79 using SVGLinearGradientElementBase
= SVGGradientElement
;
81 class SVGLinearGradientElement final
: public SVGLinearGradientElementBase
{
82 friend class mozilla::SVGLinearGradientFrame
;
83 friend nsresult(::NS_NewSVGLinearGradientElement(
85 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
88 explicit SVGLinearGradientElement(
89 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
90 virtual JSObject
* WrapNode(JSContext
* aCx
,
91 JS::Handle
<JSObject
*> aGivenProto
) override
;
94 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
97 already_AddRefed
<DOMSVGAnimatedLength
> X1();
98 already_AddRefed
<DOMSVGAnimatedLength
> Y1();
99 already_AddRefed
<DOMSVGAnimatedLength
> X2();
100 already_AddRefed
<DOMSVGAnimatedLength
> Y2();
103 LengthAttributesInfo
GetLengthInfo() override
;
105 enum { ATTR_X1
, ATTR_Y1
, ATTR_X2
, ATTR_Y2
};
106 SVGAnimatedLength mLengthAttributes
[4];
107 static LengthInfo sLengthInfo
[4];
110 //-------------------------- Radial Gradients ----------------------------
112 using SVGRadialGradientElementBase
= SVGGradientElement
;
114 class SVGRadialGradientElement final
: public SVGRadialGradientElementBase
{
115 friend class mozilla::SVGRadialGradientFrame
;
116 friend nsresult(::NS_NewSVGRadialGradientElement(
117 nsIContent
** aResult
,
118 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
121 explicit SVGRadialGradientElement(
122 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
123 virtual JSObject
* WrapNode(JSContext
* aCx
,
124 JS::Handle
<JSObject
*> aGivenProto
) override
;
127 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
130 already_AddRefed
<DOMSVGAnimatedLength
> Cx();
131 already_AddRefed
<DOMSVGAnimatedLength
> Cy();
132 already_AddRefed
<DOMSVGAnimatedLength
> R();
133 already_AddRefed
<DOMSVGAnimatedLength
> Fx();
134 already_AddRefed
<DOMSVGAnimatedLength
> Fy();
135 already_AddRefed
<DOMSVGAnimatedLength
> Fr();
138 LengthAttributesInfo
GetLengthInfo() override
;
140 enum { ATTR_CX
, ATTR_CY
, ATTR_R
, ATTR_FX
, ATTR_FY
, ATTR_FR
};
141 SVGAnimatedLength mLengthAttributes
[6];
142 static LengthInfo sLengthInfo
[6];
146 } // namespace mozilla
148 #endif // DOM_SVG_SVGGRADIENTELEMENT_H_