Rename OVERFLOW_SCROLLING as ACCELERATED_OVERFLOW_SCROLLING
[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 "WebCoreMemoryInstrumentation.h"
31
32 namespace WebCore {
33
34 struct SameSizeAsStyleRareInheritedData : public RefCounted<SameSizeAsStyleRareInheritedData> {
35     Color firstColor;
36     float firstFloat;
37     Color colors[5];
38     void* ownPtrs[1];
39     AtomicString atomicStrings[5];
40     void* refPtrs[2];
41     Length lengths[1];
42     float secondFloat;
43     unsigned m_bitfields[2];
44     short pagedMediaShorts[2];
45     unsigned unsigneds[1];
46     short hyphenationShorts[3];
47
48 #if ENABLE(CSS_IMAGE_RESOLUTION)
49     float imageResolutionFloats;
50 #endif
51
52 #if ENABLE(TOUCH_EVENTS)
53     Color touchColors;
54 #endif
55
56 #if ENABLE(CSS_VARIABLES)
57     void* variableDataRefs[1];
58 #endif
59 };
60
61 COMPILE_ASSERT(sizeof(StyleRareInheritedData) == sizeof(SameSizeAsStyleRareInheritedData), StyleRareInheritedData_should_bit_pack);
62
63 StyleRareInheritedData::StyleRareInheritedData()
64     : textStrokeWidth(RenderStyle::initialTextStrokeWidth())
65     , indent(RenderStyle::initialTextIndent())
66     , m_effectiveZoom(RenderStyle::initialZoom())
67     , widows(RenderStyle::initialWidows())
68     , orphans(RenderStyle::initialOrphans())
69     , textSecurity(RenderStyle::initialTextSecurity())
70     , userModify(READ_ONLY)
71     , wordBreak(RenderStyle::initialWordBreak())
72     , overflowWrap(RenderStyle::initialOverflowWrap())
73     , nbspMode(NBNORMAL)
74     , khtmlLineBreak(LBNORMAL)
75     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
76     , resize(RenderStyle::initialResize())
77     , userSelect(RenderStyle::initialUserSelect())
78     , colorSpace(ColorSpaceDeviceRGB)
79     , speak(SpeakNormal)
80     , hyphens(HyphensManual)
81     , textEmphasisFill(TextEmphasisFillFilled)
82     , textEmphasisMark(TextEmphasisMarkNone)
83     , textEmphasisPosition(TextEmphasisPositionOver)
84     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
85 #if ENABLE(CSS_IMAGE_ORIENTATION)
86     , m_imageOrientation(RenderStyle::initialImageOrientation())
87 #endif
88     , m_imageRendering(RenderStyle::initialImageRendering())
89     , m_lineSnap(RenderStyle::initialLineSnap())
90     , m_lineAlign(RenderStyle::initialLineAlign())
91 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
92     , useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
93 #endif
94 #if ENABLE(CSS_IMAGE_RESOLUTION)
95     , m_imageResolutionSource(RenderStyle::initialImageResolutionSource())
96     , m_imageResolutionSnap(RenderStyle::initialImageResolutionSnap())
97 #endif
98     , hyphenationLimitBefore(-1)
99     , hyphenationLimitAfter(-1)
100     , hyphenationLimitLines(-1)
101     , m_lineGrid(RenderStyle::initialLineGrid())
102     , m_tabSize(RenderStyle::initialTabSize())
103 #if ENABLE(CSS_IMAGE_RESOLUTION)
104     , m_imageResolution(RenderStyle::initialImageResolution())
105 #endif
106 #if ENABLE(TOUCH_EVENTS)
107     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
108 #endif    
109 {
110 #if ENABLE(CSS_VARIABLES)
111     m_variables.init();
112 #endif
113 }
114
115 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
116     : RefCounted<StyleRareInheritedData>()
117     , textStrokeColor(o.textStrokeColor)
118     , textStrokeWidth(o.textStrokeWidth)
119     , textFillColor(o.textFillColor)
120     , textEmphasisColor(o.textEmphasisColor)
121     , visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor)
122     , visitedLinkTextFillColor(o.visitedLinkTextFillColor)
123     , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
124     , textShadow(o.textShadow ? adoptPtr(new ShadowData(*o.textShadow)) : nullptr)
125     , highlight(o.highlight)
126     , cursorData(o.cursorData)
127     , indent(o.indent)
128     , m_effectiveZoom(o.m_effectiveZoom)
129     , widows(o.widows)
130     , orphans(o.orphans)
131     , textSecurity(o.textSecurity)
132     , userModify(o.userModify)
133     , wordBreak(o.wordBreak)
134     , overflowWrap(o.overflowWrap)
135     , nbspMode(o.nbspMode)
136     , khtmlLineBreak(o.khtmlLineBreak)
137     , textSizeAdjust(o.textSizeAdjust)
138     , resize(o.resize)
139     , userSelect(o.userSelect)
140     , colorSpace(o.colorSpace)
141     , speak(o.speak)
142     , hyphens(o.hyphens)
143     , textEmphasisFill(o.textEmphasisFill)
144     , textEmphasisMark(o.textEmphasisMark)
145     , textEmphasisPosition(o.textEmphasisPosition)
146     , m_lineBoxContain(o.m_lineBoxContain)
147 #if ENABLE(CSS_IMAGE_ORIENTATION)
148     , m_imageOrientation(o.m_imageOrientation)
149 #endif
150     , m_imageRendering(o.m_imageRendering)
151     , m_lineSnap(o.m_lineSnap)
152     , m_lineAlign(o.m_lineAlign)
153 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
154     , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
155 #endif
156 #if ENABLE(CSS_IMAGE_RESOLUTION)
157     , m_imageResolutionSource(o.m_imageResolutionSource)
158     , m_imageResolutionSnap(o.m_imageResolutionSnap)
159 #endif
160     , hyphenationString(o.hyphenationString)
161     , hyphenationLimitBefore(o.hyphenationLimitBefore)
162     , hyphenationLimitAfter(o.hyphenationLimitAfter)
163     , hyphenationLimitLines(o.hyphenationLimitLines)
164     , locale(o.locale)
165     , textEmphasisCustomMark(o.textEmphasisCustomMark)
166     , m_lineGrid(o.m_lineGrid)
167     , m_tabSize(o.m_tabSize)
168 #if ENABLE(CSS_IMAGE_RESOLUTION)
169     , m_imageResolution(o.m_imageResolution)
170 #endif
171 #if ENABLE(TOUCH_EVENTS)
172     , tapHighlightColor(o.tapHighlightColor)
173 #endif
174 #if ENABLE(CSS_VARIABLES)
175     , m_variables(o.m_variables)
176 #endif
177 {
178 }
179
180 StyleRareInheritedData::~StyleRareInheritedData()
181 {
182 }
183
184 static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
185 {
186     if (c1 == c2)
187         return true;
188     if ((!c1 && c2) || (c1 && !c2))
189         return false;
190     return (*c1 == *c2);
191 }
192
193 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
194 {
195     return textStrokeColor == o.textStrokeColor
196         && textStrokeWidth == o.textStrokeWidth
197         && textFillColor == o.textFillColor
198         && textEmphasisColor == o.textEmphasisColor
199         && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor
200         && visitedLinkTextFillColor == o.visitedLinkTextFillColor
201         && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
202 #if ENABLE(TOUCH_EVENTS)
203         && tapHighlightColor == o.tapHighlightColor
204 #endif
205         && shadowDataEquivalent(o)
206         && highlight == o.highlight
207         && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
208         && indent == o.indent
209         && m_effectiveZoom == o.m_effectiveZoom
210         && widows == o.widows
211         && orphans == o.orphans
212         && textSecurity == o.textSecurity
213         && userModify == o.userModify
214         && wordBreak == o.wordBreak
215         && overflowWrap == o.overflowWrap
216         && nbspMode == o.nbspMode
217         && khtmlLineBreak == o.khtmlLineBreak
218 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
219         && useTouchOverflowScrolling == o.useTouchOverflowScrolling
220 #endif
221         && textSizeAdjust == o.textSizeAdjust
222         && resize == o.resize
223         && userSelect == o.userSelect
224         && colorSpace == o.colorSpace
225         && speak == o.speak
226         && hyphens == o.hyphens
227         && hyphenationLimitBefore == o.hyphenationLimitBefore
228         && hyphenationLimitAfter == o.hyphenationLimitAfter
229         && hyphenationLimitLines == o.hyphenationLimitLines
230         && textEmphasisFill == o.textEmphasisFill
231         && textEmphasisMark == o.textEmphasisMark
232         && textEmphasisPosition == o.textEmphasisPosition
233         && m_lineBoxContain == o.m_lineBoxContain
234         && hyphenationString == o.hyphenationString
235         && locale == o.locale
236         && textEmphasisCustomMark == o.textEmphasisCustomMark
237         && QuotesData::equals(quotes.get(), o.quotes.get())
238         && m_tabSize == o.m_tabSize
239         && m_lineGrid == o.m_lineGrid
240 #if ENABLE(CSS_IMAGE_ORIENTATION)
241         && m_imageOrientation == o.m_imageOrientation
242 #endif
243         && m_imageRendering == o.m_imageRendering
244 #if ENABLE(CSS_IMAGE_RESOLUTION)
245         && m_imageResolutionSource == o.m_imageResolutionSource
246         && m_imageResolutionSnap == o.m_imageResolutionSnap
247         && m_imageResolution == o.m_imageResolution
248 #endif
249         && m_lineSnap == o.m_lineSnap
250 #if ENABLE(CSS_VARIABLES)
251         && m_variables == o.m_variables
252 #endif
253         && m_lineAlign == o.m_lineAlign;
254 }
255
256 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
257 {
258     if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
259         return false;
260     if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
261         return false;
262     return true;
263 }
264
265 void StyleRareInheritedData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
266 {
267     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
268     info.addMember(textShadow);
269     info.addInstrumentedMember(highlight);
270     info.addMember(cursorData);
271     info.addInstrumentedMember(hyphenationString);
272     info.addInstrumentedMember(locale);
273     info.addInstrumentedMember(textEmphasisCustomMark);
274     info.addMember(quotes);
275     info.addInstrumentedMember(m_lineGrid);
276 #if ENABLE(CSS_VARIABLES)
277     info.addMember(m_variables);
278 #endif
279 }
280
281 } // namespace WebCore