Use "= default" to denote default constructor or destructor
[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 "DataRef.h"
27 #include "QuotesData.h"
28 #include "RenderStyle.h"
29 #include "RenderStyleConstants.h"
30 #include "ShadowData.h"
31 #include "StyleCustomPropertyData.h"
32 #include "StyleImage.h"
33 #include <wtf/PointerComparison.h>
34
35 namespace WebCore {
36
37 struct GreaterThanOrSameSizeAsStyleRareInheritedData : public RefCounted<GreaterThanOrSameSizeAsStyleRareInheritedData> {
38     void* styleImage;
39     Color firstColor;
40     float firstFloat;
41     Color colors[9];
42     void* ownPtrs[1];
43     AtomicString atomicStrings[5];
44     void* refPtrs[2];
45     Length lengths[2];
46     float secondFloat;
47     unsigned bitfields[4];
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(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     void* customPropertyDataRefs[1];
68 };
69
70 COMPILE_ASSERT(sizeof(StyleRareInheritedData) <= sizeof(GreaterThanOrSameSizeAsStyleRareInheritedData), StyleRareInheritedData_should_bit_pack);
71
72 StyleRareInheritedData::StyleRareInheritedData()
73     : listStyleImage(RenderStyle::initialListStyleImage())
74     , textStrokeWidth(RenderStyle::initialTextStrokeWidth())
75     , indent(RenderStyle::initialTextIndent())
76     , effectiveZoom(RenderStyle::initialZoom())
77     , customProperties(StyleCustomPropertyData::create())
78     , widows(RenderStyle::initialWidows())
79     , orphans(RenderStyle::initialOrphans())
80     , hasAutoWidows(true)
81     , hasAutoOrphans(true)
82     , textSecurity(RenderStyle::initialTextSecurity())
83     , userModify(READ_ONLY)
84     , wordBreak(RenderStyle::initialWordBreak())
85     , overflowWrap(RenderStyle::initialOverflowWrap())
86     , nbspMode(NBNORMAL)
87     , lineBreak(LineBreakAuto)
88     , userSelect(RenderStyle::initialUserSelect())
89     , speak(SpeakNormal)
90     , hyphens(HyphensManual)
91     , textEmphasisFill(TextEmphasisFillFilled)
92     , textEmphasisMark(TextEmphasisMarkNone)
93     , textEmphasisPosition(TextEmphasisPositionOver | TextEmphasisPositionRight)
94     , textOrientation(static_cast<unsigned>(TextOrientation::Mixed))
95 #if ENABLE(CSS3_TEXT)
96     , textIndentLine(RenderStyle::initialTextIndentLine())
97     , textIndentType(RenderStyle::initialTextIndentType())
98 #endif
99     , lineBoxContain(RenderStyle::initialLineBoxContain())
100 #if ENABLE(CSS_IMAGE_ORIENTATION)
101     , imageOrientation(RenderStyle::initialImageOrientation())
102 #endif
103     , imageRendering(RenderStyle::initialImageRendering())
104     , lineSnap(RenderStyle::initialLineSnap())
105     , lineAlign(RenderStyle::initialLineAlign())
106 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
107     , useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
108 #endif
109 #if ENABLE(CSS_IMAGE_RESOLUTION)
110     , imageResolutionSource(RenderStyle::initialImageResolutionSource())
111     , imageResolutionSnap(RenderStyle::initialImageResolutionSnap())
112 #endif
113 #if ENABLE(CSS3_TEXT)
114     , textAlignLast(RenderStyle::initialTextAlignLast())
115     , textJustify(RenderStyle::initialTextJustify())
116 #endif
117     , textDecorationSkip(RenderStyle::initialTextDecorationSkip())
118     , textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
119     , rubyPosition(RenderStyle::initialRubyPosition())
120     , textZoom(RenderStyle::initialTextZoom())
121 #if PLATFORM(IOS)
122     , touchCalloutEnabled(RenderStyle::initialTouchCalloutEnabled())
123 #endif
124 #if ENABLE(CSS_TRAILING_WORD)
125     , trailingWord(static_cast<unsigned>(RenderStyle::initialTrailingWord()))
126 #endif
127     , hangingPunctuation(RenderStyle::initialHangingPunctuation())
128     , paintOrder(static_cast<unsigned>(RenderStyle::initialPaintOrder()))
129     , capStyle(RenderStyle::initialCapStyle())
130     , joinStyle(RenderStyle::initialJoinStyle())
131     , hasSetStrokeWidth(false)
132     , hasSetStrokeColor(false)
133     , strokeWidth(RenderStyle::initialStrokeWidth())
134     , strokeColor(RenderStyle::initialStrokeColor())
135     , miterLimit(RenderStyle::initialStrokeMiterLimit())
136     , hyphenationLimitBefore(-1)
137     , hyphenationLimitAfter(-1)
138     , hyphenationLimitLines(-1)
139     , lineGrid(RenderStyle::initialLineGrid())
140     , tabSize(RenderStyle::initialTabSize())
141 #if ENABLE(TEXT_AUTOSIZING)
142     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
143 #endif
144 #if ENABLE(CSS_IMAGE_RESOLUTION)
145     , imageResolution(RenderStyle::initialImageResolution())
146 #endif
147 #if ENABLE(TOUCH_EVENTS)
148     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
149 #endif
150 {
151 }
152
153 inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
154     : RefCounted<StyleRareInheritedData>()
155     , listStyleImage(o.listStyleImage)
156     , textStrokeColor(o.textStrokeColor)
157     , textStrokeWidth(o.textStrokeWidth)
158     , textFillColor(o.textFillColor)
159     , textEmphasisColor(o.textEmphasisColor)
160     , visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor)
161     , visitedLinkTextFillColor(o.visitedLinkTextFillColor)
162     , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
163     , caretColor(o.caretColor)
164     , visitedLinkCaretColor(o.visitedLinkCaretColor)
165     , textShadow(o.textShadow ? std::make_unique<ShadowData>(*o.textShadow) : nullptr)
166     , cursorData(o.cursorData)
167     , indent(o.indent)
168     , effectiveZoom(o.effectiveZoom)
169     , customProperties(o.customProperties)
170     , widows(o.widows)
171     , orphans(o.orphans)
172     , hasAutoWidows(o.hasAutoWidows)
173     , hasAutoOrphans(o.hasAutoOrphans)
174     , textSecurity(o.textSecurity)
175     , userModify(o.userModify)
176     , wordBreak(o.wordBreak)
177     , overflowWrap(o.overflowWrap)
178     , nbspMode(o.nbspMode)
179     , lineBreak(o.lineBreak)
180     , userSelect(o.userSelect)
181     , speak(o.speak)
182     , hyphens(o.hyphens)
183     , textEmphasisFill(o.textEmphasisFill)
184     , textEmphasisMark(o.textEmphasisMark)
185     , textEmphasisPosition(o.textEmphasisPosition)
186     , textOrientation(o.textOrientation)
187 #if ENABLE(CSS3_TEXT)
188     , textIndentLine(o.textIndentLine)
189     , textIndentType(o.textIndentType)
190 #endif
191     , lineBoxContain(o.lineBoxContain)
192 #if ENABLE(CSS_IMAGE_ORIENTATION)
193     , imageOrientation(o.imageOrientation)
194 #endif
195     , imageRendering(o.imageRendering)
196     , lineSnap(o.lineSnap)
197     , lineAlign(o.lineAlign)
198 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
199     , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
200 #endif
201 #if ENABLE(CSS_IMAGE_RESOLUTION)
202     , imageResolutionSource(o.imageResolutionSource)
203     , imageResolutionSnap(o.imageResolutionSnap)
204 #endif
205 #if ENABLE(CSS3_TEXT)
206     , textAlignLast(o.textAlignLast)
207     , textJustify(o.textJustify)
208 #endif
209     , textDecorationSkip(o.textDecorationSkip)
210     , textUnderlinePosition(o.textUnderlinePosition)
211     , rubyPosition(o.rubyPosition)
212     , textZoom(o.textZoom)
213 #if PLATFORM(IOS)
214     , touchCalloutEnabled(o.touchCalloutEnabled)
215 #endif
216 #if ENABLE(CSS_TRAILING_WORD)
217     , trailingWord(o.trailingWord)
218 #endif
219     , hangingPunctuation(o.hangingPunctuation)
220     , paintOrder(o.paintOrder)
221     , capStyle(o.capStyle)
222     , joinStyle(o.joinStyle)
223     , hasSetStrokeWidth(o.hasSetStrokeWidth)
224     , hasSetStrokeColor(o.hasSetStrokeColor)
225     , strokeWidth(o.strokeWidth)
226     , strokeColor(o.strokeColor)
227     , visitedLinkStrokeColor(o.visitedLinkStrokeColor)
228     , miterLimit(o.miterLimit)
229     , hyphenationString(o.hyphenationString)
230     , hyphenationLimitBefore(o.hyphenationLimitBefore)
231     , hyphenationLimitAfter(o.hyphenationLimitAfter)
232     , hyphenationLimitLines(o.hyphenationLimitLines)
233     , textEmphasisCustomMark(o.textEmphasisCustomMark)
234     , lineGrid(o.lineGrid)
235     , tabSize(o.tabSize)
236 #if ENABLE(TEXT_AUTOSIZING)
237     , textSizeAdjust(o.textSizeAdjust)
238 #endif
239 #if ENABLE(CSS_IMAGE_RESOLUTION)
240     , imageResolution(o.imageResolution)
241 #endif
242 #if ENABLE(TOUCH_EVENTS)
243     , tapHighlightColor(o.tapHighlightColor)
244 #endif
245 {
246 }
247
248 Ref<StyleRareInheritedData> StyleRareInheritedData::copy() const
249 {
250     return adoptRef(*new StyleRareInheritedData(*this));
251 }
252
253 StyleRareInheritedData::~StyleRareInheritedData() = default;
254
255 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
256 {
257     return textStrokeColor == o.textStrokeColor
258         && textStrokeWidth == o.textStrokeWidth
259         && textFillColor == o.textFillColor
260         && textEmphasisColor == o.textEmphasisColor
261         && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor
262         && visitedLinkTextFillColor == o.visitedLinkTextFillColor
263         && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
264         && caretColor == o.caretColor
265         && visitedLinkCaretColor == o.visitedLinkCaretColor
266 #if ENABLE(TOUCH_EVENTS)
267         && tapHighlightColor == o.tapHighlightColor
268 #endif
269         && arePointingToEqualData(textShadow, o.textShadow)
270         && arePointingToEqualData(cursorData, o.cursorData)
271         && indent == o.indent
272         && effectiveZoom == o.effectiveZoom
273         && widows == o.widows
274         && orphans == o.orphans
275         && hasAutoWidows == o.hasAutoWidows
276         && hasAutoOrphans == o.hasAutoOrphans
277         && textSecurity == o.textSecurity
278         && userModify == o.userModify
279         && wordBreak == o.wordBreak
280         && overflowWrap == o.overflowWrap
281         && nbspMode == o.nbspMode
282         && lineBreak == o.lineBreak
283 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
284         && useTouchOverflowScrolling == o.useTouchOverflowScrolling
285 #endif
286 #if ENABLE(TEXT_AUTOSIZING)
287         && textSizeAdjust == o.textSizeAdjust
288 #endif
289         && userSelect == o.userSelect
290         && speak == o.speak
291         && hyphens == o.hyphens
292         && hyphenationLimitBefore == o.hyphenationLimitBefore
293         && hyphenationLimitAfter == o.hyphenationLimitAfter
294         && hyphenationLimitLines == o.hyphenationLimitLines
295         && textEmphasisFill == o.textEmphasisFill
296         && textEmphasisMark == o.textEmphasisMark
297         && textEmphasisPosition == o.textEmphasisPosition
298         && textOrientation == o.textOrientation
299 #if ENABLE(CSS3_TEXT)
300         && textIndentLine == o.textIndentLine
301         && textIndentType == o.textIndentType
302 #endif
303         && lineBoxContain == o.lineBoxContain
304 #if PLATFORM(IOS)
305         && touchCalloutEnabled == o.touchCalloutEnabled
306 #endif
307         && hyphenationString == o.hyphenationString
308         && textEmphasisCustomMark == o.textEmphasisCustomMark
309         && arePointingToEqualData(quotes, o.quotes)
310         && tabSize == o.tabSize
311         && lineGrid == o.lineGrid
312 #if ENABLE(CSS_IMAGE_ORIENTATION)
313         && imageOrientation == o.imageOrientation
314 #endif
315         && imageRendering == o.imageRendering
316 #if ENABLE(CSS_IMAGE_RESOLUTION)
317         && imageResolutionSource == o.imageResolutionSource
318         && imageResolutionSnap == o.imageResolutionSnap
319         && imageResolution == o.imageResolution
320 #endif
321 #if ENABLE(CSS3_TEXT)
322         && textAlignLast == o.textAlignLast
323         && textJustify == o.textJustify
324 #endif // CSS3_TEXT
325         && textDecorationSkip == o.textDecorationSkip
326         && textUnderlinePosition == o.textUnderlinePosition
327         && rubyPosition == o.rubyPosition
328         && textZoom == o.textZoom
329         && lineSnap == o.lineSnap
330         && lineAlign == o.lineAlign
331 #if ENABLE(CSS_TRAILING_WORD)
332         && trailingWord == o.trailingWord
333 #endif
334         && hangingPunctuation == o.hangingPunctuation
335         && paintOrder == o.paintOrder
336         && capStyle == o.capStyle
337         && joinStyle == o.joinStyle
338         && hasSetStrokeWidth == o.hasSetStrokeWidth
339         && hasSetStrokeColor == o.hasSetStrokeColor
340         && strokeWidth == o.strokeWidth
341         && strokeColor == o.strokeColor
342         && visitedLinkStrokeColor == o.visitedLinkStrokeColor
343         && miterLimit == o.miterLimit
344         && customProperties == o.customProperties
345         && arePointingToEqualData(listStyleImage, o.listStyleImage);
346 }
347
348 } // namespace WebCore