• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
StyleFillData()38 StyleFillData::StyleFillData()
39     : opacity(SVGRenderStyle::initialFillOpacity())
40     , paint(SVGRenderStyle::initialFillPaint())
41 {
42 }
43 
StyleFillData(const StyleFillData & other)44 StyleFillData::StyleFillData(const StyleFillData& other)
45     : RefCounted<StyleFillData>()
46     , opacity(other.opacity)
47     , paint(other.paint)
48 {
49 }
50 
operator ==(const StyleFillData & other) const51 bool StyleFillData::operator==(const StyleFillData& other) const
52 {
53     if (opacity != other.opacity)
54         return false;
55 
56     if (!paint || !other.paint)
57         return paint == other.paint;
58 
59     if (paint->paintType() != other.paint->paintType())
60         return false;
61 
62     if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI)
63         return paint->uri() == other.paint->uri();
64 
65     if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR)
66         return paint->color() == other.paint->color();
67 
68     return paint == other.paint;
69 }
70 
StyleStrokeData()71 StyleStrokeData::StyleStrokeData()
72     : opacity(SVGRenderStyle::initialStrokeOpacity())
73     , miterLimit(SVGRenderStyle::initialStrokeMiterLimit())
74     , width(SVGRenderStyle::initialStrokeWidth())
75     , dashOffset(SVGRenderStyle::initialStrokeDashOffset())
76     , dashArray(SVGRenderStyle::initialStrokeDashArray())
77     , paint(SVGRenderStyle::initialStrokePaint())
78 {
79 }
80 
StyleStrokeData(const StyleStrokeData & other)81 StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
82     : RefCounted<StyleStrokeData>()
83     , opacity(other.opacity)
84     , miterLimit(other.miterLimit)
85     , width(other.width)
86     , dashOffset(other.dashOffset)
87     , dashArray(other.dashArray)
88     , paint(other.paint)
89 {
90 }
91 
operator ==(const StyleStrokeData & other) const92 bool StyleStrokeData::operator==(const StyleStrokeData& other) const
93 {
94     return paint == other.paint
95         && width == other.width
96         && opacity == other.opacity
97         && miterLimit == other.miterLimit
98         && dashOffset == other.dashOffset
99         && dashArray == other.dashArray;
100 }
101 
StyleStopData()102 StyleStopData::StyleStopData()
103     : opacity(SVGRenderStyle::initialStopOpacity())
104     , color(SVGRenderStyle::initialStopColor())
105 {
106 }
107 
StyleStopData(const StyleStopData & other)108 StyleStopData::StyleStopData(const StyleStopData& other)
109     : RefCounted<StyleStopData>()
110     , opacity(other.opacity)
111     , color(other.color)
112 {
113 }
114 
operator ==(const StyleStopData & other) const115 bool StyleStopData::operator==(const StyleStopData& other) const
116 {
117     return color == other.color
118         && opacity == other.opacity;
119 }
120 
StyleTextData()121 StyleTextData::StyleTextData()
122     : kerning(SVGRenderStyle::initialKerning())
123 {
124 }
125 
StyleTextData(const StyleTextData & other)126 StyleTextData::StyleTextData(const StyleTextData& other)
127     : RefCounted<StyleTextData>()
128     , kerning(other.kerning)
129 {
130 }
131 
operator ==(const StyleTextData & other) const132 bool StyleTextData::operator==(const StyleTextData& other) const
133 {
134     return kerning == other.kerning;
135 }
136 
StyleMiscData()137 StyleMiscData::StyleMiscData()
138     : floodColor(SVGRenderStyle::initialFloodColor())
139     , floodOpacity(SVGRenderStyle::initialFloodOpacity())
140     , lightingColor(SVGRenderStyle::initialLightingColor())
141     , baselineShiftValue(SVGRenderStyle::initialBaselineShiftValue())
142 {
143 }
144 
StyleMiscData(const StyleMiscData & other)145 StyleMiscData::StyleMiscData(const StyleMiscData& other)
146     : RefCounted<StyleMiscData>()
147     , floodColor(other.floodColor)
148     , floodOpacity(other.floodOpacity)
149     , lightingColor(other.lightingColor)
150     , baselineShiftValue(other.baselineShiftValue)
151 {
152 }
153 
operator ==(const StyleMiscData & other) const154 bool StyleMiscData::operator==(const StyleMiscData& other) const
155 {
156     return floodOpacity == other.floodOpacity
157         && floodColor == other.floodColor
158         && lightingColor == other.lightingColor
159         && baselineShiftValue == other.baselineShiftValue;
160 }
161 
StyleShadowSVGData()162 StyleShadowSVGData::StyleShadowSVGData()
163 {
164 }
165 
StyleShadowSVGData(const StyleShadowSVGData & other)166 StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other)
167     : RefCounted<StyleShadowSVGData>()
168     , shadow(other.shadow ? new ShadowData(*other.shadow) : 0)
169 {
170 }
171 
operator ==(const StyleShadowSVGData & other) const172 bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const
173 {
174     if ((!shadow && other.shadow) || (shadow && !other.shadow))
175         return false;
176     if (shadow && other.shadow && (*shadow != *other.shadow))
177         return false;
178     return true;
179 }
180 
StyleResourceData()181 StyleResourceData::StyleResourceData()
182     : clipper(SVGRenderStyle::initialClipperResource())
183     , filter(SVGRenderStyle::initialFilterResource())
184     , masker(SVGRenderStyle::initialMaskerResource())
185 {
186 }
187 
StyleResourceData(const StyleResourceData & other)188 StyleResourceData::StyleResourceData(const StyleResourceData& other)
189     : RefCounted<StyleResourceData>()
190     , clipper(other.clipper)
191     , filter(other.filter)
192     , masker(other.masker)
193 {
194 }
195 
operator ==(const StyleResourceData & other) const196 bool StyleResourceData::operator==(const StyleResourceData& other) const
197 {
198     return clipper == other.clipper
199         && filter == other.filter
200         && masker == other.masker;
201 }
202 
StyleInheritedResourceData()203 StyleInheritedResourceData::StyleInheritedResourceData()
204     : markerStart(SVGRenderStyle::initialMarkerStartResource())
205     , markerMid(SVGRenderStyle::initialMarkerMidResource())
206     , markerEnd(SVGRenderStyle::initialMarkerEndResource())
207 {
208 }
209 
StyleInheritedResourceData(const StyleInheritedResourceData & other)210 StyleInheritedResourceData::StyleInheritedResourceData(const StyleInheritedResourceData& other)
211     : RefCounted<StyleInheritedResourceData>()
212     , markerStart(other.markerStart)
213     , markerMid(other.markerMid)
214     , markerEnd(other.markerEnd)
215 {
216 }
217 
operator ==(const StyleInheritedResourceData & other) const218 bool StyleInheritedResourceData::operator==(const StyleInheritedResourceData& other) const
219 {
220     return markerStart == other.markerStart
221         && markerMid == other.markerMid
222         && markerEnd == other.markerEnd;
223 }
224 
225 }
226 
227 #endif // ENABLE(SVG)
228