6e37cf8fb8aba55ec330a96033a8a954c7cb04ba
[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     Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
6
7     Based on khtml code by:
8     Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
9     Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
10     Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org)
11     Copyright (C) 2002 Apple Inc.
12
13     This library is free software; you can redistribute it and/or
14     modify it under the terms of the GNU Library General Public
15     License as published by the Free Software Foundation; either
16     version 2 of the License, or (at your option) any later version.
17
18     This library is distributed in the hope that it will be useful,
19     but WITHOUT ANY WARRANTY; without even the implied warranty of
20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21     Library General Public License for more details.
22
23     You should have received a copy of the GNU Library General Public License
24     along with this library; see the file COPYING.LIB.  If not, write to
25     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26     Boston, MA 02110-1301, USA.
27 */
28
29 #include "config.h"
30 #include "SVGRenderStyleDefs.h"
31
32 #include "RenderStyle.h"
33 #include "SVGRenderStyle.h"
34 #include <wtf/PointerComparison.h>
35
36 namespace WebCore {
37
38 StyleFillData::StyleFillData()
39     : opacity(SVGRenderStyle::initialFillOpacity())
40     , paintColor(SVGRenderStyle::initialFillPaintColor())
41     , visitedLinkPaintColor(SVGRenderStyle::initialFillPaintColor())
42     , paintUri(SVGRenderStyle::initialFillPaintUri())
43     , visitedLinkPaintUri(SVGRenderStyle::initialFillPaintUri())
44     , paintType(SVGRenderStyle::initialFillPaintType())
45     , visitedLinkPaintType(SVGRenderStyle::initialStrokePaintType())
46 {
47 }
48
49 inline StyleFillData::StyleFillData(const StyleFillData& other)
50     : RefCounted<StyleFillData>()
51     , opacity(other.opacity)
52     , paintColor(other.paintColor)
53     , visitedLinkPaintColor(other.visitedLinkPaintColor)
54     , paintUri(other.paintUri)
55     , visitedLinkPaintUri(other.visitedLinkPaintUri)
56     , paintType(other.paintType)
57     , visitedLinkPaintType(other.visitedLinkPaintType)
58 {
59 }
60
61 Ref<StyleFillData> StyleFillData::copy() const
62 {
63     return adoptRef(*new StyleFillData(*this));
64 }
65
66 bool StyleFillData::operator==(const StyleFillData& other) const
67 {
68     return opacity == other.opacity
69         && paintColor == other.paintColor
70         && visitedLinkPaintColor == other.visitedLinkPaintColor
71         && paintUri == other.paintUri
72         && visitedLinkPaintUri == other.visitedLinkPaintUri
73         && paintType == other.paintType
74         && visitedLinkPaintType == other.visitedLinkPaintType;
75     
76 }
77
78 StyleStrokeData::StyleStrokeData()
79     : opacity(SVGRenderStyle::initialStrokeOpacity())
80     , paintColor(SVGRenderStyle::initialStrokePaintColor())
81     , visitedLinkPaintColor(SVGRenderStyle::initialStrokePaintColor())
82     , paintUri(SVGRenderStyle::initialStrokePaintUri())
83     , visitedLinkPaintUri(SVGRenderStyle::initialStrokePaintUri())
84     , dashOffset(RenderStyle::initialZeroLength())
85     , dashArray(SVGRenderStyle::initialStrokeDashArray())
86     , paintType(SVGRenderStyle::initialStrokePaintType())
87     , visitedLinkPaintType(SVGRenderStyle::initialStrokePaintType())
88 {
89 }
90
91 inline StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
92     : RefCounted<StyleStrokeData>()
93     , opacity(other.opacity)
94     , paintColor(other.paintColor)
95     , visitedLinkPaintColor(other.visitedLinkPaintColor)
96     , paintUri(other.paintUri)
97     , visitedLinkPaintUri(other.visitedLinkPaintUri)
98     , dashOffset(other.dashOffset)
99     , dashArray(other.dashArray)
100     , paintType(other.paintType)
101     , visitedLinkPaintType(other.visitedLinkPaintType)
102 {
103 }
104
105 Ref<StyleStrokeData> StyleStrokeData::copy() const
106 {
107     return adoptRef(*new StyleStrokeData(*this));
108 }
109
110 bool StyleStrokeData::operator==(const StyleStrokeData& other) const
111 {
112     return opacity == other.opacity
113         && paintColor == other.paintColor
114         && visitedLinkPaintColor == other.visitedLinkPaintColor
115         && paintUri == other.paintUri
116         && visitedLinkPaintUri == other.visitedLinkPaintUri
117         && dashOffset == other.dashOffset
118         && dashArray == other.dashArray
119         && paintType == other.paintType
120         && visitedLinkPaintType == other.visitedLinkPaintType;
121 }
122
123 StyleStopData::StyleStopData()
124     : opacity(SVGRenderStyle::initialStopOpacity())
125     , color(SVGRenderStyle::initialStopColor())
126 {
127 }
128
129 inline StyleStopData::StyleStopData(const StyleStopData& other)
130     : RefCounted<StyleStopData>()
131     , opacity(other.opacity)
132     , color(other.color)
133 {
134 }
135
136 Ref<StyleStopData> StyleStopData::copy() const
137 {
138     return adoptRef(*new StyleStopData(*this));
139 }
140
141 bool StyleStopData::operator==(const StyleStopData& other) const
142 {
143     return opacity == other.opacity
144         && color == other.color;
145 }
146
147 StyleTextData::StyleTextData()
148     : kerning(SVGRenderStyle::initialKerning())
149 {
150 }
151
152 inline StyleTextData::StyleTextData(const StyleTextData& other)
153     : RefCounted<StyleTextData>()
154     , kerning(other.kerning)
155 {
156 }
157
158 Ref<StyleTextData> StyleTextData::copy() const
159 {
160     return adoptRef(*new StyleTextData(*this));
161 }
162
163 bool StyleTextData::operator==(const StyleTextData& other) const
164 {
165     return kerning == other.kerning;
166 }
167
168 StyleMiscData::StyleMiscData()
169     : floodOpacity(SVGRenderStyle::initialFloodOpacity())
170     , floodColor(SVGRenderStyle::initialFloodColor())
171     , lightingColor(SVGRenderStyle::initialLightingColor())
172     , baselineShiftValue(SVGRenderStyle::initialBaselineShiftValue())
173 {
174 }
175
176 inline StyleMiscData::StyleMiscData(const StyleMiscData& other)
177     : RefCounted<StyleMiscData>()
178     , floodOpacity(other.floodOpacity)
179     , floodColor(other.floodColor)
180     , lightingColor(other.lightingColor)
181     , baselineShiftValue(other.baselineShiftValue)
182 {
183 }
184
185 Ref<StyleMiscData> StyleMiscData::copy() const
186 {
187     return adoptRef(*new StyleMiscData(*this));
188 }
189
190 bool StyleMiscData::operator==(const StyleMiscData& other) const
191 {
192     return floodOpacity == other.floodOpacity
193         && floodColor == other.floodColor
194         && lightingColor == other.lightingColor
195         && baselineShiftValue == other.baselineShiftValue;
196 }
197
198 StyleShadowSVGData::StyleShadowSVGData()
199 {
200 }
201
202 inline StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other)
203     : RefCounted<StyleShadowSVGData>()
204     , shadow(other.shadow ? makeUnique<ShadowData>(*other.shadow) : nullptr)
205 {
206 }
207
208 Ref<StyleShadowSVGData> StyleShadowSVGData::copy() const
209 {
210     return adoptRef(*new StyleShadowSVGData(*this));
211 }
212
213 bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const
214 {
215     return arePointingToEqualData(shadow, other.shadow);
216 }
217
218 StyleResourceData::StyleResourceData()
219     : clipper(SVGRenderStyle::initialClipperResource())
220     , masker(SVGRenderStyle::initialMaskerResource())
221 {
222 }
223
224 inline StyleResourceData::StyleResourceData(const StyleResourceData& other)
225     : RefCounted<StyleResourceData>()
226     , clipper(other.clipper)
227     , masker(other.masker)
228 {
229 }
230
231 Ref<StyleResourceData> StyleResourceData::copy() const
232 {
233     return adoptRef(*new StyleResourceData(*this));
234 }
235
236 bool StyleResourceData::operator==(const StyleResourceData& other) const
237 {
238     return clipper == other.clipper
239         && masker == other.masker;
240 }
241
242 StyleInheritedResourceData::StyleInheritedResourceData()
243     : markerStart(SVGRenderStyle::initialMarkerStartResource())
244     , markerMid(SVGRenderStyle::initialMarkerMidResource())
245     , markerEnd(SVGRenderStyle::initialMarkerEndResource())
246 {
247 }
248
249 inline StyleInheritedResourceData::StyleInheritedResourceData(const StyleInheritedResourceData& other)
250     : RefCounted<StyleInheritedResourceData>()
251     , markerStart(other.markerStart)
252     , markerMid(other.markerMid)
253     , markerEnd(other.markerEnd)
254 {
255 }
256
257 Ref<StyleInheritedResourceData> StyleInheritedResourceData::copy() const
258 {
259     return adoptRef(*new StyleInheritedResourceData(*this));
260 }
261
262 bool StyleInheritedResourceData::operator==(const StyleInheritedResourceData& other) const
263 {
264     return markerStart == other.markerStart
265         && markerMid == other.markerMid
266         && markerEnd == other.markerEnd;
267 }
268
269 StyleLayoutData::StyleLayoutData()
270     : cx(RenderStyle::initialZeroLength())
271     , cy(RenderStyle::initialZeroLength())
272     , r(RenderStyle::initialZeroLength())
273     , rx(RenderStyle::initialZeroLength())
274     , ry(RenderStyle::initialZeroLength())
275     , x(RenderStyle::initialZeroLength())
276     , y(RenderStyle::initialZeroLength())
277 {
278 }
279
280 inline StyleLayoutData::StyleLayoutData(const StyleLayoutData& other)
281     : RefCounted<StyleLayoutData>()
282     , cx(other.cx)
283     , cy(other.cy)
284     , r(other.r)
285     , rx(other.rx)
286     , ry(other.ry)
287     , x(other.x)
288     , y(other.y)
289 {
290 }
291
292 Ref<StyleLayoutData> StyleLayoutData::copy() const
293 {
294     return adoptRef(*new StyleLayoutData(*this));
295 }
296
297 bool StyleLayoutData::operator==(const StyleLayoutData& other) const
298 {
299     return cx == other.cx
300         && cy == other.cy
301         && r == other.r
302         && rx == other.rx
303         && ry == other.ry
304         && x == other.x
305         && y == other.y;
306 }
307
308 }