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 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 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
     33     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
     34 #endif
     35     , textShadow(0)
     36     , textSecurity(RenderStyle::initialTextSecurity())
     37     , userModify(READ_ONLY)
     38     , wordBreak(RenderStyle::initialWordBreak())
     39     , wordWrap(RenderStyle::initialWordWrap())
     40     , nbspMode(NBNORMAL)
     41     , khtmlLineBreak(LBNORMAL)
     42     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
     43     , resize(RenderStyle::initialResize())
     44     , userSelect(RenderStyle::initialUserSelect())
     45     , colorSpace(DeviceColorSpace)
     46 {
     47 }
     48 
     49 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     50     : RefCounted<StyleRareInheritedData>()
     51     , textStrokeColor(o.textStrokeColor)
     52     , textStrokeWidth(o.textStrokeWidth)
     53     , textFillColor(o.textFillColor)
     54 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
     55     , tapHighlightColor(o.tapHighlightColor)
     56 #endif
     57     , textShadow(o.textShadow ? new ShadowData(*o.textShadow) : 0)
     58     , highlight(o.highlight)
     59     , textSecurity(o.textSecurity)
     60     , userModify(o.userModify)
     61     , wordBreak(o.wordBreak)
     62     , wordWrap(o.wordWrap)
     63     , nbspMode(o.nbspMode)
     64     , khtmlLineBreak(o.khtmlLineBreak)
     65     , textSizeAdjust(o.textSizeAdjust)
     66     , resize(o.resize)
     67     , userSelect(o.userSelect)
     68     , colorSpace(o.colorSpace)
     69 {
     70 }
     71 
     72 StyleRareInheritedData::~StyleRareInheritedData()
     73 {
     74     delete textShadow;
     75 }
     76 
     77 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
     78 {
     79     return textStrokeColor == o.textStrokeColor
     80         && textStrokeWidth == o.textStrokeWidth
     81         && textFillColor == o.textFillColor
     82         && shadowDataEquivalent(o)
     83         && highlight == o.highlight
     84         && textSecurity == o.textSecurity
     85         && userModify == o.userModify
     86         && wordBreak == o.wordBreak
     87         && wordWrap == o.wordWrap
     88         && nbspMode == o.nbspMode
     89         && khtmlLineBreak == o.khtmlLineBreak
     90         && textSizeAdjust == o.textSizeAdjust
     91 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
     92         && tapHighlightColor == o.tapHighlightColor
     93 #endif
     94         && resize == o.resize
     95         && userSelect == o.userSelect
     96         && colorSpace == o.colorSpace;
     97 }
     98 
     99 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
    100 {
    101     if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
    102         return false;
    103     if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
    104         return false;
    105     return true;
    106 }
    107 
    108 } // namespace WebCore
    109