Home | History | Annotate | Download | only in style
      1 /*
      2     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3                   2004, 2005, 2007 Rob Buis <buis (at) kde.org>
      4 
      5     Based on khtml code by:
      6     Copyright (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      7     Copyright (C) 1999-2003 Lars Knoll (knoll (at) kde.org)
      8     Copyright (C) 2002-2003 Dirk Mueller (mueller (at) kde.org)
      9     Copyright (C) 2002 Apple Computer, Inc.
     10 
     11     This library is free software; you can redistribute it and/or
     12     modify it under the terms of the GNU Library General Public
     13     License as published by the Free Software Foundation; either
     14     version 2 of the License, or (at your option) any later version.
     15 
     16     This library is distributed in the hope that it will be useful,
     17     but WITHOUT ANY WARRANTY; without even the implied warranty of
     18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19     Library General Public License for more details.
     20 
     21     You should have received a copy of the GNU Library General Public License
     22     along with this library; see the file COPYING.LIB.  If not, write to
     23     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     24     Boston, MA 02110-1301, USA.
     25 */
     26 
     27 #include "config.h"
     28 #if ENABLE(SVG)
     29 #include "SVGRenderStyleDefs.h"
     30 
     31 #include "RenderStyle.h"
     32 #include "SVGRenderStyle.h"
     33 
     34 using namespace WebCore;
     35 
     36 StyleFillData::StyleFillData()
     37 {
     38     paint = SVGRenderStyle::initialFillPaint();
     39     opacity = SVGRenderStyle::initialFillOpacity();
     40 }
     41 
     42 StyleFillData::StyleFillData(const StyleFillData& other)
     43     : RefCounted<StyleFillData>()
     44 {
     45     paint = other.paint;
     46     opacity = other.opacity;
     47 }
     48 
     49 bool StyleFillData::operator==(const StyleFillData &other) const
     50 {
     51     if (opacity != other.opacity)
     52         return false;
     53 
     54     if (!paint || !other.paint)
     55         return paint == other.paint;
     56 
     57     if (paint->paintType() != other.paint->paintType())
     58         return false;
     59 
     60     if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI)
     61         return paint->uri() == other.paint->uri();
     62 
     63     if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR)
     64         return paint->color() == other.paint->color();
     65 
     66     return paint == other.paint;
     67 }
     68 
     69 StyleStrokeData::StyleStrokeData()
     70 {
     71     width = SVGRenderStyle::initialStrokeWidth();
     72     paint = SVGRenderStyle::initialStrokePaint();
     73     opacity = SVGRenderStyle::initialStrokeOpacity();
     74     miterLimit = SVGRenderStyle::initialStrokeMiterLimit();
     75     dashOffset = SVGRenderStyle::initialStrokeDashOffset();
     76     dashArray = SVGRenderStyle::initialStrokeDashArray();
     77 }
     78 
     79 StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
     80     : RefCounted<StyleStrokeData>()
     81 {
     82     width = other.width;
     83     paint = other.paint;
     84     opacity = other.opacity;
     85     miterLimit = other.miterLimit;
     86     dashOffset = other.dashOffset;
     87     dashArray = other.dashArray;
     88 }
     89 
     90 bool StyleStrokeData::operator==(const StyleStrokeData &other) const
     91 {
     92     return (paint == other.paint) &&
     93            (width == other.width) &&
     94            (opacity == other.opacity) &&
     95            (miterLimit == other.miterLimit) &&
     96            (dashOffset == other.dashOffset) &&
     97            (dashArray == other.dashArray);
     98 }
     99 
    100 StyleStopData::StyleStopData()
    101 {
    102     color = SVGRenderStyle::initialStopColor();
    103     opacity = SVGRenderStyle::initialStopOpacity();
    104 }
    105 
    106 StyleStopData::StyleStopData(const StyleStopData& other)
    107     : RefCounted<StyleStopData>()
    108 {
    109     color = other.color;
    110     opacity = other.opacity;
    111 }
    112 
    113 bool StyleStopData::operator==(const StyleStopData &other) const
    114 {
    115     return (color == other.color) &&
    116            (opacity == other.opacity);
    117 }
    118 
    119 StyleTextData::StyleTextData()
    120 {
    121     kerning = SVGRenderStyle::initialKerning();
    122 }
    123 
    124 StyleTextData::StyleTextData(const StyleTextData& other)
    125     : RefCounted<StyleTextData>()
    126 {
    127     kerning = other.kerning;
    128 }
    129 
    130 bool StyleTextData::operator==(const StyleTextData& other) const
    131 {
    132     return kerning == other.kerning;
    133 }
    134 
    135 StyleClipData::StyleClipData()
    136 {
    137     clipPath = SVGRenderStyle::initialClipPath();
    138 }
    139 
    140 StyleClipData::StyleClipData(const StyleClipData& other)
    141     : RefCounted<StyleClipData>()
    142 {
    143     clipPath = other.clipPath;
    144 }
    145 
    146 bool StyleClipData::operator==(const StyleClipData &other) const
    147 {
    148     return (clipPath == other.clipPath);
    149 }
    150 
    151 StyleMaskData::StyleMaskData()
    152 {
    153     maskElement = SVGRenderStyle::initialMaskElement();
    154 }
    155 
    156 StyleMaskData::StyleMaskData(const StyleMaskData& other)
    157     : RefCounted<StyleMaskData>()
    158 {
    159     maskElement = other.maskElement;
    160 }
    161 
    162 bool StyleMaskData::operator==(const StyleMaskData &other) const
    163 {
    164     return (maskElement == other.maskElement);
    165 }
    166 
    167 StyleMarkerData::StyleMarkerData()
    168 {
    169     startMarker = SVGRenderStyle::initialStartMarker();
    170     midMarker = SVGRenderStyle::initialMidMarker();
    171     endMarker = SVGRenderStyle::initialEndMarker();
    172 }
    173 
    174 StyleMarkerData::StyleMarkerData(const StyleMarkerData& other)
    175     : RefCounted<StyleMarkerData>()
    176 {
    177     startMarker = other.startMarker;
    178     midMarker = other.midMarker;
    179     endMarker = other.endMarker;
    180 }
    181 
    182 bool StyleMarkerData::operator==(const StyleMarkerData &other) const
    183 {
    184     return (startMarker == other.startMarker && midMarker == other.midMarker && endMarker == other.endMarker);
    185 }
    186 
    187 StyleMiscData::StyleMiscData()
    188 {
    189     floodColor = SVGRenderStyle::initialFloodColor();
    190     floodOpacity = SVGRenderStyle::initialFloodOpacity();
    191     lightingColor = SVGRenderStyle::initialLightingColor();
    192     baselineShiftValue = SVGRenderStyle::initialBaselineShiftValue();
    193 }
    194 
    195 StyleMiscData::StyleMiscData(const StyleMiscData& other)
    196     : RefCounted<StyleMiscData>()
    197 {
    198     filter = other.filter;
    199     floodColor = other.floodColor;
    200     floodOpacity = other.floodOpacity;
    201     lightingColor = other.lightingColor;
    202     baselineShiftValue = other.baselineShiftValue;
    203 }
    204 
    205 bool StyleMiscData::operator==(const StyleMiscData &other) const
    206 {
    207     return filter == other.filter
    208            && floodOpacity == other.floodOpacity
    209            && floodColor == other.floodColor
    210            && lightingColor == other.lightingColor
    211            && baselineShiftValue == other.baselineShiftValue;
    212 }
    213 
    214 StyleShadowSVGData::StyleShadowSVGData()
    215 {
    216 }
    217 
    218 StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other)
    219     : RefCounted<StyleShadowSVGData>()
    220     , shadow(other.shadow ? new ShadowData(*other.shadow) : 0)
    221 {
    222 }
    223 
    224 bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const
    225 {
    226     if ((!shadow && other.shadow) || (shadow && !other.shadow))
    227         return false;
    228     if (shadow && other.shadow && (*shadow != *other.shadow))
    229         return false;
    230     return true;
    231 }
    232 
    233 #endif // ENABLE(SVG)
    234 
    235 // vim:ts=4:noet
    236