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 #include "SVGLength.h"
33 #include "SVGPaint.h"
34 #include "ShadowData.h"
35 #include <wtf/OwnPtr.h>
36 #include <wtf/PassOwnPtr.h>
37 #include <wtf/RefCounted.h>
38 #include <wtf/RefPtr.h>
39 
40 namespace WebCore {
41 
42     enum EBaselineShift {
43         BS_BASELINE, BS_SUB, BS_SUPER, BS_LENGTH
44     };
45 
46     enum ETextAnchor {
47         TA_START, TA_MIDDLE, TA_END
48     };
49 
50     enum EColorInterpolation {
51         CI_AUTO, CI_SRGB, CI_LINEARRGB
52     };
53 
54     enum EColorRendering {
55         CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY
56     };
57 
58     enum EImageRendering {
59         IR_AUTO, IR_OPTIMIZESPEED, IR_OPTIMIZEQUALITY
60     };
61 
62     enum EShapeRendering {
63         SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION
64     };
65 
66     enum SVGWritingMode {
67         WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB
68     };
69 
70     enum EGlyphOrientation {
71         GO_0DEG, GO_90DEG, GO_180DEG, GO_270DEG, GO_AUTO
72     };
73 
74     enum EAlignmentBaseline {
75         AB_AUTO, AB_BASELINE, AB_BEFORE_EDGE, AB_TEXT_BEFORE_EDGE,
76         AB_MIDDLE, AB_CENTRAL, AB_AFTER_EDGE, AB_TEXT_AFTER_EDGE,
77         AB_IDEOGRAPHIC, AB_ALPHABETIC, AB_HANGING, AB_MATHEMATICAL
78     };
79 
80     enum EDominantBaseline {
81         DB_AUTO, DB_USE_SCRIPT, DB_NO_CHANGE, DB_RESET_SIZE,
82         DB_IDEOGRAPHIC, DB_ALPHABETIC, DB_HANGING, DB_MATHEMATICAL,
83         DB_CENTRAL, DB_MIDDLE, DB_TEXT_AFTER_EDGE, DB_TEXT_BEFORE_EDGE
84     };
85 
86     enum EVectorEffect {
87         VE_NONE,
88         VE_NON_SCALING_STROKE
89     };
90 
91     class CSSValue;
92     class CSSValueList;
93     class SVGPaint;
94 
95     // Inherited/Non-Inherited Style Datastructures
96     class StyleFillData : public RefCounted<StyleFillData> {
97     public:
create()98         static PassRefPtr<StyleFillData> create() { return adoptRef(new StyleFillData); }
copy()99         PassRefPtr<StyleFillData> copy() const { return adoptRef(new StyleFillData(*this)); }
100 
101         bool operator==(const StyleFillData&) const;
102         bool operator!=(const StyleFillData& other) const
103         {
104             return !(*this == other);
105         }
106 
107         float opacity;
108         SVGPaint::SVGPaintType paintType;
109         Color paintColor;
110         String paintUri;
111 
112     private:
113         StyleFillData();
114         StyleFillData(const StyleFillData&);
115     };
116 
117     class StyleStrokeData : public RefCounted<StyleStrokeData> {
118     public:
create()119         static PassRefPtr<StyleStrokeData> create() { return adoptRef(new StyleStrokeData); }
copy()120         PassRefPtr<StyleStrokeData> copy() const { return adoptRef(new StyleStrokeData(*this)); }
121 
122         bool operator==(const StyleStrokeData&) const;
123         bool operator!=(const StyleStrokeData& other) const
124         {
125             return !(*this == other);
126         }
127 
128         float opacity;
129         float miterLimit;
130 
131         SVGLength width;
132         SVGLength dashOffset;
133         Vector<SVGLength> dashArray;
134 
135         SVGPaint::SVGPaintType paintType;
136         Color paintColor;
137         String paintUri;
138 
139     private:
140         StyleStrokeData();
141         StyleStrokeData(const StyleStrokeData&);
142     };
143 
144     class StyleStopData : public RefCounted<StyleStopData> {
145     public:
create()146         static PassRefPtr<StyleStopData> create() { return adoptRef(new StyleStopData); }
copy()147         PassRefPtr<StyleStopData> copy() const { return adoptRef(new StyleStopData(*this)); }
148 
149         bool operator==(const StyleStopData&) const;
150         bool operator!=(const StyleStopData& other) const
151         {
152             return !(*this == other);
153         }
154 
155         float opacity;
156         Color color;
157 
158     private:
159         StyleStopData();
160         StyleStopData(const StyleStopData&);
161     };
162 
163     class StyleTextData : public RefCounted<StyleTextData> {
164     public:
create()165         static PassRefPtr<StyleTextData> create() { return adoptRef(new StyleTextData); }
copy()166         PassRefPtr<StyleTextData> copy() const { return adoptRef(new StyleTextData(*this)); }
167 
168         bool operator==(const StyleTextData& other) const;
169         bool operator!=(const StyleTextData& other) const
170         {
171             return !(*this == other);
172         }
173 
174         SVGLength kerning;
175 
176     private:
177         StyleTextData();
178         StyleTextData(const StyleTextData&);
179     };
180 
181     // Note: the rule for this class is, *no inheritance* of these props
182     class StyleMiscData : public RefCounted<StyleMiscData> {
183     public:
create()184         static PassRefPtr<StyleMiscData> create() { return adoptRef(new StyleMiscData); }
copy()185         PassRefPtr<StyleMiscData> copy() const { return adoptRef(new StyleMiscData(*this)); }
186 
187         bool operator==(const StyleMiscData&) const;
188         bool operator!=(const StyleMiscData& other) const
189         {
190             return !(*this == other);
191         }
192 
193         Color floodColor;
194         float floodOpacity;
195         Color lightingColor;
196 
197         // non-inherited text stuff lives here not in StyleTextData.
198         SVGLength baselineShiftValue;
199 
200     private:
201         StyleMiscData();
202         StyleMiscData(const StyleMiscData&);
203     };
204 
205     class StyleShadowSVGData : public RefCounted<StyleShadowSVGData> {
206     public:
create()207         static PassRefPtr<StyleShadowSVGData> create() { return adoptRef(new StyleShadowSVGData); }
copy()208         PassRefPtr<StyleShadowSVGData> copy() const { return adoptRef(new StyleShadowSVGData(*this)); }
209 
210         bool operator==(const StyleShadowSVGData&) const;
211         bool operator!=(const StyleShadowSVGData& other) const
212         {
213             return !(*this == other);
214         }
215 
216         OwnPtr<ShadowData> shadow;
217 
218     private:
219         StyleShadowSVGData();
220         StyleShadowSVGData(const StyleShadowSVGData&);
221     };
222 
223     // Non-inherited resources
224     class StyleResourceData : public RefCounted<StyleResourceData> {
225     public:
create()226         static PassRefPtr<StyleResourceData> create() { return adoptRef(new StyleResourceData); }
copy()227         PassRefPtr<StyleResourceData> copy() const { return adoptRef(new StyleResourceData(*this)); }
228 
229         bool operator==(const StyleResourceData&) const;
230         bool operator!=(const StyleResourceData& other) const
231         {
232             return !(*this == other);
233         }
234 
235         String clipper;
236         String filter;
237         String masker;
238 
239     private:
240         StyleResourceData();
241         StyleResourceData(const StyleResourceData&);
242     };
243 
244     // Inherited resources
245     class StyleInheritedResourceData : public RefCounted<StyleInheritedResourceData> {
246     public:
create()247         static PassRefPtr<StyleInheritedResourceData> create() { return adoptRef(new StyleInheritedResourceData); }
copy()248         PassRefPtr<StyleInheritedResourceData> copy() const { return adoptRef(new StyleInheritedResourceData(*this)); }
249 
250         bool operator==(const StyleInheritedResourceData&) const;
251         bool operator!=(const StyleInheritedResourceData& other) const
252         {
253             return !(*this == other);
254         }
255 
256         String markerStart;
257         String markerMid;
258         String markerEnd;
259 
260     private:
261         StyleInheritedResourceData();
262         StyleInheritedResourceData(const StyleInheritedResourceData&);
263     };
264 
265 } // namespace WebCore
266 
267 #endif // ENABLE(SVG)
268 #endif // SVGRenderStyleDefs_h
269