|
1 /* |
|
2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
|
3 2004, 2005 Rob Buis <buis@kde.org> |
|
4 Copyright (C) Research In Motion Limited 2010. All rights reserved. |
|
5 |
|
6 Based on khtml code by: |
|
7 Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org) |
|
8 (C) 2000 Antti Koivisto (koivisto@kde.org) |
|
9 (C) 2000-2003 Dirk Mueller (mueller@kde.org) |
|
10 (C) 2002-2003 Apple Computer, Inc. |
|
11 |
|
12 This library is free software; you can redistribute it and/or |
|
13 modify it under the terms of the GNU Library General Public |
|
14 License as published by the Free Software Foundation; either |
|
15 version 2 of the License, or (at your option) any later version. |
|
16 |
|
17 This library is distributed in the hope that it will be useful, |
|
18 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
20 Library General Public License for more details. |
|
21 |
|
22 You should have received a copy of the GNU Library General Public License |
|
23 along with this library; see the file COPYING.LIB. If not, write to |
|
24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
25 Boston, MA 02110-1301, USA. |
|
26 */ |
|
27 |
|
28 #ifndef SVGRenderStyleDefs_h |
|
29 #define SVGRenderStyleDefs_h |
|
30 |
|
31 #if ENABLE(SVG) |
|
32 |
|
33 #include "Color.h" |
|
34 #include "PlatformString.h" |
|
35 #include "ShadowData.h" |
|
36 #include <wtf/OwnPtr.h> |
|
37 #include <wtf/PassOwnPtr.h> |
|
38 #include <wtf/RefCounted.h> |
|
39 #include <wtf/RefPtr.h> |
|
40 |
|
41 // Helper macros for 'SVGRenderStyle' |
|
42 #define SVG_RS_DEFINE_ATTRIBUTE(Data, Type, Name, Initial) \ |
|
43 void set##Type(Data val) { svg_noninherited_flags.f._##Name = val; } \ |
|
44 Data Name() const { return (Data) svg_noninherited_flags.f._##Name; } \ |
|
45 static Data initial##Type() { return Initial; } |
|
46 |
|
47 #define SVG_RS_DEFINE_ATTRIBUTE_INHERITED(Data, Type, Name, Initial) \ |
|
48 void set##Type(Data val) { svg_inherited_flags._##Name = val; } \ |
|
49 Data Name() const { return (Data) svg_inherited_flags._##Name; } \ |
|
50 static Data initial##Type() { return Initial; } |
|
51 |
|
52 // "Helper" macros for SVG's RenderStyle properties |
|
53 // FIXME: These are impossible to work with or debug. |
|
54 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF(Data, Group, Variable, Type, Name) \ |
|
55 Data Name() const { return Group->Variable; } \ |
|
56 void set##Type(Data obj) { SVG_RS_SET_VARIABLE(Group, Variable, obj) } |
|
57 |
|
58 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(Data, Group, Variable, Type, Name, Initial) \ |
|
59 SVG_RS_DEFINE_ATTRIBUTE_DATAREF(Data, Group, Variable, Type, Name) \ |
|
60 static Data initial##Type() { return Initial; } |
|
61 |
|
62 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(Data, Group, Variable, Type, Name, Initial) \ |
|
63 Data* Name() const { return Group->Variable.get(); } \ |
|
64 void set##Type(PassRefPtr<Data> obj) { \ |
|
65 if (!(Group->Variable == obj)) \ |
|
66 Group.access()->Variable = obj; \ |
|
67 } \ |
|
68 static Data* initial##Type() { return Initial; } |
|
69 |
|
70 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_OWNPTR(Data, Group, Variable, Type, Name, Initial) \ |
|
71 Data* Name() const { return Group->Variable.get(); } \ |
|
72 void set##Type(PassOwnPtr<Data> obj) { \ |
|
73 Group.access()->Variable = obj; \ |
|
74 } \ |
|
75 static Data* initial##Type() { return Initial; } |
|
76 |
|
77 #define SVG_RS_SET_VARIABLE(Group, Variable, Value) \ |
|
78 if (!(Group->Variable == Value)) \ |
|
79 Group.access()->Variable = Value; |
|
80 |
|
81 namespace WebCore { |
|
82 |
|
83 enum EBaselineShift { |
|
84 BS_BASELINE, BS_SUB, BS_SUPER, BS_LENGTH |
|
85 }; |
|
86 |
|
87 enum ETextAnchor { |
|
88 TA_START, TA_MIDDLE, TA_END |
|
89 }; |
|
90 |
|
91 enum EColorInterpolation { |
|
92 CI_AUTO, CI_SRGB, CI_LINEARRGB |
|
93 }; |
|
94 |
|
95 enum EColorRendering { |
|
96 CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY |
|
97 }; |
|
98 |
|
99 enum EImageRendering { |
|
100 IR_AUTO, IR_OPTIMIZESPEED, IR_OPTIMIZEQUALITY |
|
101 }; |
|
102 |
|
103 enum EShapeRendering { |
|
104 SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION |
|
105 }; |
|
106 |
|
107 enum EWritingMode { |
|
108 WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB |
|
109 }; |
|
110 |
|
111 enum EGlyphOrientation { |
|
112 GO_0DEG, GO_90DEG, GO_180DEG, GO_270DEG, GO_AUTO |
|
113 }; |
|
114 |
|
115 enum EAlignmentBaseline { |
|
116 AB_AUTO, AB_BASELINE, AB_BEFORE_EDGE, AB_TEXT_BEFORE_EDGE, |
|
117 AB_MIDDLE, AB_CENTRAL, AB_AFTER_EDGE, AB_TEXT_AFTER_EDGE, |
|
118 AB_IDEOGRAPHIC, AB_ALPHABETIC, AB_HANGING, AB_MATHEMATICAL |
|
119 }; |
|
120 |
|
121 enum EDominantBaseline { |
|
122 DB_AUTO, DB_USE_SCRIPT, DB_NO_CHANGE, DB_RESET_SIZE, |
|
123 DB_IDEOGRAPHIC, DB_ALPHABETIC, DB_HANGING, DB_MATHEMATICAL, |
|
124 DB_CENTRAL, DB_MIDDLE, DB_TEXT_AFTER_EDGE, DB_TEXT_BEFORE_EDGE |
|
125 }; |
|
126 |
|
127 enum EVectorEffect { |
|
128 VE_NONE, |
|
129 VE_NON_SCALING_STROKE |
|
130 }; |
|
131 |
|
132 class CSSValue; |
|
133 class CSSValueList; |
|
134 class SVGPaint; |
|
135 |
|
136 // Inherited/Non-Inherited Style Datastructures |
|
137 class StyleFillData : public RefCounted<StyleFillData> { |
|
138 public: |
|
139 static PassRefPtr<StyleFillData> create() { return adoptRef(new StyleFillData); } |
|
140 PassRefPtr<StyleFillData> copy() const { return adoptRef(new StyleFillData(*this)); } |
|
141 |
|
142 bool operator==(const StyleFillData&) const; |
|
143 bool operator!=(const StyleFillData& other) const |
|
144 { |
|
145 return !(*this == other); |
|
146 } |
|
147 |
|
148 float opacity; |
|
149 RefPtr<SVGPaint> paint; |
|
150 |
|
151 private: |
|
152 StyleFillData(); |
|
153 StyleFillData(const StyleFillData&); |
|
154 }; |
|
155 |
|
156 class StyleStrokeData : public RefCounted<StyleStrokeData> { |
|
157 public: |
|
158 static PassRefPtr<StyleStrokeData> create() { return adoptRef(new StyleStrokeData); } |
|
159 PassRefPtr<StyleStrokeData> copy() const { return adoptRef(new StyleStrokeData(*this)); } |
|
160 |
|
161 bool operator==(const StyleStrokeData&) const; |
|
162 bool operator!=(const StyleStrokeData& other) const |
|
163 { |
|
164 return !(*this == other); |
|
165 } |
|
166 |
|
167 float opacity; |
|
168 float miterLimit; |
|
169 |
|
170 RefPtr<CSSValue> width; |
|
171 RefPtr<CSSValue> dashOffset; |
|
172 |
|
173 RefPtr<SVGPaint> paint; |
|
174 RefPtr<CSSValueList> dashArray; |
|
175 |
|
176 private: |
|
177 StyleStrokeData(); |
|
178 StyleStrokeData(const StyleStrokeData&); |
|
179 }; |
|
180 |
|
181 class StyleStopData : public RefCounted<StyleStopData> { |
|
182 public: |
|
183 static PassRefPtr<StyleStopData> create() { return adoptRef(new StyleStopData); } |
|
184 PassRefPtr<StyleStopData> copy() const { return adoptRef(new StyleStopData(*this)); } |
|
185 |
|
186 bool operator==(const StyleStopData&) const; |
|
187 bool operator!=(const StyleStopData& other) const |
|
188 { |
|
189 return !(*this == other); |
|
190 } |
|
191 |
|
192 float opacity; |
|
193 Color color; |
|
194 |
|
195 private: |
|
196 StyleStopData(); |
|
197 StyleStopData(const StyleStopData&); |
|
198 }; |
|
199 |
|
200 class StyleTextData : public RefCounted<StyleTextData> { |
|
201 public: |
|
202 static PassRefPtr<StyleTextData> create() { return adoptRef(new StyleTextData); } |
|
203 PassRefPtr<StyleTextData> copy() const { return adoptRef(new StyleTextData(*this)); } |
|
204 |
|
205 bool operator==(const StyleTextData& other) const; |
|
206 bool operator!=(const StyleTextData& other) const |
|
207 { |
|
208 return !(*this == other); |
|
209 } |
|
210 |
|
211 RefPtr<CSSValue> kerning; |
|
212 |
|
213 private: |
|
214 StyleTextData(); |
|
215 StyleTextData(const StyleTextData&); |
|
216 }; |
|
217 |
|
218 // Note: the rule for this class is, *no inheritance* of these props |
|
219 class StyleMiscData : public RefCounted<StyleMiscData> { |
|
220 public: |
|
221 static PassRefPtr<StyleMiscData> create() { return adoptRef(new StyleMiscData); } |
|
222 PassRefPtr<StyleMiscData> copy() const { return adoptRef(new StyleMiscData(*this)); } |
|
223 |
|
224 bool operator==(const StyleMiscData&) const; |
|
225 bool operator!=(const StyleMiscData& other) const |
|
226 { |
|
227 return !(*this == other); |
|
228 } |
|
229 |
|
230 Color floodColor; |
|
231 float floodOpacity; |
|
232 Color lightingColor; |
|
233 |
|
234 // non-inherited text stuff lives here not in StyleTextData. |
|
235 RefPtr<CSSValue> baselineShiftValue; |
|
236 |
|
237 private: |
|
238 StyleMiscData(); |
|
239 StyleMiscData(const StyleMiscData&); |
|
240 }; |
|
241 |
|
242 class StyleShadowSVGData : public RefCounted<StyleShadowSVGData> { |
|
243 public: |
|
244 static PassRefPtr<StyleShadowSVGData> create() { return adoptRef(new StyleShadowSVGData); } |
|
245 PassRefPtr<StyleShadowSVGData> copy() const { return adoptRef(new StyleShadowSVGData(*this)); } |
|
246 |
|
247 bool operator==(const StyleShadowSVGData&) const; |
|
248 bool operator!=(const StyleShadowSVGData& other) const |
|
249 { |
|
250 return !(*this == other); |
|
251 } |
|
252 |
|
253 OwnPtr<ShadowData> shadow; |
|
254 |
|
255 private: |
|
256 StyleShadowSVGData(); |
|
257 StyleShadowSVGData(const StyleShadowSVGData&); |
|
258 }; |
|
259 |
|
260 // Non-inherited resources |
|
261 class StyleResourceData : public RefCounted<StyleResourceData> { |
|
262 public: |
|
263 static PassRefPtr<StyleResourceData> create() { return adoptRef(new StyleResourceData); } |
|
264 PassRefPtr<StyleResourceData> copy() const { return adoptRef(new StyleResourceData(*this)); } |
|
265 |
|
266 bool operator==(const StyleResourceData&) const; |
|
267 bool operator!=(const StyleResourceData& other) const |
|
268 { |
|
269 return !(*this == other); |
|
270 } |
|
271 |
|
272 String clipper; |
|
273 String filter; |
|
274 String masker; |
|
275 |
|
276 private: |
|
277 StyleResourceData(); |
|
278 StyleResourceData(const StyleResourceData&); |
|
279 }; |
|
280 |
|
281 // Inherited resources |
|
282 class StyleInheritedResourceData : public RefCounted<StyleInheritedResourceData> { |
|
283 public: |
|
284 static PassRefPtr<StyleInheritedResourceData> create() { return adoptRef(new StyleInheritedResourceData); } |
|
285 PassRefPtr<StyleInheritedResourceData> copy() const { return adoptRef(new StyleInheritedResourceData(*this)); } |
|
286 |
|
287 bool operator==(const StyleInheritedResourceData&) const; |
|
288 bool operator!=(const StyleInheritedResourceData& other) const |
|
289 { |
|
290 return !(*this == other); |
|
291 } |
|
292 |
|
293 String markerStart; |
|
294 String markerMid; |
|
295 String markerEnd; |
|
296 |
|
297 private: |
|
298 StyleInheritedResourceData(); |
|
299 StyleInheritedResourceData(const StyleInheritedResourceData&); |
|
300 }; |
|
301 |
|
302 } // namespace WebCore |
|
303 |
|
304 #endif // ENABLE(SVG) |
|
305 |
|
306 #endif // SVGRenderStyleDefs_h |