Remove -webkit-color-correction CSS property
[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     , speak(SpeakNormal)
85     , hyphens(HyphensManual)
86     , textEmphasisFill(TextEmphasisFillFilled)
87     , textEmphasisMark(TextEmphasisMarkNone)
88     , textEmphasisPosition(TextEmphasisPositionOver | TextEmphasisPositionRight)
89     , m_textOrientation(TextOrientationVerticalRight)
90 #if ENABLE(CSS3_TEXT)
91     , m_textIndentLine(RenderStyle::initialTextIndentLine())
92     , m_textIndentType(RenderStyle::initialTextIndentType())
93 #endif
94     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
95 #if ENABLE(CSS_IMAGE_ORIENTATION)
96     , m_imageOrientation(RenderStyle::initialImageOrientation())
97 #endif
98     , m_imageRendering(RenderStyle::initialImageRendering())
99     , m_lineSnap(RenderStyle::initialLineSnap())
100     , m_lineAlign(RenderStyle::initialLineAlign())
101 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
102     , useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
103 #endif
104 #if ENABLE(CSS_IMAGE_RESOLUTION)
105     , m_imageResolutionSource(RenderStyle::initialImageResolutionSource())
106     , m_imageResolutionSnap(RenderStyle::initialImageResolutionSnap())
107 #endif
108 #if ENABLE(CSS3_TEXT)
109     , m_textAlignLast(RenderStyle::initialTextAlignLast())
110     , m_textJustify(RenderStyle::initialTextJustify())
111 #endif // CSS3_TEXT
112     , m_textDecorationSkip(RenderStyle::initialTextDecorationSkip())
113     , m_textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
114     , m_rubyPosition(RenderStyle::initialRubyPosition())
115     , m_textZoom(RenderStyle::initialTextZoom())
116 #if PLATFORM(IOS)
117     , touchCalloutEnabled(RenderStyle::initialTouchCalloutEnabled())
118 #endif
119 #if ENABLE(CSS_TRAILING_WORD)
120     , trailingWord(static_cast<unsigned>(RenderStyle::initialTrailingWord()))
121 #endif
122     , hyphenationLimitBefore(-1)
123     , hyphenationLimitAfter(-1)
124     , hyphenationLimitLines(-1)
125     , m_lineGrid(RenderStyle::initialLineGrid())
126     , m_tabSize(RenderStyle::initialTabSize())
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 ? std::make_unique<ShadowData>(*o.textShadow) : nullptr)
150     , cursorData(o.cursorData)
151     , indent(o.indent)
152     , m_effectiveZoom(o.m_effectiveZoom)
153     , widows(o.widows)
154     , orphans(o.orphans)
155     , m_hasAutoWidows(o.m_hasAutoWidows)
156     , m_hasAutoOrphans(o.m_hasAutoOrphans)
157     , textSecurity(o.textSecurity)
158     , userModify(o.userModify)
159     , wordBreak(o.wordBreak)
160     , overflowWrap(o.overflowWrap)
161     , nbspMode(o.nbspMode)
162     , lineBreak(o.lineBreak)
163     , resize(o.resize)
164     , userSelect(o.userSelect)
165     , speak(o.speak)
166     , hyphens(o.hyphens)
167     , textEmphasisFill(o.textEmphasisFill)
168     , textEmphasisMark(o.textEmphasisMark)
169     , textEmphasisPosition(o.textEmphasisPosition)
170     , m_textOrientation(o.m_textOrientation)
171 #if ENABLE(CSS3_TEXT)
172     , m_textIndentLine(o.m_textIndentLine)
173     , m_textIndentType(o.m_textIndentType)
174 #endif
175     , m_lineBoxContain(o.m_lineBoxContain)
176 #if ENABLE(CSS_IMAGE_ORIENTATION)
177     , m_imageOrientation(o.m_imageOrientation)
178 #endif
179     , m_imageRendering(o.m_imageRendering)
180     , m_lineSnap(o.m_lineSnap)
181     , m_lineAlign(o.m_lineAlign)
182 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
183     , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
184 #endif
185 #if ENABLE(CSS_IMAGE_RESOLUTION)
186     , m_imageResolutionSource(o.m_imageResolutionSource)
187     , m_imageResolutionSnap(o.m_imageResolutionSnap)
188 #endif
189 #if ENABLE(CSS3_TEXT)
190     , m_textAlignLast(o.m_textAlignLast)
191     , m_textJustify(o.m_textJustify)
192 #endif // CSS3_TEXT
193     , m_textDecorationSkip(o.m_textDecorationSkip)
194     , m_textUnderlinePosition(o.m_textUnderlinePosition)
195     , m_rubyPosition(o.m_rubyPosition)
196     , m_textZoom(o.m_textZoom)
197 #if PLATFORM(IOS)
198     , touchCalloutEnabled(o.touchCalloutEnabled)
199 #endif
200 #if ENABLE(CSS_TRAILING_WORD)
201     , trailingWord(o.trailingWord)
202 #endif
203     , hyphenationString(o.hyphenationString)
204     , hyphenationLimitBefore(o.hyphenationLimitBefore)
205     , hyphenationLimitAfter(o.hyphenationLimitAfter)
206     , hyphenationLimitLines(o.hyphenationLimitLines)
207     , textEmphasisCustomMark(o.textEmphasisCustomMark)
208     , m_lineGrid(o.m_lineGrid)
209     , m_tabSize(o.m_tabSize)
210 #if ENABLE(IOS_TEXT_AUTOSIZING)
211     , textSizeAdjust(o.textSizeAdjust)
212 #endif
213 #if ENABLE(CSS_IMAGE_RESOLUTION)
214     , m_imageResolution(o.m_imageResolution)
215 #endif
216 #if ENABLE(TOUCH_EVENTS)
217     , tapHighlightColor(o.tapHighlightColor)
218 #endif
219 {
220 }
221
222 Ref<StyleRareInheritedData> StyleRareInheritedData::copy() const
223 {
224     return adoptRef(*new StyleRareInheritedData(*this));
225 }
226
227 StyleRareInheritedData::~StyleRareInheritedData()
228 {
229 }
230
231 static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
232 {
233     if (c1 == c2)
234         return true;
235     if ((!c1 && c2) || (c1 && !c2))
236         return false;
237     return (*c1 == *c2);
238 }
239
240 static bool quotesDataEquivalent(const QuotesData* q1, const QuotesData* q2)
241 {
242     if (q1 == q2)
243         return true;
244     if ((!q1 && q2) || (q1 && !q2))
245         return false;
246     return (*q1 == *q2);
247 }
248
249 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
250 {
251     return textStrokeColor == o.textStrokeColor
252         && textStrokeWidth == o.textStrokeWidth
253         && textFillColor == o.textFillColor
254         && textEmphasisColor == o.textEmphasisColor
255         && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor
256         && visitedLinkTextFillColor == o.visitedLinkTextFillColor
257         && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
258 #if ENABLE(TOUCH_EVENTS)
259         && tapHighlightColor == o.tapHighlightColor
260 #endif
261         && shadowDataEquivalent(o)
262         && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
263         && indent == o.indent
264         && m_effectiveZoom == o.m_effectiveZoom
265         && widows == o.widows
266         && orphans == o.orphans
267         && m_hasAutoWidows == o.m_hasAutoWidows
268         && m_hasAutoOrphans == o.m_hasAutoOrphans
269         && textSecurity == o.textSecurity
270         && userModify == o.userModify
271         && wordBreak == o.wordBreak
272         && overflowWrap == o.overflowWrap
273         && nbspMode == o.nbspMode
274         && lineBreak == o.lineBreak
275 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
276         && useTouchOverflowScrolling == o.useTouchOverflowScrolling
277 #endif
278 #if ENABLE(IOS_TEXT_AUTOSIZING)
279         && textSizeAdjust == o.textSizeAdjust
280 #endif
281         && resize == o.resize
282         && userSelect == o.userSelect
283         && speak == o.speak
284         && hyphens == o.hyphens
285         && hyphenationLimitBefore == o.hyphenationLimitBefore
286         && hyphenationLimitAfter == o.hyphenationLimitAfter
287         && hyphenationLimitLines == o.hyphenationLimitLines
288         && textEmphasisFill == o.textEmphasisFill
289         && textEmphasisMark == o.textEmphasisMark
290         && textEmphasisPosition == o.textEmphasisPosition
291         && m_textOrientation == o.m_textOrientation
292 #if ENABLE(CSS3_TEXT)
293         && m_textIndentLine == o.m_textIndentLine
294         && m_textIndentType == o.m_textIndentType
295 #endif
296         && m_lineBoxContain == o.m_lineBoxContain
297 #if PLATFORM(IOS)
298         && touchCalloutEnabled == o.touchCalloutEnabled
299 #endif
300         && hyphenationString == o.hyphenationString
301         && textEmphasisCustomMark == o.textEmphasisCustomMark
302         && quotesDataEquivalent(quotes.get(), o.quotes.get())
303         && m_tabSize == o.m_tabSize
304         && m_lineGrid == o.m_lineGrid
305 #if ENABLE(CSS_IMAGE_ORIENTATION)
306         && m_imageOrientation == o.m_imageOrientation
307 #endif
308         && m_imageRendering == o.m_imageRendering
309 #if ENABLE(CSS_IMAGE_RESOLUTION)
310         && m_imageResolutionSource == o.m_imageResolutionSource
311         && m_imageResolutionSnap == o.m_imageResolutionSnap
312         && m_imageResolution == o.m_imageResolution
313 #endif
314 #if ENABLE(CSS3_TEXT)
315         && m_textAlignLast == o.m_textAlignLast
316         && m_textJustify == o.m_textJustify
317 #endif // CSS3_TEXT
318         && m_textDecorationSkip == o.m_textDecorationSkip
319         && m_textUnderlinePosition == o.m_textUnderlinePosition
320         && m_rubyPosition == o.m_rubyPosition
321         && m_textZoom == o.m_textZoom
322         && m_lineSnap == o.m_lineSnap
323         && m_lineAlign == o.m_lineAlign
324 #if ENABLE(CSS_TRAILING_WORD)
325         && trailingWord == o.trailingWord
326 #endif
327         && StyleImage::imagesEquivalent(listStyleImage.get(), o.listStyleImage.get());
328 }
329
330 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
331 {
332     if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
333         return false;
334     if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
335         return false;
336     return true;
337 }
338
339 } // namespace WebCore