WebCore/rendering/style/StyleRareInheritedData.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
       
     3  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
       
     4  *
       
     5  * This library is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Library General Public
       
     7  * License as published by the Free Software Foundation; either
       
     8  * version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This library is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Library General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Library General Public License
       
    16  * along with this library; see the file COPYING.LIB.  If not, write to
       
    17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    18  * Boston, MA 02110-1301, USA.
       
    19  *
       
    20  */
       
    21 
       
    22 #include "config.h"
       
    23 #include "StyleRareInheritedData.h"
       
    24 
       
    25 #include "RenderStyle.h"
       
    26 #include "RenderStyleConstants.h"
       
    27 
       
    28 namespace WebCore {
       
    29 
       
    30 StyleRareInheritedData::StyleRareInheritedData()
       
    31     : textStrokeWidth(RenderStyle::initialTextStrokeWidth())
       
    32     , textShadow(0)
       
    33     , indent(RenderStyle::initialTextIndent())
       
    34     , m_effectiveZoom(RenderStyle::initialZoom())
       
    35     , widows(RenderStyle::initialWidows())
       
    36     , orphans(RenderStyle::initialOrphans())
       
    37     , textSecurity(RenderStyle::initialTextSecurity())
       
    38     , userModify(READ_ONLY)
       
    39     , wordBreak(RenderStyle::initialWordBreak())
       
    40     , wordWrap(RenderStyle::initialWordWrap())
       
    41     , nbspMode(NBNORMAL)
       
    42     , khtmlLineBreak(LBNORMAL)
       
    43     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
       
    44     , resize(RenderStyle::initialResize())
       
    45     , userSelect(RenderStyle::initialUserSelect())
       
    46     , colorSpace(DeviceColorSpace)
       
    47     , hyphens(HyphensManual)
       
    48 {
       
    49 }
       
    50 
       
    51 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
       
    52     : RefCounted<StyleRareInheritedData>()
       
    53     , textStrokeColor(o.textStrokeColor)
       
    54     , textStrokeWidth(o.textStrokeWidth)
       
    55     , textFillColor(o.textFillColor)
       
    56     , textShadow(o.textShadow ? new ShadowData(*o.textShadow) : 0)
       
    57     , highlight(o.highlight)
       
    58     , cursorData(o.cursorData)
       
    59     , indent(o.indent)
       
    60     , m_effectiveZoom(o.m_effectiveZoom)
       
    61     , widows(o.widows)
       
    62     , orphans(o.orphans)
       
    63     , textSecurity(o.textSecurity)
       
    64     , userModify(o.userModify)
       
    65     , wordBreak(o.wordBreak)
       
    66     , wordWrap(o.wordWrap)
       
    67     , nbspMode(o.nbspMode)
       
    68     , khtmlLineBreak(o.khtmlLineBreak)
       
    69     , textSizeAdjust(o.textSizeAdjust)
       
    70     , resize(o.resize)
       
    71     , userSelect(o.userSelect)
       
    72     , colorSpace(o.colorSpace)
       
    73     , hyphens(o.hyphens)
       
    74     , hyphenateCharacter(o.hyphenateCharacter)
       
    75 {
       
    76 }
       
    77 
       
    78 StyleRareInheritedData::~StyleRareInheritedData()
       
    79 {
       
    80     delete textShadow;
       
    81 }
       
    82 
       
    83 static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
       
    84 {
       
    85     if (c1 == c2)
       
    86         return true;
       
    87     if ((!c1 && c2) || (c1 && !c2))
       
    88         return false;
       
    89     return (*c1 == *c2);
       
    90 }
       
    91 
       
    92 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
       
    93 {
       
    94     return textStrokeColor == o.textStrokeColor
       
    95         && textStrokeWidth == o.textStrokeWidth
       
    96         && textFillColor == o.textFillColor
       
    97         && shadowDataEquivalent(o)
       
    98         && highlight == o.highlight
       
    99         && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
       
   100         && indent == o.indent
       
   101         && m_effectiveZoom == o.m_effectiveZoom
       
   102         && widows == o.widows
       
   103         && orphans == o.orphans
       
   104         && textSecurity == o.textSecurity
       
   105         && userModify == o.userModify
       
   106         && wordBreak == o.wordBreak
       
   107         && wordWrap == o.wordWrap
       
   108         && nbspMode == o.nbspMode
       
   109         && khtmlLineBreak == o.khtmlLineBreak
       
   110         && textSizeAdjust == o.textSizeAdjust
       
   111         && resize == o.resize
       
   112         && userSelect == o.userSelect
       
   113         && colorSpace == o.colorSpace
       
   114         && hyphens == o.hyphens
       
   115         && hyphenateCharacter == o.hyphenateCharacter;
       
   116 }
       
   117 
       
   118 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
       
   119 {
       
   120     if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
       
   121         return false;
       
   122     if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
       
   123         return false;
       
   124     return true;
       
   125 }
       
   126 
       
   127 } // namespace WebCore