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 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#include "SVGRenderStyleDefs.h" 30 31#include "RenderStyle.h" 32#include "SVGRenderStyle.h" 33 34namespace WebCore { 35 36StyleFillData::StyleFillData() 37 : opacity(SVGRenderStyle::initialFillOpacity()) 38 , paintType(SVGRenderStyle::initialFillPaintType()) 39 , paintColor(SVGRenderStyle::initialFillPaintColor()) 40 , paintUri(SVGRenderStyle::initialFillPaintUri()) 41 , visitedLinkPaintType(SVGRenderStyle::initialStrokePaintType()) 42 , visitedLinkPaintColor(SVGRenderStyle::initialFillPaintColor()) 43 , visitedLinkPaintUri(SVGRenderStyle::initialFillPaintUri()) 44{ 45} 46 47inline StyleFillData::StyleFillData(const StyleFillData& other) 48 : RefCounted<StyleFillData>() 49 , opacity(other.opacity) 50 , paintType(other.paintType) 51 , paintColor(other.paintColor) 52 , paintUri(other.paintUri) 53 , visitedLinkPaintType(other.visitedLinkPaintType) 54 , visitedLinkPaintColor(other.visitedLinkPaintColor) 55 , visitedLinkPaintUri(other.visitedLinkPaintUri) 56{ 57} 58 59PassRef<StyleFillData> StyleFillData::copy() const 60{ 61 return adoptRef(*new StyleFillData(*this)); 62} 63 64bool StyleFillData::operator==(const StyleFillData& other) const 65{ 66 return opacity == other.opacity 67 && paintType == other.paintType 68 && paintColor == other.paintColor 69 && paintUri == other.paintUri 70 && visitedLinkPaintType == other.visitedLinkPaintType 71 && visitedLinkPaintColor == other.visitedLinkPaintColor 72 && visitedLinkPaintUri == other.visitedLinkPaintUri; 73} 74 75StyleStrokeData::StyleStrokeData() 76 : opacity(SVGRenderStyle::initialStrokeOpacity()) 77 , miterLimit(SVGRenderStyle::initialStrokeMiterLimit()) 78 , width(SVGRenderStyle::initialStrokeWidth()) 79 , dashOffset(SVGRenderStyle::initialStrokeDashOffset()) 80 , dashArray(SVGRenderStyle::initialStrokeDashArray()) 81 , paintType(SVGRenderStyle::initialStrokePaintType()) 82 , paintColor(SVGRenderStyle::initialStrokePaintColor()) 83 , paintUri(SVGRenderStyle::initialStrokePaintUri()) 84 , visitedLinkPaintType(SVGRenderStyle::initialStrokePaintType()) 85 , visitedLinkPaintColor(SVGRenderStyle::initialStrokePaintColor()) 86 , visitedLinkPaintUri(SVGRenderStyle::initialStrokePaintUri()) 87{ 88} 89 90inline StyleStrokeData::StyleStrokeData(const StyleStrokeData& other) 91 : RefCounted<StyleStrokeData>() 92 , opacity(other.opacity) 93 , miterLimit(other.miterLimit) 94 , width(other.width) 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 106PassRef<StyleStrokeData> StyleStrokeData::copy() const 107{ 108 return adoptRef(*new StyleStrokeData(*this)); 109} 110 111bool StyleStrokeData::operator==(const StyleStrokeData& other) const 112{ 113 return width == other.width 114 && opacity == other.opacity 115 && miterLimit == other.miterLimit 116 && dashOffset == other.dashOffset 117 && dashArray == other.dashArray 118 && paintType == other.paintType 119 && paintColor == other.paintColor 120 && paintUri == other.paintUri 121 && visitedLinkPaintType == other.visitedLinkPaintType 122 && visitedLinkPaintColor == other.visitedLinkPaintColor 123 && visitedLinkPaintUri == other.visitedLinkPaintUri; 124} 125 126StyleStopData::StyleStopData() 127 : opacity(SVGRenderStyle::initialStopOpacity()) 128 , color(SVGRenderStyle::initialStopColor()) 129{ 130} 131 132inline StyleStopData::StyleStopData(const StyleStopData& other) 133 : RefCounted<StyleStopData>() 134 , opacity(other.opacity) 135 , color(other.color) 136{ 137} 138 139PassRef<StyleStopData> StyleStopData::copy() const 140{ 141 return adoptRef(*new StyleStopData(*this)); 142} 143 144bool StyleStopData::operator==(const StyleStopData& other) const 145{ 146 return color == other.color 147 && opacity == other.opacity; 148} 149 150StyleTextData::StyleTextData() 151 : kerning(SVGRenderStyle::initialKerning()) 152{ 153} 154 155inline StyleTextData::StyleTextData(const StyleTextData& other) 156 : RefCounted<StyleTextData>() 157 , kerning(other.kerning) 158{ 159} 160 161PassRef<StyleTextData> StyleTextData::copy() const 162{ 163 return adoptRef(*new StyleTextData(*this)); 164} 165 166bool StyleTextData::operator==(const StyleTextData& other) const 167{ 168 return kerning == other.kerning; 169} 170 171StyleMiscData::StyleMiscData() 172 : floodColor(SVGRenderStyle::initialFloodColor()) 173 , floodOpacity(SVGRenderStyle::initialFloodOpacity()) 174 , lightingColor(SVGRenderStyle::initialLightingColor()) 175 , baselineShiftValue(SVGRenderStyle::initialBaselineShiftValue()) 176{ 177} 178 179inline StyleMiscData::StyleMiscData(const StyleMiscData& other) 180 : RefCounted<StyleMiscData>() 181 , floodColor(other.floodColor) 182 , floodOpacity(other.floodOpacity) 183 , lightingColor(other.lightingColor) 184 , baselineShiftValue(other.baselineShiftValue) 185{ 186} 187 188PassRef<StyleMiscData> StyleMiscData::copy() const 189{ 190 return adoptRef(*new StyleMiscData(*this)); 191} 192 193bool StyleMiscData::operator==(const StyleMiscData& other) const 194{ 195 return floodOpacity == other.floodOpacity 196 && floodColor == other.floodColor 197 && lightingColor == other.lightingColor 198 && baselineShiftValue == other.baselineShiftValue; 199} 200 201StyleShadowSVGData::StyleShadowSVGData() 202{ 203} 204 205inline StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other) 206 : RefCounted<StyleShadowSVGData>() 207 , shadow(other.shadow ? std::make_unique<ShadowData>(*other.shadow) : nullptr) 208{ 209} 210 211PassRef<StyleShadowSVGData> StyleShadowSVGData::copy() const 212{ 213 return adoptRef(*new StyleShadowSVGData(*this)); 214} 215 216bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const 217{ 218 if ((!shadow && other.shadow) || (shadow && !other.shadow)) 219 return false; 220 if (shadow && other.shadow && (*shadow != *other.shadow)) 221 return false; 222 return true; 223} 224 225StyleResourceData::StyleResourceData() 226 : clipper(SVGRenderStyle::initialClipperResource()) 227 , filter(SVGRenderStyle::initialFilterResource()) 228 , masker(SVGRenderStyle::initialMaskerResource()) 229{ 230} 231 232inline StyleResourceData::StyleResourceData(const StyleResourceData& other) 233 : RefCounted<StyleResourceData>() 234 , clipper(other.clipper) 235 , filter(other.filter) 236 , masker(other.masker) 237{ 238} 239 240PassRef<StyleResourceData> StyleResourceData::copy() const 241{ 242 return adoptRef(*new StyleResourceData(*this)); 243} 244 245bool StyleResourceData::operator==(const StyleResourceData& other) const 246{ 247 return clipper == other.clipper 248 && filter == other.filter 249 && masker == other.masker; 250} 251 252StyleInheritedResourceData::StyleInheritedResourceData() 253 : markerStart(SVGRenderStyle::initialMarkerStartResource()) 254 , markerMid(SVGRenderStyle::initialMarkerMidResource()) 255 , markerEnd(SVGRenderStyle::initialMarkerEndResource()) 256{ 257} 258 259inline StyleInheritedResourceData::StyleInheritedResourceData(const StyleInheritedResourceData& other) 260 : RefCounted<StyleInheritedResourceData>() 261 , markerStart(other.markerStart) 262 , markerMid(other.markerMid) 263 , markerEnd(other.markerEnd) 264{ 265} 266 267PassRef<StyleInheritedResourceData> StyleInheritedResourceData::copy() const 268{ 269 return adoptRef(*new StyleInheritedResourceData(*this)); 270} 271 272bool StyleInheritedResourceData::operator==(const StyleInheritedResourceData& other) const 273{ 274 return markerStart == other.markerStart 275 && markerMid == other.markerMid 276 && markerEnd == other.markerEnd; 277} 278 279} 280