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