Apply SVG styles paint-order, stroke-linejoin, and stroke-linecap on DOM text.
[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     , paintType(SVGRenderStyle::initialFillPaintType())
41     , paintColor(SVGRenderStyle::initialFillPaintColor())
42     , paintUri(SVGRenderStyle::initialFillPaintUri())
43     , visitedLinkPaintType(SVGRenderStyle::initialStrokePaintType())
44     , visitedLinkPaintColor(SVGRenderStyle::initialFillPaintColor())
45     , visitedLinkPaintUri(SVGRenderStyle::initialFillPaintUri())
46 {
47 }
48
49 inline StyleFillData::StyleFillData(const StyleFillData& other)
50     : RefCounted<StyleFillData>()
51     , opacity(other.opacity)
52     , paintType(other.paintType)
53     , paintColor(other.paintColor)
54     , paintUri(other.paintUri)
55     , visitedLinkPaintType(other.visitedLinkPaintType)
56     , visitedLinkPaintColor(other.visitedLinkPaintColor)
57     , visitedLinkPaintUri(other.visitedLinkPaintUri)
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         && paintType == other.paintType
70         && paintColor == other.paintColor
71         && paintUri == other.paintUri
72         && visitedLinkPaintType == other.visitedLinkPaintType
73         && visitedLinkPaintColor == other.visitedLinkPaintColor
74         && visitedLinkPaintUri == other.visitedLinkPaintUri;
75 }
76
77 StyleStrokeData::StyleStrokeData()
78     : opacity(SVGRenderStyle::initialStrokeOpacity())
79     , miterLimit(SVGRenderStyle::initialStrokeMiterLimit())
80     , dashOffset(RenderStyle::initialZeroLength())
81     , dashArray(SVGRenderStyle::initialStrokeDashArray())
82     , paintType(SVGRenderStyle::initialStrokePaintType())
83     , paintColor(SVGRenderStyle::initialStrokePaintColor())
84     , paintUri(SVGRenderStyle::initialStrokePaintUri())
85     , visitedLinkPaintType(SVGRenderStyle::initialStrokePaintType())
86     , visitedLinkPaintColor(SVGRenderStyle::initialStrokePaintColor())
87     , visitedLinkPaintUri(SVGRenderStyle::initialStrokePaintUri())
88 {
89 }
90
91 inline StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
92     : RefCounted<StyleStrokeData>()
93     , opacity(other.opacity)
94     , miterLimit(other.miterLimit)
95     , dashOffset(other.dashOffset)
96     , dashArray(other.dashArray)
97     , paintType(other.paintType)
98     , paintColor(other.paintColor)
99     , paintUri(other.paintUri)
100     , visitedLinkPaintType(other.visitedLinkPaintType)
101     , visitedLinkPaintColor(other.visitedLinkPaintColor)
102     , visitedLinkPaintUri(other.visitedLinkPaintUri)
103 {
104 }
105
106 Ref<StyleStrokeData> StyleStrokeData::copy() const
107 {
108     return adoptRef(*new StyleStrokeData(*this));
109 }
110
111 bool StyleStrokeData::operator==(const StyleStrokeData& other) const
112 {
113     return opacity == other.opacity
114         && miterLimit == other.miterLimit
115         && dashOffset == other.dashOffset
116         && dashArray == other.dashArray
117         && paintType == other.paintType
118         && paintColor == other.paintColor
119         && paintUri == other.paintUri
120         && visitedLinkPaintType == other.visitedLinkPaintType
121         && visitedLinkPaintColor == other.visitedLinkPaintColor
122         && visitedLinkPaintUri == other.visitedLinkPaintUri;
123 }
124
125 StyleStopData::StyleStopData()
126     : opacity(SVGRenderStyle::initialStopOpacity())
127     , color(SVGRenderStyle::initialStopColor())
128 {
129 }
130
131 inline StyleStopData::StyleStopData(const StyleStopData& other)
132     : RefCounted<StyleStopData>()
133     , opacity(other.opacity)
134     , color(other.color)
135 {
136 }
137
138 Ref<StyleStopData> StyleStopData::copy() const
139 {
140     return adoptRef(*new StyleStopData(*this));
141 }
142
143 bool StyleStopData::operator==(const StyleStopData& other) const
144 {
145     return color == other.color
146         && opacity == other.opacity;
147 }
148
149 StyleTextData::StyleTextData()
150     : kerning(SVGRenderStyle::initialKerning())
151 {
152 }
153
154 inline StyleTextData::StyleTextData(const StyleTextData& other)
155     : RefCounted<StyleTextData>()
156     , kerning(other.kerning)
157 {
158 }
159
160 Ref<StyleTextData> StyleTextData::copy() const
161 {
162     return adoptRef(*new StyleTextData(*this));
163 }
164
165 bool StyleTextData::operator==(const StyleTextData& other) const
166 {
167     return kerning == other.kerning;
168 }
169
170 StyleMiscData::StyleMiscData()
171     : floodColor(SVGRenderStyle::initialFloodColor())
172     , floodOpacity(SVGRenderStyle::initialFloodOpacity())
173     , lightingColor(SVGRenderStyle::initialLightingColor())
174     , baselineShiftValue(SVGRenderStyle::initialBaselineShiftValue())
175 {
176 }
177
178 inline StyleMiscData::StyleMiscData(const StyleMiscData& other)
179     : RefCounted<StyleMiscData>()
180     , floodColor(other.floodColor)
181     , floodOpacity(other.floodOpacity)
182     , lightingColor(other.lightingColor)
183     , baselineShiftValue(other.baselineShiftValue)
184 {
185 }
186
187 Ref<StyleMiscData> StyleMiscData::copy() const
188 {
189     return adoptRef(*new StyleMiscData(*this));
190 }
191
192 bool StyleMiscData::operator==(const StyleMiscData& other) const
193 {
194     return floodOpacity == other.floodOpacity
195         && floodColor == other.floodColor
196         && lightingColor == other.lightingColor
197         && baselineShiftValue == other.baselineShiftValue;
198 }
199
200 StyleShadowSVGData::StyleShadowSVGData()
201 {
202 }
203
204 inline StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other)
205     : RefCounted<StyleShadowSVGData>()
206     , shadow(other.shadow ? std::make_unique<ShadowData>(*other.shadow) : nullptr)
207 {
208 }
209
210 Ref<StyleShadowSVGData> StyleShadowSVGData::copy() const
211 {
212     return adoptRef(*new StyleShadowSVGData(*this));
213 }
214
215 bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const
216 {
217     return arePointingToEqualData(shadow, other.shadow);
218 }
219
220 StyleResourceData::StyleResourceData()
221     : clipper(SVGRenderStyle::initialClipperResource())
222     , masker(SVGRenderStyle::initialMaskerResource())
223 {
224 }
225
226 inline StyleResourceData::StyleResourceData(const StyleResourceData& other)
227     : RefCounted<StyleResourceData>()
228     , clipper(other.clipper)
229     , masker(other.masker)
230 {
231 }
232
233 Ref<StyleResourceData> StyleResourceData::copy() const
234 {
235     return adoptRef(*new StyleResourceData(*this));
236 }
237
238 bool StyleResourceData::operator==(const StyleResourceData& other) const
239 {
240     return clipper == other.clipper
241         && masker == other.masker;
242 }
243
244 StyleInheritedResourceData::StyleInheritedResourceData()
245     : markerStart(SVGRenderStyle::initialMarkerStartResource())
246     , markerMid(SVGRenderStyle::initialMarkerMidResource())
247     , markerEnd(SVGRenderStyle::initialMarkerEndResource())
248 {
249 }
250
251 inline StyleInheritedResourceData::StyleInheritedResourceData(const StyleInheritedResourceData& other)
252     : RefCounted<StyleInheritedResourceData>()
253     , markerStart(other.markerStart)
254     , markerMid(other.markerMid)
255     , markerEnd(other.markerEnd)
256 {
257 }
258
259 Ref<StyleInheritedResourceData> StyleInheritedResourceData::copy() const
260 {
261     return adoptRef(*new StyleInheritedResourceData(*this));
262 }
263
264 bool StyleInheritedResourceData::operator==(const StyleInheritedResourceData& other) const
265 {
266     return markerStart == other.markerStart
267         && markerMid == other.markerMid
268         && markerEnd == other.markerEnd;
269 }
270
271 StyleLayoutData::StyleLayoutData()
272     : cx(RenderStyle::initialZeroLength())
273     , cy(RenderStyle::initialZeroLength())
274     , r(RenderStyle::initialZeroLength())
275     , rx(RenderStyle::initialZeroLength())
276     , ry(RenderStyle::initialZeroLength())
277     , x(RenderStyle::initialZeroLength())
278     , y(RenderStyle::initialZeroLength())
279 {
280 }
281
282 inline StyleLayoutData::StyleLayoutData(const StyleLayoutData& other)
283     : RefCounted<StyleLayoutData>()
284     , cx(other.cx)
285     , cy(other.cy)
286     , r(other.r)
287     , rx(other.rx)
288     , ry(other.ry)
289     , x(other.x)
290     , y(other.y)
291 {
292 }
293
294 Ref<StyleLayoutData> StyleLayoutData::copy() const
295 {
296     return adoptRef(*new StyleLayoutData(*this));
297 }
298
299 bool StyleLayoutData::operator==(const StyleLayoutData& other) const
300 {
301     return cx == other.cx
302         && cy == other.cy
303         && r == other.r
304         && rx == other.rx
305         && ry == other.ry
306         && x == other.x
307         && y == other.y;
308 }
309
310 }