Apply SVG styles paint-order, stroke-linejoin, and stroke-linecap on DOM text.
[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[5];
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(RenderStyle::initialPaintOrder())
129     , capStyle(RenderStyle::initialCapStyle())
130     , joinStyle(RenderStyle::initialJoinStyle())
131     , strokeWidth(RenderStyle::initialOneLength())
132     , hyphenationLimitBefore(-1)
133     , hyphenationLimitAfter(-1)
134     , hyphenationLimitLines(-1)
135     , lineGrid(RenderStyle::initialLineGrid())
136     , tabSize(RenderStyle::initialTabSize())
137 #if ENABLE(TEXT_AUTOSIZING)
138     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
139 #endif
140 #if ENABLE(CSS_IMAGE_RESOLUTION)
141     , imageResolution(RenderStyle::initialImageResolution())
142 #endif
143 #if ENABLE(TOUCH_EVENTS)
144     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
145 #endif
146 {
147 }
148
149 inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
150     : RefCounted<StyleRareInheritedData>()
151     , listStyleImage(o.listStyleImage)
152     , textStrokeColor(o.textStrokeColor)
153     , textStrokeWidth(o.textStrokeWidth)
154     , textFillColor(o.textFillColor)
155     , textEmphasisColor(o.textEmphasisColor)
156     , visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor)
157     , visitedLinkTextFillColor(o.visitedLinkTextFillColor)
158     , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
159     , textShadow(o.textShadow ? std::make_unique<ShadowData>(*o.textShadow) : nullptr)
160     , cursorData(o.cursorData)
161     , indent(o.indent)
162     , effectiveZoom(o.effectiveZoom)
163     , customProperties(o.customProperties)
164     , widows(o.widows)
165     , orphans(o.orphans)
166     , hasAutoWidows(o.hasAutoWidows)
167     , hasAutoOrphans(o.hasAutoOrphans)
168     , textSecurity(o.textSecurity)
169     , userModify(o.userModify)
170     , wordBreak(o.wordBreak)
171     , overflowWrap(o.overflowWrap)
172     , nbspMode(o.nbspMode)
173     , lineBreak(o.lineBreak)
174     , userSelect(o.userSelect)
175     , speak(o.speak)
176     , hyphens(o.hyphens)
177     , textEmphasisFill(o.textEmphasisFill)
178     , textEmphasisMark(o.textEmphasisMark)
179     , textEmphasisPosition(o.textEmphasisPosition)
180     , textOrientation(o.textOrientation)
181 #if ENABLE(CSS3_TEXT)
182     , textIndentLine(o.textIndentLine)
183     , textIndentType(o.textIndentType)
184 #endif
185     , lineBoxContain(o.lineBoxContain)
186 #if ENABLE(CSS_IMAGE_ORIENTATION)
187     , imageOrientation(o.imageOrientation)
188 #endif
189     , imageRendering(o.imageRendering)
190     , lineSnap(o.lineSnap)
191     , lineAlign(o.lineAlign)
192 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
193     , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
194 #endif
195 #if ENABLE(CSS_IMAGE_RESOLUTION)
196     , imageResolutionSource(o.imageResolutionSource)
197     , imageResolutionSnap(o.imageResolutionSnap)
198 #endif
199 #if ENABLE(CSS3_TEXT)
200     , textAlignLast(o.textAlignLast)
201     , textJustify(o.textJustify)
202 #endif
203     , textDecorationSkip(o.textDecorationSkip)
204     , textUnderlinePosition(o.textUnderlinePosition)
205     , rubyPosition(o.rubyPosition)
206     , textZoom(o.textZoom)
207 #if PLATFORM(IOS)
208     , touchCalloutEnabled(o.touchCalloutEnabled)
209 #endif
210 #if ENABLE(CSS_TRAILING_WORD)
211     , trailingWord(o.trailingWord)
212 #endif
213     , hangingPunctuation(o.hangingPunctuation)
214     , paintOrder(o.paintOrder)
215     , capStyle(o.capStyle)
216     , joinStyle(o.joinStyle)
217     , strokeWidth(o.strokeWidth)
218     , hyphenationString(o.hyphenationString)
219     , hyphenationLimitBefore(o.hyphenationLimitBefore)
220     , hyphenationLimitAfter(o.hyphenationLimitAfter)
221     , hyphenationLimitLines(o.hyphenationLimitLines)
222     , textEmphasisCustomMark(o.textEmphasisCustomMark)
223     , lineGrid(o.lineGrid)
224     , tabSize(o.tabSize)
225 #if ENABLE(TEXT_AUTOSIZING)
226     , textSizeAdjust(o.textSizeAdjust)
227 #endif
228 #if ENABLE(CSS_IMAGE_RESOLUTION)
229     , imageResolution(o.imageResolution)
230 #endif
231 #if ENABLE(TOUCH_EVENTS)
232     , tapHighlightColor(o.tapHighlightColor)
233 #endif
234 {
235 }
236
237 Ref<StyleRareInheritedData> StyleRareInheritedData::copy() const
238 {
239     return adoptRef(*new StyleRareInheritedData(*this));
240 }
241
242 StyleRareInheritedData::~StyleRareInheritedData()
243 {
244 }
245
246 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
247 {
248     return textStrokeColor == o.textStrokeColor
249         && textStrokeWidth == o.textStrokeWidth
250         && textFillColor == o.textFillColor
251         && textEmphasisColor == o.textEmphasisColor
252         && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor
253         && visitedLinkTextFillColor == o.visitedLinkTextFillColor
254         && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
255 #if ENABLE(TOUCH_EVENTS)
256         && tapHighlightColor == o.tapHighlightColor
257 #endif
258         && arePointingToEqualData(textShadow, o.textShadow)
259         && arePointingToEqualData(cursorData, o.cursorData)
260         && indent == o.indent
261         && effectiveZoom == o.effectiveZoom
262         && widows == o.widows
263         && orphans == o.orphans
264         && hasAutoWidows == o.hasAutoWidows
265         && hasAutoOrphans == o.hasAutoOrphans
266         && textSecurity == o.textSecurity
267         && userModify == o.userModify
268         && wordBreak == o.wordBreak
269         && overflowWrap == o.overflowWrap
270         && nbspMode == o.nbspMode
271         && lineBreak == o.lineBreak
272 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
273         && useTouchOverflowScrolling == o.useTouchOverflowScrolling
274 #endif
275 #if ENABLE(TEXT_AUTOSIZING)
276         && textSizeAdjust == o.textSizeAdjust
277 #endif
278         && userSelect == o.userSelect
279         && speak == o.speak
280         && hyphens == o.hyphens
281         && hyphenationLimitBefore == o.hyphenationLimitBefore
282         && hyphenationLimitAfter == o.hyphenationLimitAfter
283         && hyphenationLimitLines == o.hyphenationLimitLines
284         && textEmphasisFill == o.textEmphasisFill
285         && textEmphasisMark == o.textEmphasisMark
286         && textEmphasisPosition == o.textEmphasisPosition
287         && textOrientation == o.textOrientation
288 #if ENABLE(CSS3_TEXT)
289         && textIndentLine == o.textIndentLine
290         && textIndentType == o.textIndentType
291 #endif
292         && lineBoxContain == o.lineBoxContain
293 #if PLATFORM(IOS)
294         && touchCalloutEnabled == o.touchCalloutEnabled
295 #endif
296         && hyphenationString == o.hyphenationString
297         && textEmphasisCustomMark == o.textEmphasisCustomMark
298         && arePointingToEqualData(quotes, o.quotes)
299         && tabSize == o.tabSize
300         && lineGrid == o.lineGrid
301 #if ENABLE(CSS_IMAGE_ORIENTATION)
302         && imageOrientation == o.imageOrientation
303 #endif
304         && imageRendering == o.imageRendering
305 #if ENABLE(CSS_IMAGE_RESOLUTION)
306         && imageResolutionSource == o.imageResolutionSource
307         && imageResolutionSnap == o.imageResolutionSnap
308         && imageResolution == o.imageResolution
309 #endif
310 #if ENABLE(CSS3_TEXT)
311         && textAlignLast == o.textAlignLast
312         && textJustify == o.textJustify
313 #endif // CSS3_TEXT
314         && textDecorationSkip == o.textDecorationSkip
315         && textUnderlinePosition == o.textUnderlinePosition
316         && rubyPosition == o.rubyPosition
317         && textZoom == o.textZoom
318         && lineSnap == o.lineSnap
319         && lineAlign == o.lineAlign
320 #if ENABLE(CSS_TRAILING_WORD)
321         && trailingWord == o.trailingWord
322 #endif
323         && hangingPunctuation == o.hangingPunctuation
324         && paintOrder == o.paintOrder
325         && capStyle == o.capStyle
326         && joinStyle == o.joinStyle
327         && strokeWidth == o.strokeWidth
328         && customProperties == o.customProperties
329         && arePointingToEqualData(listStyleImage, o.listStyleImage);
330 }
331
332 } // namespace WebCore