Home | History | Annotate | Download | only in style
      1 /*
      2  * Copyright (C) 1999 Antti Koivisto (koivisto (at) 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 "CursorList.h"
     26 #include "QuotesData.h"
     27 #include "RenderStyle.h"
     28 #include "RenderStyleConstants.h"
     29 #include "ShadowData.h"
     30 
     31 namespace WebCore {
     32 
     33 StyleRareInheritedData::StyleRareInheritedData()
     34     : textStrokeWidth(RenderStyle::initialTextStrokeWidth())
     35 #ifdef ANDROID_CSS_RING
     36     , ringFillColor(RenderStyle::initialRingFillColor())
     37     , ringInnerWidth(RenderStyle::initialRingInnerWidth())
     38     , ringOuterWidth(RenderStyle::initialRingOuterWidth())
     39     , ringOutset(RenderStyle::initialRingOutset())
     40     , ringPressedInnerColor(RenderStyle::initialRingPressedInnerColor())
     41     , ringPressedOuterColor(RenderStyle::initialRingPressedOuterColor())
     42     , ringRadius(RenderStyle::initialRingRadius())
     43     , ringSelectedInnerColor(RenderStyle::initialRingSelectedInnerColor())
     44     , ringSelectedOuterColor(RenderStyle::initialRingSelectedOuterColor())
     45 #endif
     46 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
     47     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
     48 #endif
     49     , textShadow(0)
     50     , indent(RenderStyle::initialTextIndent())
     51     , m_effectiveZoom(RenderStyle::initialZoom())
     52     , widows(RenderStyle::initialWidows())
     53     , orphans(RenderStyle::initialOrphans())
     54     , textSecurity(RenderStyle::initialTextSecurity())
     55     , userModify(READ_ONLY)
     56     , wordBreak(RenderStyle::initialWordBreak())
     57     , wordWrap(RenderStyle::initialWordWrap())
     58     , nbspMode(NBNORMAL)
     59     , khtmlLineBreak(LBNORMAL)
     60     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
     61     , resize(RenderStyle::initialResize())
     62     , userSelect(RenderStyle::initialUserSelect())
     63     , colorSpace(ColorSpaceDeviceRGB)
     64     , speak(SpeakNormal)
     65     , hyphens(HyphensManual)
     66     , textEmphasisFill(TextEmphasisFillFilled)
     67     , textEmphasisMark(TextEmphasisMarkNone)
     68     , textEmphasisPosition(TextEmphasisPositionOver)
     69     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
     70     , hyphenationLimitBefore(-1)
     71     , hyphenationLimitAfter(-1)
     72 {
     73 }
     74 
     75 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     76     : RefCounted<StyleRareInheritedData>()
     77     , textStrokeColor(o.textStrokeColor)
     78     , textStrokeWidth(o.textStrokeWidth)
     79     , textFillColor(o.textFillColor)
     80     , textEmphasisColor(o.textEmphasisColor)
     81 #ifdef ANDROID_CSS_RING
     82     , ringFillColor(o.ringFillColor)
     83     , ringInnerWidth(o.ringInnerWidth)
     84     , ringOuterWidth(o.ringOuterWidth)
     85     , ringOutset(o.ringOutset)
     86     , ringPressedInnerColor(o.ringPressedInnerColor)
     87     , ringPressedOuterColor(o.ringPressedOuterColor)
     88     , ringRadius(o.ringRadius)
     89     , ringSelectedInnerColor(o.ringSelectedInnerColor)
     90     , ringSelectedOuterColor(o.ringSelectedOuterColor)
     91 #endif
     92 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
     93     , tapHighlightColor(o.tapHighlightColor)
     94 #endif
     95     , textShadow(o.textShadow ? new ShadowData(*o.textShadow) : 0)
     96     , highlight(o.highlight)
     97     , cursorData(o.cursorData)
     98     , indent(o.indent)
     99     , m_effectiveZoom(o.m_effectiveZoom)
    100     , widows(o.widows)
    101     , orphans(o.orphans)
    102     , textSecurity(o.textSecurity)
    103     , userModify(o.userModify)
    104     , wordBreak(o.wordBreak)
    105     , wordWrap(o.wordWrap)
    106     , nbspMode(o.nbspMode)
    107     , khtmlLineBreak(o.khtmlLineBreak)
    108     , textSizeAdjust(o.textSizeAdjust)
    109     , resize(o.resize)
    110     , userSelect(o.userSelect)
    111     , colorSpace(o.colorSpace)
    112     , speak(o.speak)
    113     , hyphens(o.hyphens)
    114     , textEmphasisFill(o.textEmphasisFill)
    115     , textEmphasisMark(o.textEmphasisMark)
    116     , textEmphasisPosition(o.textEmphasisPosition)
    117     , m_lineBoxContain(o.m_lineBoxContain)
    118     , hyphenationString(o.hyphenationString)
    119     , hyphenationLimitBefore(o.hyphenationLimitBefore)
    120     , hyphenationLimitAfter(o.hyphenationLimitAfter)
    121     , locale(o.locale)
    122     , textEmphasisCustomMark(o.textEmphasisCustomMark)
    123 {
    124 }
    125 
    126 StyleRareInheritedData::~StyleRareInheritedData()
    127 {
    128     delete textShadow;
    129 }
    130 
    131 static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
    132 {
    133     if (c1 == c2)
    134         return true;
    135     if ((!c1 && c2) || (c1 && !c2))
    136         return false;
    137     return (*c1 == *c2);
    138 }
    139 
    140 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
    141 {
    142     return textStrokeColor == o.textStrokeColor
    143         && textStrokeWidth == o.textStrokeWidth
    144         && textFillColor == o.textFillColor
    145         && textEmphasisColor == o.textEmphasisColor
    146         && shadowDataEquivalent(o)
    147         && highlight == o.highlight
    148         && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
    149         && indent == o.indent
    150         && m_effectiveZoom == o.m_effectiveZoom
    151         && widows == o.widows
    152         && orphans == o.orphans
    153         && textSecurity == o.textSecurity
    154         && userModify == o.userModify
    155         && wordBreak == o.wordBreak
    156         && wordWrap == o.wordWrap
    157         && nbspMode == o.nbspMode
    158         && khtmlLineBreak == o.khtmlLineBreak
    159         && textSizeAdjust == o.textSizeAdjust
    160 #ifdef ANDROID_CSS_RING
    161         && ringFillColor == o.ringFillColor
    162         && ringInnerWidth == o.ringInnerWidth
    163         && ringOuterWidth == o.ringOuterWidth
    164         && ringOutset == o.ringOutset
    165         && ringPressedInnerColor == o.ringPressedInnerColor
    166         && ringPressedOuterColor == o.ringPressedOuterColor
    167         && ringRadius == o.ringRadius
    168         && ringSelectedInnerColor == o.ringSelectedInnerColor
    169         && ringSelectedOuterColor == o.ringSelectedOuterColor
    170 #endif
    171 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
    172         && tapHighlightColor == o.tapHighlightColor
    173 #endif
    174         && resize == o.resize
    175         && userSelect == o.userSelect
    176         && colorSpace == o.colorSpace
    177         && speak == o.speak
    178         && hyphens == o.hyphens
    179         && hyphenationLimitBefore == o.hyphenationLimitBefore
    180         && hyphenationLimitAfter == o.hyphenationLimitAfter
    181         && textEmphasisFill == o.textEmphasisFill
    182         && textEmphasisMark == o.textEmphasisMark
    183         && textEmphasisPosition == o.textEmphasisPosition
    184         && m_lineBoxContain == o.m_lineBoxContain
    185         && hyphenationString == o.hyphenationString
    186         && locale == o.locale
    187         && textEmphasisCustomMark == o.textEmphasisCustomMark
    188         && *quotes == *o.quotes;
    189 }
    190 
    191 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
    192 {
    193     if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
    194         return false;
    195     if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
    196         return false;
    197     return true;
    198 }
    199 
    200 } // namespace WebCore
    201