1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is the Mozilla SVG project.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Scooter Morris.
19 : * Portions created by the Initial Developer are Copyright (C) 2004
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Scooter Morris <scootermorris@comcast.net>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef __NS_SVGGRADIENTELEMENT_H__
40 : #define __NS_SVGGRADIENTELEMENT_H__
41 :
42 : #include "nsIDOMSVGURIReference.h"
43 : #include "nsIDOMSVGGradientElement.h"
44 : #include "DOMSVGTests.h"
45 : #include "nsIDOMSVGUnitTypes.h"
46 : #include "nsSVGStylableElement.h"
47 : #include "nsSVGLength2.h"
48 : #include "nsSVGEnum.h"
49 : #include "nsSVGString.h"
50 : #include "SVGAnimatedTransformList.h"
51 :
52 : //--------------------- Gradients------------------------
53 :
54 : typedef nsSVGStylableElement nsSVGGradientElementBase;
55 :
56 : class nsSVGGradientElement : public nsSVGGradientElementBase,
57 : public DOMSVGTests,
58 : public nsIDOMSVGURIReference,
59 : public nsIDOMSVGUnitTypes
60 0 : {
61 : friend class nsSVGGradientFrame;
62 :
63 : protected:
64 : nsSVGGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
65 :
66 : public:
67 : // interfaces:
68 : NS_DECL_ISUPPORTS_INHERITED
69 :
70 : // Gradient Element
71 : NS_DECL_NSIDOMSVGGRADIENTELEMENT
72 :
73 : // URI Reference
74 : NS_DECL_NSIDOMSVGURIREFERENCE
75 :
76 : // nsIContent
77 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
78 :
79 : virtual mozilla::SVGAnimatedTransformList* GetAnimatedTransformList();
80 0 : virtual nsIAtom* GetTransformListAttrName() const {
81 0 : return nsGkAtoms::gradientTransform;
82 : }
83 :
84 : protected:
85 : virtual EnumAttributesInfo GetEnumInfo();
86 : virtual StringAttributesInfo GetStringInfo();
87 :
88 : enum { GRADIENTUNITS, SPREADMETHOD };
89 : nsSVGEnum mEnumAttributes[2];
90 : static nsSVGEnumMapping sSpreadMethodMap[];
91 : static EnumInfo sEnumInfo[2];
92 :
93 : enum { HREF };
94 : nsSVGString mStringAttributes[1];
95 : static StringInfo sStringInfo[1];
96 :
97 : // nsIDOMSVGGradientElement values
98 : nsAutoPtr<mozilla::SVGAnimatedTransformList> mGradientTransform;
99 : };
100 :
101 : //---------------------Linear Gradients------------------------
102 :
103 : typedef nsSVGGradientElement nsSVGLinearGradientElementBase;
104 :
105 : class nsSVGLinearGradientElement : public nsSVGLinearGradientElementBase,
106 : public nsIDOMSVGLinearGradientElement
107 0 : {
108 : friend class nsSVGLinearGradientFrame;
109 :
110 : protected:
111 : friend nsresult NS_NewSVGLinearGradientElement(nsIContent **aResult,
112 : already_AddRefed<nsINodeInfo> aNodeInfo);
113 : nsSVGLinearGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
114 :
115 : public:
116 : // interfaces:
117 : NS_DECL_ISUPPORTS_INHERITED
118 :
119 : // Gradient Element
120 0 : NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(nsSVGLinearGradientElementBase::)
121 :
122 : // Linear Gradient
123 : NS_DECL_NSIDOMSVGLINEARGRADIENTELEMENT
124 :
125 : // The Gradient Element base class implements these
126 0 : NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLinearGradientElementBase::)
127 :
128 0 : NS_FORWARD_NSIDOMNODE(nsSVGLinearGradientElementBase::)
129 0 : NS_FORWARD_NSIDOMELEMENT(nsSVGLinearGradientElementBase::)
130 :
131 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
132 :
133 : virtual nsXPCClassInfo* GetClassInfo();
134 : protected:
135 :
136 : virtual LengthAttributesInfo GetLengthInfo();
137 :
138 : // nsIDOMSVGLinearGradientElement values
139 : enum { X1, Y1, X2, Y2 };
140 : nsSVGLength2 mLengthAttributes[4];
141 : static LengthInfo sLengthInfo[4];
142 : };
143 :
144 : //-------------------------- Radial Gradients ----------------------------
145 :
146 : typedef nsSVGGradientElement nsSVGRadialGradientElementBase;
147 :
148 : class nsSVGRadialGradientElement : public nsSVGRadialGradientElementBase,
149 : public nsIDOMSVGRadialGradientElement
150 0 : {
151 : friend class nsSVGRadialGradientFrame;
152 :
153 : protected:
154 : friend nsresult NS_NewSVGRadialGradientElement(nsIContent **aResult,
155 : already_AddRefed<nsINodeInfo> aNodeInfo);
156 : nsSVGRadialGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
157 :
158 : public:
159 : // interfaces:
160 :
161 : NS_DECL_ISUPPORTS_INHERITED
162 :
163 : // Gradient Element
164 0 : NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(nsSVGRadialGradientElementBase::)
165 :
166 : // Radial Gradient
167 : NS_DECL_NSIDOMSVGRADIALGRADIENTELEMENT
168 :
169 : // xxx I wish we could use virtual inheritance
170 0 : NS_FORWARD_NSIDOMNODE(nsSVGRadialGradientElementBase::)
171 0 : NS_FORWARD_NSIDOMELEMENT(nsSVGRadialGradientElementBase::)
172 0 : NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRadialGradientElementBase::)
173 :
174 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
175 :
176 : virtual nsXPCClassInfo* GetClassInfo();
177 : protected:
178 :
179 : virtual LengthAttributesInfo GetLengthInfo();
180 :
181 : // nsIDOMSVGRadialGradientElement values
182 : enum { CX, CY, R, FX, FY };
183 : nsSVGLength2 mLengthAttributes[5];
184 : static LengthInfo sLengthInfo[5];
185 : };
186 :
187 : #endif
|