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 "core/rendering/style/StyleRareInheritedData.h"
     24 
     25 #include "core/rendering/style/AppliedTextDecoration.h"
     26 #include "core/rendering/style/CursorData.h"
     27 #include "core/rendering/style/DataEquivalency.h"
     28 #include "core/rendering/style/QuotesData.h"
     29 #include "core/rendering/style/RenderStyle.h"
     30 #include "core/rendering/style/RenderStyleConstants.h"
     31 #include "core/rendering/style/ShadowList.h"
     32 #include "core/rendering/style/StyleImage.h"
     33 
     34 namespace WebCore {
     35 
     36 struct SameSizeAsStyleRareInheritedData : public RefCounted<SameSizeAsStyleRareInheritedData> {
     37     void* styleImage;
     38     Color firstColor;
     39     float firstFloat;
     40     Color colors[5];
     41     void* ownPtrs[1];
     42     AtomicString atomicStrings[4];
     43     void* refPtrs[3];
     44     Length lengths[1];
     45     float secondFloat;
     46     unsigned m_bitfields[2];
     47     short pagedMediaShorts[2];
     48     unsigned unsigneds[1];
     49     short hyphenationShorts[3];
     50 
     51     Color touchColors;
     52 };
     53 
     54 COMPILE_ASSERT(sizeof(StyleRareInheritedData) == sizeof(SameSizeAsStyleRareInheritedData), StyleRareInheritedData_should_bit_pack);
     55 
     56 StyleRareInheritedData::StyleRareInheritedData()
     57     : listStyleImage(RenderStyle::initialListStyleImage())
     58     , textStrokeWidth(RenderStyle::initialTextStrokeWidth())
     59     , indent(RenderStyle::initialTextIndent())
     60     , m_effectiveZoom(RenderStyle::initialZoom())
     61     , widows(RenderStyle::initialWidows())
     62     , orphans(RenderStyle::initialOrphans())
     63     , m_hasAutoWidows(true)
     64     , m_hasAutoOrphans(true)
     65     , m_textStrokeColorIsCurrentColor(true)
     66     , m_textFillColorIsCurrentColor(true)
     67     , m_textEmphasisColorIsCurrentColor(true)
     68     , m_visitedLinkTextStrokeColorIsCurrentColor(true)
     69     , m_visitedLinkTextFillColorIsCurrentColor(true)
     70     , m_visitedLinkTextEmphasisColorIsCurrentColor(true)
     71     , textSecurity(RenderStyle::initialTextSecurity())
     72     , userModify(READ_ONLY)
     73     , wordBreak(RenderStyle::initialWordBreak())
     74     , overflowWrap(RenderStyle::initialOverflowWrap())
     75     , lineBreak(LineBreakAuto)
     76     , resize(RenderStyle::initialResize())
     77     , userSelect(RenderStyle::initialUserSelect())
     78     , speak(SpeakNormal)
     79     , hyphens(HyphensManual)
     80     , textEmphasisFill(TextEmphasisFillFilled)
     81     , textEmphasisMark(TextEmphasisMarkNone)
     82     , textEmphasisPosition(TextEmphasisPositionOver)
     83     , m_textAlignLast(RenderStyle::initialTextAlignLast())
     84     , m_textJustify(RenderStyle::initialTextJustify())
     85     , m_textOrientation(TextOrientationVerticalRight)
     86     , m_textIndentLine(RenderStyle::initialTextIndentLine())
     87     , m_textIndentType(RenderStyle::initialTextIndentLine())
     88     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
     89     , m_imageRendering(RenderStyle::initialImageRendering())
     90     , m_textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
     91     , m_rubyPosition(RenderStyle::initialRubyPosition())
     92     , m_touchActionDelay(RenderStyle::initialTouchActionDelay())
     93     , m_subtreeWillChangeContents(false)
     94     , hyphenationLimitBefore(-1)
     95     , hyphenationLimitAfter(-1)
     96     , hyphenationLimitLines(-1)
     97     , m_tabSize(RenderStyle::initialTabSize())
     98     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
     99 {
    100 }
    101 
    102 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
    103     : RefCounted<StyleRareInheritedData>()
    104     , listStyleImage(o.listStyleImage)
    105     , m_textStrokeColor(o.m_textStrokeColor)
    106     , textStrokeWidth(o.textStrokeWidth)
    107     , m_textFillColor(o.m_textFillColor)
    108     , m_textEmphasisColor(o.m_textEmphasisColor)
    109     , m_visitedLinkTextStrokeColor(o.m_visitedLinkTextStrokeColor)
    110     , m_visitedLinkTextFillColor(o.m_visitedLinkTextFillColor)
    111     , m_visitedLinkTextEmphasisColor(o.m_visitedLinkTextEmphasisColor)
    112     , textShadow(o.textShadow)
    113     , highlight(o.highlight)
    114     , cursorData(o.cursorData)
    115     , indent(o.indent)
    116     , m_effectiveZoom(o.m_effectiveZoom)
    117     , widows(o.widows)
    118     , orphans(o.orphans)
    119     , m_hasAutoWidows(o.m_hasAutoWidows)
    120     , m_hasAutoOrphans(o.m_hasAutoOrphans)
    121     , m_textStrokeColorIsCurrentColor(o.m_textStrokeColorIsCurrentColor)
    122     , m_textFillColorIsCurrentColor(o.m_textFillColorIsCurrentColor)
    123     , m_textEmphasisColorIsCurrentColor(o.m_textEmphasisColorIsCurrentColor)
    124     , m_visitedLinkTextStrokeColorIsCurrentColor(o.m_visitedLinkTextStrokeColorIsCurrentColor)
    125     , m_visitedLinkTextFillColorIsCurrentColor(o.m_visitedLinkTextFillColorIsCurrentColor)
    126     , m_visitedLinkTextEmphasisColorIsCurrentColor(o.m_visitedLinkTextEmphasisColorIsCurrentColor)
    127     , textSecurity(o.textSecurity)
    128     , userModify(o.userModify)
    129     , wordBreak(o.wordBreak)
    130     , overflowWrap(o.overflowWrap)
    131     , lineBreak(o.lineBreak)
    132     , resize(o.resize)
    133     , userSelect(o.userSelect)
    134     , speak(o.speak)
    135     , hyphens(o.hyphens)
    136     , textEmphasisFill(o.textEmphasisFill)
    137     , textEmphasisMark(o.textEmphasisMark)
    138     , textEmphasisPosition(o.textEmphasisPosition)
    139     , m_textAlignLast(o.m_textAlignLast)
    140     , m_textJustify(o.m_textJustify)
    141     , m_textOrientation(o.m_textOrientation)
    142     , m_textIndentLine(o.m_textIndentLine)
    143     , m_textIndentType(o.m_textIndentType)
    144     , m_lineBoxContain(o.m_lineBoxContain)
    145     , m_imageRendering(o.m_imageRendering)
    146     , m_textUnderlinePosition(o.m_textUnderlinePosition)
    147     , m_rubyPosition(o.m_rubyPosition)
    148     , m_touchActionDelay(o.m_touchActionDelay)
    149     , m_subtreeWillChangeContents(o.m_subtreeWillChangeContents)
    150     , hyphenationString(o.hyphenationString)
    151     , hyphenationLimitBefore(o.hyphenationLimitBefore)
    152     , hyphenationLimitAfter(o.hyphenationLimitAfter)
    153     , hyphenationLimitLines(o.hyphenationLimitLines)
    154     , locale(o.locale)
    155     , textEmphasisCustomMark(o.textEmphasisCustomMark)
    156     , m_tabSize(o.m_tabSize)
    157     , tapHighlightColor(o.tapHighlightColor)
    158     , appliedTextDecorations(o.appliedTextDecorations)
    159 {
    160 }
    161 
    162 StyleRareInheritedData::~StyleRareInheritedData()
    163 {
    164 }
    165 
    166 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
    167 {
    168     return m_textStrokeColor == o.m_textStrokeColor
    169         && textStrokeWidth == o.textStrokeWidth
    170         && m_textFillColor == o.m_textFillColor
    171         && m_textEmphasisColor == o.m_textEmphasisColor
    172         && m_visitedLinkTextStrokeColor == o.m_visitedLinkTextStrokeColor
    173         && m_visitedLinkTextFillColor == o.m_visitedLinkTextFillColor
    174         && m_visitedLinkTextEmphasisColor == o.m_visitedLinkTextEmphasisColor
    175         && tapHighlightColor == o.tapHighlightColor
    176         && shadowDataEquivalent(o)
    177         && highlight == o.highlight
    178         && dataEquivalent(cursorData.get(), o.cursorData.get())
    179         && indent == o.indent
    180         && m_effectiveZoom == o.m_effectiveZoom
    181         && widows == o.widows
    182         && orphans == o.orphans
    183         && m_hasAutoWidows == o.m_hasAutoWidows
    184         && m_hasAutoOrphans == o.m_hasAutoOrphans
    185         && m_textStrokeColorIsCurrentColor == o.m_textStrokeColorIsCurrentColor
    186         && m_textFillColorIsCurrentColor == o.m_textFillColorIsCurrentColor
    187         && m_textEmphasisColorIsCurrentColor == o.m_textEmphasisColorIsCurrentColor
    188         && m_visitedLinkTextStrokeColorIsCurrentColor == o.m_visitedLinkTextStrokeColorIsCurrentColor
    189         && m_visitedLinkTextFillColorIsCurrentColor == o.m_visitedLinkTextFillColorIsCurrentColor
    190         && m_visitedLinkTextEmphasisColorIsCurrentColor == o.m_visitedLinkTextEmphasisColorIsCurrentColor
    191         && textSecurity == o.textSecurity
    192         && userModify == o.userModify
    193         && wordBreak == o.wordBreak
    194         && overflowWrap == o.overflowWrap
    195         && lineBreak == o.lineBreak
    196         && resize == o.resize
    197         && userSelect == o.userSelect
    198         && speak == o.speak
    199         && hyphens == o.hyphens
    200         && hyphenationLimitBefore == o.hyphenationLimitBefore
    201         && hyphenationLimitAfter == o.hyphenationLimitAfter
    202         && hyphenationLimitLines == o.hyphenationLimitLines
    203         && textEmphasisFill == o.textEmphasisFill
    204         && textEmphasisMark == o.textEmphasisMark
    205         && textEmphasisPosition == o.textEmphasisPosition
    206         && m_touchActionDelay == o.m_touchActionDelay
    207         && m_textAlignLast == o.m_textAlignLast
    208         && m_textJustify == o.m_textJustify
    209         && m_textOrientation == o.m_textOrientation
    210         && m_textIndentLine == o.m_textIndentLine
    211         && m_textIndentType == o.m_textIndentType
    212         && m_lineBoxContain == o.m_lineBoxContain
    213         && m_subtreeWillChangeContents == o.m_subtreeWillChangeContents
    214         && hyphenationString == o.hyphenationString
    215         && locale == o.locale
    216         && textEmphasisCustomMark == o.textEmphasisCustomMark
    217         && quotesDataEquivalent(o)
    218         && m_tabSize == o.m_tabSize
    219         && m_imageRendering == o.m_imageRendering
    220         && m_textUnderlinePosition == o.m_textUnderlinePosition
    221         && m_rubyPosition == o.m_rubyPosition
    222         && dataEquivalent(listStyleImage.get(), o.listStyleImage.get())
    223         && dataEquivalent(appliedTextDecorations, o.appliedTextDecorations);
    224 }
    225 
    226 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
    227 {
    228     return dataEquivalent(textShadow.get(), o.textShadow.get());
    229 }
    230 
    231 bool StyleRareInheritedData::quotesDataEquivalent(const StyleRareInheritedData& o) const
    232 {
    233     return dataEquivalent(quotes, o.quotes);
    234 }
    235 
    236 } // namespace WebCore
    237