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