fe8ce5d731e069924686bed6c93b6c27d1dd2651
[WebKit-https.git] / Source / WebCore / rendering / style / SVGRenderStyleDefs.cpp
1 /*
2     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3                   2004, 2005, 2007 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) 1999 Antti Koivisto (koivisto@kde.org)
8     Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
9     Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org)
10     Copyright (C) 2002 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 #include "config.h"
29
30 #if ENABLE(SVG)
31 #include "SVGRenderStyleDefs.h"
32
33 #include "RenderStyle.h"
34 #include "SVGRenderStyle.h"
35
36 namespace WebCore {
37
38 StyleFillData::StyleFillData()
39     : opacity(SVGRenderStyle::initialFillOpacity())
40     , paintType(SVGRenderStyle::initialFillPaintType())
41     , paintColor(SVGRenderStyle::initialFillPaintColor())
42     , paintUri(SVGRenderStyle::initialFillPaintUri())
43 {
44 }
45
46 StyleFillData::StyleFillData(const StyleFillData& other)
47     : RefCounted<StyleFillData>()
48     , opacity(other.opacity)
49     , paintType(other.paintType)
50     , paintColor(other.paintColor)
51     , paintUri(other.paintUri)
52 {
53 }
54
55 bool StyleFillData::operator==(const StyleFillData& other) const
56 {
57     return opacity == other.opacity 
58         && paintType == other.paintType
59         && paintColor == other.paintColor
60         && paintUri == other.paintUri;
61 }
62
63 StyleStrokeData::StyleStrokeData()
64     : opacity(SVGRenderStyle::initialStrokeOpacity())
65     , miterLimit(SVGRenderStyle::initialStrokeMiterLimit())
66     , width(SVGRenderStyle::initialStrokeWidth())
67     , dashOffset(SVGRenderStyle::initialStrokeDashOffset())
68     , dashArray(SVGRenderStyle::initialStrokeDashArray())
69     , paintType(SVGRenderStyle::initialStrokePaintType())
70     , paintColor(SVGRenderStyle::initialStrokePaintColor())
71     , paintUri(SVGRenderStyle::initialStrokePaintUri())
72 {
73 }
74
75 StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
76     : RefCounted<StyleStrokeData>()
77     , opacity(other.opacity)
78     , miterLimit(other.miterLimit)
79     , width(other.width)
80     , dashOffset(other.dashOffset)
81     , dashArray(other.dashArray)
82     , paintType(other.paintType)
83     , paintColor(other.paintColor)
84     , paintUri(other.paintUri)
85 {
86 }
87
88 bool StyleStrokeData::operator==(const StyleStrokeData& other) const
89 {
90     return width == other.width
91         && opacity == other.opacity
92         && miterLimit == other.miterLimit
93         && dashOffset == other.dashOffset
94         && dashArray == other.dashArray
95         && paintType == other.paintType
96         && paintColor == other.paintColor
97         && paintUri == other.paintUri;
98 }
99
100 StyleStopData::StyleStopData()
101     : opacity(SVGRenderStyle::initialStopOpacity())
102     , color(SVGRenderStyle::initialStopColor())
103 {
104 }
105
106 StyleStopData::StyleStopData(const StyleStopData& other)
107     : RefCounted<StyleStopData>()
108     , opacity(other.opacity)
109     , color(other.color)
110 {
111 }
112
113 bool StyleStopData::operator==(const StyleStopData& other) const
114 {
115     return color == other.color
116         && opacity == other.opacity;
117 }
118
119 StyleTextData::StyleTextData()
120     : kerning(SVGRenderStyle::initialKerning())
121 {
122 }
123
124 StyleTextData::StyleTextData(const StyleTextData& other)
125     : RefCounted<StyleTextData>()
126     , kerning(other.kerning)
127 {
128 }
129
130 bool StyleTextData::operator==(const StyleTextData& other) const
131 {
132     return kerning == other.kerning;
133 }
134
135 StyleMiscData::StyleMiscData()
136     : floodColor(SVGRenderStyle::initialFloodColor())
137     , floodOpacity(SVGRenderStyle::initialFloodOpacity())
138     , lightingColor(SVGRenderStyle::initialLightingColor())
139     , baselineShiftValue(SVGRenderStyle::initialBaselineShiftValue())
140 {
141 }
142
143 StyleMiscData::StyleMiscData(const StyleMiscData& other)
144     : RefCounted<StyleMiscData>()
145     , floodColor(other.floodColor)
146     , floodOpacity(other.floodOpacity)
147     , lightingColor(other.lightingColor)
148     , baselineShiftValue(other.baselineShiftValue)
149 {
150 }
151
152 bool StyleMiscData::operator==(const StyleMiscData& other) const
153 {
154     return floodOpacity == other.floodOpacity
155         && floodColor == other.floodColor
156         && lightingColor == other.lightingColor
157         && baselineShiftValue == other.baselineShiftValue;
158 }
159
160 StyleShadowSVGData::StyleShadowSVGData()
161 {
162 }
163
164 StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other)
165     : RefCounted<StyleShadowSVGData>()
166     , shadow(other.shadow ? adoptPtr(new ShadowData(*other.shadow)) : nullptr)
167 {
168 }
169
170 bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const
171 {
172     if ((!shadow && other.shadow) || (shadow && !other.shadow))
173         return false;
174     if (shadow && other.shadow && (*shadow != *other.shadow))
175         return false;
176     return true;
177 }
178
179 StyleResourceData::StyleResourceData()
180     : clipper(SVGRenderStyle::initialClipperResource())
181     , filter(SVGRenderStyle::initialFilterResource())
182     , masker(SVGRenderStyle::initialMaskerResource())
183 {
184 }
185
186 StyleResourceData::StyleResourceData(const StyleResourceData& other)
187     : RefCounted<StyleResourceData>()
188     , clipper(other.clipper)
189     , filter(other.filter)
190     , masker(other.masker)
191 {
192 }
193
194 bool StyleResourceData::operator==(const StyleResourceData& other) const
195 {
196     return clipper == other.clipper
197         && filter == other.filter
198         && masker == other.masker;
199 }
200
201 StyleInheritedResourceData::StyleInheritedResourceData()
202     : markerStart(SVGRenderStyle::initialMarkerStartResource())
203     , markerMid(SVGRenderStyle::initialMarkerMidResource())
204     , markerEnd(SVGRenderStyle::initialMarkerEndResource())
205 {
206 }
207
208 StyleInheritedResourceData::StyleInheritedResourceData(const StyleInheritedResourceData& other)
209     : RefCounted<StyleInheritedResourceData>()
210     , markerStart(other.markerStart)
211     , markerMid(other.markerMid)
212     , markerEnd(other.markerEnd)
213 {
214 }
215
216 bool StyleInheritedResourceData::operator==(const StyleInheritedResourceData& other) const
217 {
218     return markerStart == other.markerStart
219         && markerMid == other.markerMid
220         && markerEnd == other.markerEnd;
221 }
222
223 }
224
225 #endif // ENABLE(SVG)