Remove CSS3_TEXT_DECORATION define
[WebKit-https.git] / Source / WebCore / rendering / style / StyleRareInheritedData.cpp
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 #include "StyleImage.h"
31
32 namespace WebCore {
33
34 struct GreaterThanOrSameSizeAsStyleRareInheritedData : public RefCounted<GreaterThanOrSameSizeAsStyleRareInheritedData> {
35     void* styleImage;
36     Color firstColor;
37     float firstFloat;
38     Color colors[5];
39     void* ownPtrs[1];
40     AtomicString atomicStrings[5];
41     void* refPtrs[2];
42     Length lengths[2];
43     float secondFloat;
44     unsigned m_bitfields[4];
45     short pagedMediaShorts[2];
46     unsigned unsigneds[1];
47     short hyphenationShorts[3];
48
49 #if PLATFORM(IOS)
50     Color compositionColor;
51 #endif
52 #if ENABLE(IOS_TEXT_AUTOSIZING)
53     TextSizeAdjustment textSizeAdjust;
54 #endif
55
56 #if ENABLE(CSS_IMAGE_RESOLUTION)
57     float imageResolutionFloats;
58 #endif
59
60 #if ENABLE(TOUCH_EVENTS)
61     Color tapHighlightColor;
62 #endif
63 };
64
65 COMPILE_ASSERT(sizeof(StyleRareInheritedData) <= sizeof(GreaterThanOrSameSizeAsStyleRareInheritedData), StyleRareInheritedData_should_bit_pack);
66
67 StyleRareInheritedData::StyleRareInheritedData()
68     : listStyleImage(RenderStyle::initialListStyleImage())
69     , textStrokeWidth(RenderStyle::initialTextStrokeWidth())
70     , indent(RenderStyle::initialTextIndent())
71     , m_effectiveZoom(RenderStyle::initialZoom())
72     , widows(RenderStyle::initialWidows())
73     , orphans(RenderStyle::initialOrphans())
74     , m_hasAutoWidows(true)
75     , m_hasAutoOrphans(true)
76     , textSecurity(RenderStyle::initialTextSecurity())
77     , userModify(READ_ONLY)
78     , wordBreak(RenderStyle::initialWordBreak())
79     , overflowWrap(RenderStyle::initialOverflowWrap())
80     , nbspMode(NBNORMAL)
81     , lineBreak(LineBreakAuto)
82     , resize(RenderStyle::initialResize())
83     , userSelect(RenderStyle::initialUserSelect())
84     , colorSpace(ColorSpaceDeviceRGB)
85     , speak(SpeakNormal)
86     , hyphens(HyphensManual)
87     , textEmphasisFill(TextEmphasisFillFilled)
88     , textEmphasisMark(TextEmphasisMarkNone)
89     , textEmphasisPosition(TextEmphasisPositionOver | TextEmphasisPositionRight)
90     , m_textOrientation(TextOrientationVerticalRight)
91 #if ENABLE(CSS3_TEXT)
92     , m_textIndentLine(RenderStyle::initialTextIndentLine())
93     , m_textIndentType(RenderStyle::initialTextIndentType())
94 #endif
95     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
96 #if ENABLE(CSS_IMAGE_ORIENTATION)
97     , m_imageOrientation(RenderStyle::initialImageOrientation())
98 #endif
99     , m_imageRendering(RenderStyle::initialImageRendering())
100     , m_lineSnap(RenderStyle::initialLineSnap())
101     , m_lineAlign(RenderStyle::initialLineAlign())
102 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
103     , useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
104 #endif
105 #if ENABLE(CSS_IMAGE_RESOLUTION)
106     , m_imageResolutionSource(RenderStyle::initialImageResolutionSource())
107     , m_imageResolutionSnap(RenderStyle::initialImageResolutionSnap())
108 #endif
109 #if ENABLE(CSS3_TEXT)
110     , m_textAlignLast(RenderStyle::initialTextAlignLast())
111     , m_textJustify(RenderStyle::initialTextJustify())
112 #endif // CSS3_TEXT
113     , m_textDecorationSkip(RenderStyle::initialTextDecorationSkip())
114     , m_textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
115     , m_rubyPosition(RenderStyle::initialRubyPosition())
116 #if PLATFORM(IOS)
117     , touchCalloutEnabled(RenderStyle::initialTouchCalloutEnabled())
118 #endif
119     , hyphenationLimitBefore(-1)
120     , hyphenationLimitAfter(-1)
121     , hyphenationLimitLines(-1)
122     , m_lineGrid(RenderStyle::initialLineGrid())
123     , m_tabSize(RenderStyle::initialTabSize())
124 #if PLATFORM(IOS)
125     , compositionFillColor(RenderStyle::initialCompositionFillColor())
126 #endif
127 #if ENABLE(IOS_TEXT_AUTOSIZING)
128     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
129 #endif
130 #if ENABLE(CSS_IMAGE_RESOLUTION)
131     , m_imageResolution(RenderStyle::initialImageResolution())
132 #endif
133 #if ENABLE(TOUCH_EVENTS)
134     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
135 #endif
136 {
137 }
138
139 inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
140     : RefCounted<StyleRareInheritedData>()
141     , listStyleImage(o.listStyleImage)
142     , textStrokeColor(o.textStrokeColor)
143     , textStrokeWidth(o.textStrokeWidth)
144     , textFillColor(o.textFillColor)
145     , textEmphasisColor(o.textEmphasisColor)
146     , visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor)
147     , visitedLinkTextFillColor(o.visitedLinkTextFillColor)
148     , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
149     , textShadow(o.textShadow ? adoptPtr(new ShadowData(*o.textShadow)) : nullptr)
150     , highlight(o.highlight)
151     , cursorData(o.cursorData)
152     , indent(o.indent)
153     , m_effectiveZoom(o.m_effectiveZoom)
154     , widows(o.widows)
155     , orphans(o.orphans)
156     , m_hasAutoWidows(o.m_hasAutoWidows)
157     , m_hasAutoOrphans(o.m_hasAutoOrphans)
158     , textSecurity(o.textSecurity)
159     , userModify(o.userModify)
160     , wordBreak(o.wordBreak)
161     , overflowWrap(o.overflowWrap)
162     , nbspMode(o.nbspMode)
163     , lineBreak(o.lineBreak)
164     , resize(o.resize)
165     , userSelect(o.userSelect)
166     , colorSpace(o.colorSpace)
167     , speak(o.speak)
168     , hyphens(o.hyphens)
169     , textEmphasisFill(o.textEmphasisFill)
170     , textEmphasisMark(o.textEmphasisMark)
171     , textEmphasisPosition(o.textEmphasisPosition)
172     , m_textOrientation(o.m_textOrientation)
173 #if ENABLE(CSS3_TEXT)
174     , m_textIndentLine(o.m_textIndentLine)
175     , m_textIndentType(o.m_textIndentType)
176 #endif
177     , m_lineBoxContain(o.m_lineBoxContain)
178 #if ENABLE(CSS_IMAGE_ORIENTATION)
179     , m_imageOrientation(o.m_imageOrientation)
180 #endif
181     , m_imageRendering(o.m_imageRendering)
182     , m_lineSnap(o.m_lineSnap)
183     , m_lineAlign(o.m_lineAlign)
184 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
185     , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
186 #endif
187 #if ENABLE(CSS_IMAGE_RESOLUTION)
188     , m_imageResolutionSource(o.m_imageResolutionSource)
189     , m_imageResolutionSnap(o.m_imageResolutionSnap)
190 #endif
191 #if ENABLE(CSS3_TEXT)
192     , m_textAlignLast(o.m_textAlignLast)
193     , m_textJustify(o.m_textJustify)
194 #endif // CSS3_TEXT
195     , m_textDecorationSkip(o.m_textDecorationSkip)
196     , m_textUnderlinePosition(o.m_textUnderlinePosition)
197     , m_rubyPosition(o.m_rubyPosition)
198 #if PLATFORM(IOS)
199     , touchCalloutEnabled(o.touchCalloutEnabled)
200 #endif
201     , hyphenationString(o.hyphenationString)
202     , hyphenationLimitBefore(o.hyphenationLimitBefore)
203     , hyphenationLimitAfter(o.hyphenationLimitAfter)
204     , hyphenationLimitLines(o.hyphenationLimitLines)
205     , locale(o.locale)
206     , textEmphasisCustomMark(o.textEmphasisCustomMark)
207     , m_lineGrid(o.m_lineGrid)
208     , m_tabSize(o.m_tabSize)
209 #if PLATFORM(IOS)
210     , compositionFillColor(o.compositionFillColor)
211 #endif
212 #if ENABLE(IOS_TEXT_AUTOSIZING)
213     , textSizeAdjust(o.textSizeAdjust)
214 #endif
215 #if ENABLE(CSS_IMAGE_RESOLUTION)
216     , m_imageResolution(o.m_imageResolution)
217 #endif
218 #if ENABLE(TOUCH_EVENTS)
219     , tapHighlightColor(o.tapHighlightColor)
220 #endif
221 {
222 }
223
224 PassRef<StyleRareInheritedData> StyleRareInheritedData::copy() const
225 {
226     return adoptRef(*new StyleRareInheritedData(*this));
227 }
228
229 StyleRareInheritedData::~StyleRareInheritedData()
230 {
231 }
232
233 static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
234 {
235     if (c1 == c2)
236         return true;
237     if ((!c1 && c2) || (c1 && !c2))
238         return false;
239     return (*c1 == *c2);
240 }
241
242 static bool quotesDataEquivalent(const QuotesData* q1, const QuotesData* q2)
243 {
244     if (q1 == q2)
245         return true;
246     if ((!q1 && q2) || (q1 && !q2))
247         return false;
248     return (*q1 == *q2);
249 }
250
251 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
252 {
253     return textStrokeColor == o.textStrokeColor
254         && textStrokeWidth == o.textStrokeWidth
255         && textFillColor == o.textFillColor
256         && textEmphasisColor == o.textEmphasisColor
257         && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor
258         && visitedLinkTextFillColor == o.visitedLinkTextFillColor
259         && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
260 #if ENABLE(TOUCH_EVENTS)
261         && tapHighlightColor == o.tapHighlightColor
262 #endif
263         && shadowDataEquivalent(o)
264         && highlight == o.highlight
265         && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
266         && indent == o.indent
267         && m_effectiveZoom == o.m_effectiveZoom
268         && widows == o.widows
269         && orphans == o.orphans
270         && m_hasAutoWidows == o.m_hasAutoWidows
271         && m_hasAutoOrphans == o.m_hasAutoOrphans
272         && textSecurity == o.textSecurity
273         && userModify == o.userModify
274         && wordBreak == o.wordBreak
275         && overflowWrap == o.overflowWrap
276         && nbspMode == o.nbspMode
277         && lineBreak == o.lineBreak
278 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
279         && useTouchOverflowScrolling == o.useTouchOverflowScrolling
280 #endif
281 #if ENABLE(IOS_TEXT_AUTOSIZING)
282         && textSizeAdjust == o.textSizeAdjust
283 #endif
284         && resize == o.resize
285         && userSelect == o.userSelect
286         && colorSpace == o.colorSpace
287         && speak == o.speak
288         && hyphens == o.hyphens
289         && hyphenationLimitBefore == o.hyphenationLimitBefore
290         && hyphenationLimitAfter == o.hyphenationLimitAfter
291         && hyphenationLimitLines == o.hyphenationLimitLines
292         && textEmphasisFill == o.textEmphasisFill
293         && textEmphasisMark == o.textEmphasisMark
294         && textEmphasisPosition == o.textEmphasisPosition
295         && m_textOrientation == o.m_textOrientation
296 #if ENABLE(CSS3_TEXT)
297         && m_textIndentLine == o.m_textIndentLine
298         && m_textIndentType == o.m_textIndentType
299 #endif
300         && m_lineBoxContain == o.m_lineBoxContain
301 #if PLATFORM(IOS)
302         && touchCalloutEnabled == o.touchCalloutEnabled
303         && compositionFillColor == o.compositionFillColor
304 #endif
305         && hyphenationString == o.hyphenationString
306         && locale == o.locale
307         && textEmphasisCustomMark == o.textEmphasisCustomMark
308         && quotesDataEquivalent(quotes.get(), o.quotes.get())
309         && m_tabSize == o.m_tabSize
310         && m_lineGrid == o.m_lineGrid
311 #if ENABLE(CSS_IMAGE_ORIENTATION)
312         && m_imageOrientation == o.m_imageOrientation
313 #endif
314         && m_imageRendering == o.m_imageRendering
315 #if ENABLE(CSS_IMAGE_RESOLUTION)
316         && m_imageResolutionSource == o.m_imageResolutionSource
317         && m_imageResolutionSnap == o.m_imageResolutionSnap
318         && m_imageResolution == o.m_imageResolution
319 #endif
320 #if ENABLE(CSS3_TEXT)
321         && m_textAlignLast == o.m_textAlignLast
322         && m_textJustify == o.m_textJustify
323 #endif // CSS3_TEXT
324         && m_textDecorationSkip == o.m_textDecorationSkip
325         && m_textUnderlinePosition == o.m_textUnderlinePosition
326         && m_rubyPosition == o.m_rubyPosition
327         && m_lineSnap == o.m_lineSnap
328         && m_lineAlign == o.m_lineAlign
329         && StyleImage::imagesEquivalent(listStyleImage.get(), o.listStyleImage.get());
330 }
331
332 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
333 {
334     if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
335         return false;
336     if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
337         return false;
338     return true;
339 }
340
341 } // namespace WebCore