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 "CursorList.h"
26 #include "QuotesData.h"
27 #include "RenderStyle.h"
28 #include "RenderStyleConstants.h"
29 #include "ShadowData.h"
30 
31 namespace WebCore {
32 
StyleRareInheritedData()33 StyleRareInheritedData::StyleRareInheritedData()
34     : textStrokeWidth(RenderStyle::initialTextStrokeWidth())
35     , indent(RenderStyle::initialTextIndent())
36     , m_effectiveZoom(RenderStyle::initialZoom())
37     , widows(RenderStyle::initialWidows())
38     , orphans(RenderStyle::initialOrphans())
39     , m_hasAutoWidows(true)
40     , m_hasAutoOrphans(true)
41     , textSecurity(RenderStyle::initialTextSecurity())
42     , userModify(READ_ONLY)
43     , wordBreak(RenderStyle::initialWordBreak())
44     , wordWrap(RenderStyle::initialWordWrap())
45     , nbspMode(NBNORMAL)
46     , khtmlLineBreak(LBNORMAL)
47     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
48     , resize(RenderStyle::initialResize())
49     , userSelect(RenderStyle::initialUserSelect())
50     , colorSpace(ColorSpaceDeviceRGB)
51     , speak(SpeakNormal)
52     , hyphens(HyphensManual)
53     , textEmphasisFill(TextEmphasisFillFilled)
54     , textEmphasisMark(TextEmphasisMarkNone)
55     , textEmphasisPosition(TextEmphasisPositionOver)
56     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
57     , hyphenationLimitBefore(-1)
58     , hyphenationLimitAfter(-1)
59 {
60 }
61 
StyleRareInheritedData(const StyleRareInheritedData & o)62 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
63     : RefCounted<StyleRareInheritedData>()
64     , textStrokeColor(o.textStrokeColor)
65     , textStrokeWidth(o.textStrokeWidth)
66     , textFillColor(o.textFillColor)
67     , textEmphasisColor(o.textEmphasisColor)
68     , textShadow(o.textShadow ? adoptPtr(new ShadowData(*o.textShadow)) : nullptr)
69     , highlight(o.highlight)
70     , cursorData(o.cursorData)
71     , indent(o.indent)
72     , m_effectiveZoom(o.m_effectiveZoom)
73     , widows(o.widows)
74     , orphans(o.orphans)
75     , m_hasAutoWidows(o.m_hasAutoWidows)
76     , m_hasAutoOrphans(o.m_hasAutoOrphans)
77     , textSecurity(o.textSecurity)
78     , userModify(o.userModify)
79     , wordBreak(o.wordBreak)
80     , wordWrap(o.wordWrap)
81     , nbspMode(o.nbspMode)
82     , khtmlLineBreak(o.khtmlLineBreak)
83     , textSizeAdjust(o.textSizeAdjust)
84     , resize(o.resize)
85     , userSelect(o.userSelect)
86     , colorSpace(o.colorSpace)
87     , speak(o.speak)
88     , hyphens(o.hyphens)
89     , textEmphasisFill(o.textEmphasisFill)
90     , textEmphasisMark(o.textEmphasisMark)
91     , textEmphasisPosition(o.textEmphasisPosition)
92     , m_lineBoxContain(o.m_lineBoxContain)
93     , hyphenationString(o.hyphenationString)
94     , hyphenationLimitBefore(o.hyphenationLimitBefore)
95     , hyphenationLimitAfter(o.hyphenationLimitAfter)
96     , locale(o.locale)
97     , textEmphasisCustomMark(o.textEmphasisCustomMark)
98 {
99 }
100 
~StyleRareInheritedData()101 StyleRareInheritedData::~StyleRareInheritedData()
102 {
103 }
104 
cursorDataEquivalent(const CursorList * c1,const CursorList * c2)105 static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
106 {
107     if (c1 == c2)
108         return true;
109     if ((!c1 && c2) || (c1 && !c2))
110         return false;
111     return (*c1 == *c2);
112 }
113 
operator ==(const StyleRareInheritedData & o) const114 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
115 {
116     return textStrokeColor == o.textStrokeColor
117         && textStrokeWidth == o.textStrokeWidth
118         && textFillColor == o.textFillColor
119         && textEmphasisColor == o.textEmphasisColor
120         && shadowDataEquivalent(o)
121         && highlight == o.highlight
122         && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
123         && indent == o.indent
124         && m_effectiveZoom == o.m_effectiveZoom
125         && widows == o.widows
126         && orphans == o.orphans
127         && m_hasAutoWidows == o.m_hasAutoWidows
128         && m_hasAutoOrphans == o.m_hasAutoOrphans
129         && textSecurity == o.textSecurity
130         && userModify == o.userModify
131         && wordBreak == o.wordBreak
132         && wordWrap == o.wordWrap
133         && nbspMode == o.nbspMode
134         && khtmlLineBreak == o.khtmlLineBreak
135         && textSizeAdjust == o.textSizeAdjust
136         && resize == o.resize
137         && userSelect == o.userSelect
138         && colorSpace == o.colorSpace
139         && speak == o.speak
140         && hyphens == o.hyphens
141         && hyphenationLimitBefore == o.hyphenationLimitBefore
142         && hyphenationLimitAfter == o.hyphenationLimitAfter
143         && textEmphasisFill == o.textEmphasisFill
144         && textEmphasisMark == o.textEmphasisMark
145         && textEmphasisPosition == o.textEmphasisPosition
146         && m_lineBoxContain == o.m_lineBoxContain
147         && hyphenationString == o.hyphenationString
148         && locale == o.locale
149         && textEmphasisCustomMark == o.textEmphasisCustomMark
150         && *quotes == *o.quotes;
151 }
152 
shadowDataEquivalent(const StyleRareInheritedData & o) const153 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
154 {
155     if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
156         return false;
157     if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
158         return false;
159     return true;
160 }
161 
162 } // namespace WebCore
163