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 "StyleColorScheme.h"
32#include "StyleCustomPropertyData.h"
33#include "StyleFilterData.h"
34#include "StyleImage.h"
35#include <wtf/PointerComparison.h>
36
37namespace WebCore {
38
39struct GreaterThanOrSameSizeAsStyleRareInheritedData : public RefCounted<GreaterThanOrSameSizeAsStyleRareInheritedData> {
40 void* styleImage;
41 Color firstColor;
42 float firstFloat;
43 Color colors[9];
44 void* ownPtrs[1];
45 AtomicString atomicStrings[5];
46 void* refPtrs[3];
47 Length lengths[2];
48 float secondFloat;
49 TextUnderlineOffset offset;
50 TextDecorationThickness thickness;
51 unsigned bitfields[4];
52 short pagedMediaShorts[2];
53 unsigned unsigneds[1];
54 short hyphenationShorts[3];
55
56#if PLATFORM(IOS_FAMILY)
57 Color compositionColor; // FIXME: this has gone.
58#endif
59#if ENABLE(TEXT_AUTOSIZING)
60 TextSizeAdjustment textSizeAdjust;
61#endif
62
63#if ENABLE(CSS_IMAGE_RESOLUTION)
64 float imageResolutionFloats;
65#endif
66
67#if ENABLE(TOUCH_EVENTS)
68 Color tapHighlightColor;
69#endif
70
71#if ENABLE(DARK_MODE_CSS)
72 StyleColorScheme colorScheme;
73#endif
74
75 void* customPropertyDataRefs[1];
76};
77
78COMPILE_ASSERT(sizeof(StyleRareInheritedData) <= sizeof(GreaterThanOrSameSizeAsStyleRareInheritedData), StyleRareInheritedData_should_bit_pack);
79
80StyleRareInheritedData::StyleRareInheritedData()
81 : listStyleImage(RenderStyle::initialListStyleImage())
82 , textStrokeWidth(RenderStyle::initialTextStrokeWidth())
83 , indent(RenderStyle::initialTextIndent())
84 , effectiveZoom(RenderStyle::initialZoom())
85 , textUnderlineOffset(RenderStyle::initialTextUnderlineOffset())
86 , textDecorationThickness(RenderStyle::initialTextDecorationThickness())
87 , customProperties(StyleCustomPropertyData::create())
88 , widows(RenderStyle::initialWidows())
89 , orphans(RenderStyle::initialOrphans())
90 , hasAutoWidows(true)
91 , hasAutoOrphans(true)
92 , textSecurity(static_cast<unsigned>(RenderStyle::initialTextSecurity()))
93 , userModify(static_cast<unsigned>(UserModify::ReadOnly))
94 , wordBreak(static_cast<unsigned>(RenderStyle::initialWordBreak()))
95 , overflowWrap(static_cast<unsigned>(RenderStyle::initialOverflowWrap()))
96 , nbspMode(static_cast<unsigned>(NBSPMode::Normal))
97 , lineBreak(static_cast<unsigned>(LineBreak::Auto))
98 , userSelect(static_cast<unsigned>(RenderStyle::initialUserSelect()))
99 , speakAs(RenderStyle::initialSpeakAs().toRaw())
100 , hyphens(static_cast<unsigned>(Hyphens::Manual))
101 , textEmphasisFill(static_cast<unsigned>(TextEmphasisFill::Filled))
102 , textEmphasisMark(static_cast<unsigned>(TextEmphasisMark::None))
103 , textEmphasisPosition(static_cast<unsigned>(RenderStyle::initialTextEmphasisPosition().toRaw()))
104 , textOrientation(static_cast<unsigned>(TextOrientation::Mixed))
105#if ENABLE(CSS3_TEXT)
106 , textIndentLine(RenderStyle::initialTextIndentLine())
107 , textIndentType(RenderStyle::initialTextIndentType())
108#endif
109 , lineBoxContain(RenderStyle::initialLineBoxContain())
110#if ENABLE(CSS_IMAGE_ORIENTATION)
111 , imageOrientation(RenderStyle::initialImageOrientation())
112#endif
113 , imageRendering(static_cast<unsigned>(RenderStyle::initialImageRendering()))
114 , lineSnap(static_cast<unsigned>(RenderStyle::initialLineSnap()))
115 , lineAlign(static_cast<unsigned>(RenderStyle::initialLineAlign()))
116#if ENABLE(OVERFLOW_SCROLLING_TOUCH)
117 , useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
118#endif
119#if ENABLE(CSS_IMAGE_RESOLUTION)
120 , imageResolutionSource(RenderStyle::initialImageResolutionSource())
121 , imageResolutionSnap(RenderStyle::initialImageResolutionSnap())
122#endif
123#if ENABLE(CSS3_TEXT)
124 , textAlignLast(RenderStyle::initialTextAlignLast())
125 , textJustify(RenderStyle::initialTextJustify())
126#endif
127 , textDecorationSkip(RenderStyle::initialTextDecorationSkip().toRaw())
128 , textUnderlinePosition(static_cast<unsigned>(RenderStyle::initialTextUnderlinePosition()))
129 , rubyPosition(static_cast<unsigned>(RenderStyle::initialRubyPosition()))
130 , textZoom(static_cast<unsigned>(RenderStyle::initialTextZoom()))
131#if PLATFORM(IOS_FAMILY)
132 , touchCalloutEnabled(RenderStyle::initialTouchCalloutEnabled())
133#endif
134 , hangingPunctuation(RenderStyle::initialHangingPunctuation().toRaw())
135 , paintOrder(static_cast<unsigned>(RenderStyle::initialPaintOrder()))
136 , capStyle(RenderStyle::initialCapStyle())
137 , joinStyle(RenderStyle::initialJoinStyle())
138 , hasSetStrokeWidth(false)
139 , hasSetStrokeColor(false)
140#if ENABLE(POINTER_EVENTS)
141 , effectiveTouchActions(static_cast<unsigned>(RenderStyle::initialTouchActions()))
142#endif
143 , strokeWidth(RenderStyle::initialStrokeWidth())
144 , strokeColor(RenderStyle::initialStrokeColor())
145 , miterLimit(RenderStyle::initialStrokeMiterLimit())
146 , hyphenationLimitBefore(-1)
147 , hyphenationLimitAfter(-1)
148 , hyphenationLimitLines(-1)
149 , appleColorFilter(StyleFilterData::create())
150 , lineGrid(RenderStyle::initialLineGrid())
151 , tabSize(RenderStyle::initialTabSize())
152#if ENABLE(TEXT_AUTOSIZING)
153 , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
154#endif
155#if ENABLE(CSS_IMAGE_RESOLUTION)
156 , imageResolution(RenderStyle::initialImageResolution())
157#endif
158#if ENABLE(TOUCH_EVENTS)
159 , tapHighlightColor(RenderStyle::initialTapHighlightColor())
160#endif
161#if ENABLE(DARK_MODE_CSS)
162 , colorScheme(RenderStyle::initialColorScheme())
163#endif
164{
165}
166
167inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
168 : RefCounted<StyleRareInheritedData>()
169 , listStyleImage(o.listStyleImage)
170 , textStrokeColor(o.textStrokeColor)
171 , textStrokeWidth(o.textStrokeWidth)
172 , textFillColor(o.textFillColor)
173 , textEmphasisColor(o.textEmphasisColor)
174 , visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor)
175 , visitedLinkTextFillColor(o.visitedLinkTextFillColor)
176 , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
177 , caretColor(o.caretColor)
178 , visitedLinkCaretColor(o.visitedLinkCaretColor)
179 , textShadow(o.textShadow ? std::make_unique<ShadowData>(*o.textShadow) : nullptr)
180 , cursorData(o.cursorData)
181 , indent(o.indent)
182 , effectiveZoom(o.effectiveZoom)
183 , textUnderlineOffset(o.textUnderlineOffset)
184 , textDecorationThickness(o.textDecorationThickness)
185 , customProperties(o.customProperties)
186 , widows(o.widows)
187 , orphans(o.orphans)
188 , hasAutoWidows(o.hasAutoWidows)
189 , hasAutoOrphans(o.hasAutoOrphans)
190 , textSecurity(o.textSecurity)
191 , userModify(o.userModify)
192 , wordBreak(o.wordBreak)
193 , overflowWrap(o.overflowWrap)
194 , nbspMode(o.nbspMode)
195 , lineBreak(o.lineBreak)
196 , userSelect(o.userSelect)
197 , speakAs(o.speakAs)
198 , hyphens(o.hyphens)
199 , textEmphasisFill(o.textEmphasisFill)
200 , textEmphasisMark(o.textEmphasisMark)
201 , textEmphasisPosition(o.textEmphasisPosition)
202 , textOrientation(o.textOrientation)
203#if ENABLE(CSS3_TEXT)
204 , textIndentLine(o.textIndentLine)
205 , textIndentType(o.textIndentType)
206#endif
207 , lineBoxContain(o.lineBoxContain)
208#if ENABLE(CSS_IMAGE_ORIENTATION)
209 , imageOrientation(o.imageOrientation)
210#endif
211 , imageRendering(o.imageRendering)
212 , lineSnap(o.lineSnap)
213 , lineAlign(o.lineAlign)
214#if ENABLE(OVERFLOW_SCROLLING_TOUCH)
215 , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
216#endif
217#if ENABLE(CSS_IMAGE_RESOLUTION)
218 , imageResolutionSource(o.imageResolutionSource)
219 , imageResolutionSnap(o.imageResolutionSnap)
220#endif
221#if ENABLE(CSS3_TEXT)
222 , textAlignLast(o.textAlignLast)
223 , textJustify(o.textJustify)
224#endif
225 , textDecorationSkip(o.textDecorationSkip)
226 , textUnderlinePosition(o.textUnderlinePosition)
227 , rubyPosition(o.rubyPosition)
228 , textZoom(o.textZoom)
229#if PLATFORM(IOS_FAMILY)
230 , touchCalloutEnabled(o.touchCalloutEnabled)
231#endif
232 , hangingPunctuation(o.hangingPunctuation)
233 , paintOrder(o.paintOrder)
234 , capStyle(o.capStyle)
235 , joinStyle(o.joinStyle)
236 , hasSetStrokeWidth(o.hasSetStrokeWidth)
237 , hasSetStrokeColor(o.hasSetStrokeColor)
238#if ENABLE(POINTER_EVENTS)
239 , effectiveTouchActions(o.effectiveTouchActions)
240#endif
241 , strokeWidth(o.strokeWidth)
242 , strokeColor(o.strokeColor)
243 , visitedLinkStrokeColor(o.visitedLinkStrokeColor)
244 , miterLimit(o.miterLimit)
245 , hyphenationString(o.hyphenationString)
246 , hyphenationLimitBefore(o.hyphenationLimitBefore)
247 , hyphenationLimitAfter(o.hyphenationLimitAfter)
248 , hyphenationLimitLines(o.hyphenationLimitLines)
249 , textEmphasisCustomMark(o.textEmphasisCustomMark)
250 , appleColorFilter(o.appleColorFilter)
251 , lineGrid(o.lineGrid)
252 , tabSize(o.tabSize)
253#if ENABLE(TEXT_AUTOSIZING)
254 , textSizeAdjust(o.textSizeAdjust)
255#endif
256#if ENABLE(CSS_IMAGE_RESOLUTION)
257 , imageResolution(o.imageResolution)
258#endif
259#if ENABLE(TOUCH_EVENTS)
260 , tapHighlightColor(o.tapHighlightColor)
261#endif
262#if ENABLE(DARK_MODE_CSS)
263 , colorScheme(o.colorScheme)
264#endif
265{
266}
267
268Ref<StyleRareInheritedData> StyleRareInheritedData::copy() const
269{
270 return adoptRef(*new StyleRareInheritedData(*this));
271}
272
273StyleRareInheritedData::~StyleRareInheritedData() = default;
274
275bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
276{
277 return textStrokeColor == o.textStrokeColor
278 && textStrokeWidth == o.textStrokeWidth
279 && textFillColor == o.textFillColor
280 && textEmphasisColor == o.textEmphasisColor
281 && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor
282 && visitedLinkTextFillColor == o.visitedLinkTextFillColor
283 && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
284 && caretColor == o.caretColor
285 && visitedLinkCaretColor == o.visitedLinkCaretColor
286#if ENABLE(TOUCH_EVENTS)
287 && tapHighlightColor == o.tapHighlightColor
288#endif
289 && arePointingToEqualData(textShadow, o.textShadow)
290 && arePointingToEqualData(cursorData, o.cursorData)
291 && indent == o.indent
292 && effectiveZoom == o.effectiveZoom
293 && textUnderlineOffset == o.textUnderlineOffset
294 && textDecorationThickness == o.textDecorationThickness
295 && widows == o.widows
296 && orphans == o.orphans
297 && hasAutoWidows == o.hasAutoWidows
298 && hasAutoOrphans == o.hasAutoOrphans
299 && textSecurity == o.textSecurity
300 && userModify == o.userModify
301 && wordBreak == o.wordBreak
302 && overflowWrap == o.overflowWrap
303 && nbspMode == o.nbspMode
304 && lineBreak == o.lineBreak
305#if ENABLE(OVERFLOW_SCROLLING_TOUCH)
306 && useTouchOverflowScrolling == o.useTouchOverflowScrolling
307#endif
308#if ENABLE(TEXT_AUTOSIZING)
309 && textSizeAdjust == o.textSizeAdjust
310#endif
311#if ENABLE(DARK_MODE_CSS)
312 && colorScheme == o.colorScheme
313#endif
314 && userSelect == o.userSelect
315 && speakAs == o.speakAs
316 && hyphens == o.hyphens
317 && hyphenationLimitBefore == o.hyphenationLimitBefore
318 && hyphenationLimitAfter == o.hyphenationLimitAfter
319 && hyphenationLimitLines == o.hyphenationLimitLines
320 && textEmphasisFill == o.textEmphasisFill
321 && textEmphasisMark == o.textEmphasisMark
322 && textEmphasisPosition == o.textEmphasisPosition
323 && textOrientation == o.textOrientation
324#if ENABLE(CSS3_TEXT)
325 && textIndentLine == o.textIndentLine
326 && textIndentType == o.textIndentType
327#endif
328 && lineBoxContain == o.lineBoxContain
329#if PLATFORM(IOS_FAMILY)
330 && touchCalloutEnabled == o.touchCalloutEnabled
331#endif
332 && hyphenationString == o.hyphenationString
333 && textEmphasisCustomMark == o.textEmphasisCustomMark
334 && arePointingToEqualData(quotes, o.quotes)
335 && appleColorFilter == o.appleColorFilter
336 && tabSize == o.tabSize
337 && lineGrid == o.lineGrid
338#if ENABLE(CSS_IMAGE_ORIENTATION)
339 && imageOrientation == o.imageOrientation
340#endif
341 && imageRendering == o.imageRendering
342#if ENABLE(CSS_IMAGE_RESOLUTION)
343 && imageResolutionSource == o.imageResolutionSource
344 && imageResolutionSnap == o.imageResolutionSnap
345 && imageResolution == o.imageResolution
346#endif
347#if ENABLE(CSS3_TEXT)
348 && textAlignLast == o.textAlignLast
349 && textJustify == o.textJustify
350#endif // CSS3_TEXT
351 && textDecorationSkip == o.textDecorationSkip
352 && textUnderlinePosition == o.textUnderlinePosition
353 && rubyPosition == o.rubyPosition
354 && textZoom == o.textZoom
355 && lineSnap == o.lineSnap
356 && lineAlign == o.lineAlign
357 && hangingPunctuation == o.hangingPunctuation
358 && paintOrder == o.paintOrder
359 && capStyle == o.capStyle
360 && joinStyle == o.joinStyle
361 && hasSetStrokeWidth == o.hasSetStrokeWidth
362 && hasSetStrokeColor == o.hasSetStrokeColor
363#if ENABLE(POINTER_EVENTS)
364 && effectiveTouchActions == o.effectiveTouchActions
365#endif
366 && strokeWidth == o.strokeWidth
367 && strokeColor == o.strokeColor
368 && visitedLinkStrokeColor == o.visitedLinkStrokeColor
369 && miterLimit == o.miterLimit
370 && customProperties == o.customProperties
371 && arePointingToEqualData(listStyleImage, o.listStyleImage);
372}
373
374bool StyleRareInheritedData::hasColorFilters() const
375{
376 return !appleColorFilter->operations.isEmpty();
377}
378
379} // namespace WebCore
380