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 "third_party/blink/renderer/core/style/svg_computed_style_defs.h"
29 
30 #include "third_party/blink/renderer/core/style/data_equivalency.h"
31 #include "third_party/blink/renderer/core/style/style_svg_resource.h"
32 #include "third_party/blink/renderer/core/style/svg_computed_style.h"
33 
34 namespace blink {
35 
36 SVGPaint::SVGPaint() = default;
SVGPaint(Color color)37 SVGPaint::SVGPaint(Color color) : color(color), type(SVG_PAINTTYPE_COLOR) {}
38 SVGPaint::SVGPaint(const SVGPaint& paint) = default;
39 
40 SVGPaint::~SVGPaint() = default;
41 
42 SVGPaint& SVGPaint::operator=(const SVGPaint& paint) = default;
43 
operator ==(const SVGPaint & other) const44 bool SVGPaint::operator==(const SVGPaint& other) const {
45   return type == other.type && color == other.color &&
46          DataEquivalent(resource, other.resource);
47 }
48 
GetUrl() const49 const AtomicString& SVGPaint::GetUrl() const {
50   return Resource()->Url();
51 }
52 
StyleFillData()53 StyleFillData::StyleFillData()
54     : opacity(SVGComputedStyle::InitialFillOpacity()),
55       paint(SVGComputedStyle::InitialFillPaint()),
56       visited_link_paint(SVGComputedStyle::InitialFillPaint()) {}
57 
StyleFillData(const StyleFillData & other)58 StyleFillData::StyleFillData(const StyleFillData& other)
59     : RefCounted<StyleFillData>(),
60       opacity(other.opacity),
61       paint(other.paint),
62       visited_link_paint(other.visited_link_paint) {}
63 
operator ==(const StyleFillData & other) const64 bool StyleFillData::operator==(const StyleFillData& other) const {
65   return opacity == other.opacity && paint == other.paint &&
66          visited_link_paint == other.visited_link_paint;
67 }
68 
StyleStrokeData()69 StyleStrokeData::StyleStrokeData()
70     : opacity(SVGComputedStyle::InitialStrokeOpacity()),
71       miter_limit(SVGComputedStyle::InitialStrokeMiterLimit()),
72       width(SVGComputedStyle::InitialStrokeWidth()),
73       dash_offset(SVGComputedStyle::InitialStrokeDashOffset()),
74       dash_array(SVGComputedStyle::InitialStrokeDashArray()),
75       paint(SVGComputedStyle::InitialStrokePaint()),
76       visited_link_paint(SVGComputedStyle::InitialStrokePaint()) {}
77 
StyleStrokeData(const StyleStrokeData & other)78 StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
79     : RefCounted<StyleStrokeData>(),
80       opacity(other.opacity),
81       miter_limit(other.miter_limit),
82       width(other.width),
83       dash_offset(other.dash_offset),
84       dash_array(other.dash_array),
85       paint(other.paint),
86       visited_link_paint(other.visited_link_paint) {}
87 
operator ==(const StyleStrokeData & other) const88 bool StyleStrokeData::operator==(const StyleStrokeData& other) const {
89   return width == other.width && opacity == other.opacity &&
90          miter_limit == other.miter_limit && dash_offset == other.dash_offset &&
91          dash_array->data == other.dash_array->data && paint == other.paint &&
92          visited_link_paint == other.visited_link_paint;
93 }
94 
StyleStopData()95 StyleStopData::StyleStopData()
96     : color(SVGComputedStyle::InitialStopColor()),
97       opacity(SVGComputedStyle::InitialStopOpacity()) {}
98 
StyleStopData(const StyleStopData & other)99 StyleStopData::StyleStopData(const StyleStopData& other)
100     : RefCounted<StyleStopData>(), color(other.color), opacity(other.opacity) {}
101 
operator ==(const StyleStopData & other) const102 bool StyleStopData::operator==(const StyleStopData& other) const {
103   return color == other.color && opacity == other.opacity;
104 }
105 
StyleMiscData()106 StyleMiscData::StyleMiscData()
107     : baseline_shift_value(SVGComputedStyle::InitialBaselineShiftValue()),
108       flood_color(SVGComputedStyle::InitialFloodColor()),
109       lighting_color(SVGComputedStyle::InitialLightingColor()),
110       flood_opacity(SVGComputedStyle::InitialFloodOpacity()) {}
111 
StyleMiscData(const StyleMiscData & other)112 StyleMiscData::StyleMiscData(const StyleMiscData& other)
113     : RefCounted<StyleMiscData>(),
114       baseline_shift_value(other.baseline_shift_value),
115       flood_color(other.flood_color),
116       lighting_color(other.lighting_color),
117       flood_opacity(other.flood_opacity) {}
118 
operator ==(const StyleMiscData & other) const119 bool StyleMiscData::operator==(const StyleMiscData& other) const {
120   return flood_color == other.flood_color &&
121          lighting_color == other.lighting_color &&
122          baseline_shift_value == other.baseline_shift_value &&
123          flood_opacity == other.flood_opacity;
124 }
125 
StyleResourceData()126 StyleResourceData::StyleResourceData()
127     : masker(SVGComputedStyle::InitialMaskerResource()) {}
128 
StyleResourceData(const StyleResourceData & other)129 StyleResourceData::StyleResourceData(const StyleResourceData& other)
130     : RefCounted<StyleResourceData>(), masker(other.masker) {}
131 
132 StyleResourceData::~StyleResourceData() = default;
133 
operator ==(const StyleResourceData & other) const134 bool StyleResourceData::operator==(const StyleResourceData& other) const {
135   return DataEquivalent(masker, other.masker);
136 }
137 
StyleInheritedResourceData()138 StyleInheritedResourceData::StyleInheritedResourceData()
139     : marker_start(SVGComputedStyle::InitialMarkerStartResource()),
140       marker_mid(SVGComputedStyle::InitialMarkerMidResource()),
141       marker_end(SVGComputedStyle::InitialMarkerEndResource()) {}
142 
StyleInheritedResourceData(const StyleInheritedResourceData & other)143 StyleInheritedResourceData::StyleInheritedResourceData(
144     const StyleInheritedResourceData& other)
145     : RefCounted<StyleInheritedResourceData>(),
146       marker_start(other.marker_start),
147       marker_mid(other.marker_mid),
148       marker_end(other.marker_end) {}
149 
150 StyleInheritedResourceData::~StyleInheritedResourceData() = default;
151 
operator ==(const StyleInheritedResourceData & other) const152 bool StyleInheritedResourceData::operator==(
153     const StyleInheritedResourceData& other) const {
154   return DataEquivalent(marker_start, other.marker_start) &&
155          DataEquivalent(marker_mid, other.marker_mid) &&
156          DataEquivalent(marker_end, other.marker_end);
157 }
158 
StyleGeometryData()159 StyleGeometryData::StyleGeometryData()
160     : d(SVGComputedStyle::InitialD()),
161       cx(SVGComputedStyle::InitialCx()),
162       cy(SVGComputedStyle::InitialCy()),
163       x(SVGComputedStyle::InitialX()),
164       y(SVGComputedStyle::InitialY()),
165       r(SVGComputedStyle::InitialR()),
166       rx(SVGComputedStyle::InitialRx()),
167       ry(SVGComputedStyle::InitialRy()) {}
168 
StyleGeometryData(const StyleGeometryData & other)169 inline StyleGeometryData::StyleGeometryData(const StyleGeometryData& other)
170     : RefCounted<StyleGeometryData>(),
171       d(other.d),
172       cx(other.cx),
173       cy(other.cy),
174       x(other.x),
175       y(other.y),
176       r(other.r),
177       rx(other.rx),
178       ry(other.ry) {}
179 
Copy() const180 scoped_refptr<StyleGeometryData> StyleGeometryData::Copy() const {
181   return base::AdoptRef(new StyleGeometryData(*this));
182 }
183 
operator ==(const StyleGeometryData & other) const184 bool StyleGeometryData::operator==(const StyleGeometryData& other) const {
185   return x == other.x && y == other.y && r == other.r && rx == other.rx &&
186          ry == other.ry && cx == other.cx && cy == other.cy &&
187          DataEquivalent(d, other.d);
188 }
189 
190 }  // namespace blink
191