[CSS Exclusions] Update wrap-margin/padding to shape-margin/padding
[WebKit-https.git] / Source / WebCore / rendering / style / StyleRareNonInheritedData.cpp
1 /*
2  * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3  * Copyright (C) 2004, 2005, 2006, 2007, 2008 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 "StyleRareNonInheritedData.h"
24
25 #include "ContentData.h"
26 #include "RenderCounter.h"
27 #include "RenderStyle.h"
28 #include "ShadowData.h"
29 #include "StyleFilterData.h"
30 #include "StyleTransformData.h"
31 #include "StyleImage.h"
32 #include "StyleResolver.h"
33 #include "WebCoreMemoryInstrumentation.h"
34 #include <wtf/MemoryInstrumentationHashMap.h>
35 #include <wtf/MemoryInstrumentationVector.h>
36
37 namespace WebCore {
38
39 StyleRareNonInheritedData::StyleRareNonInheritedData()
40     : opacity(RenderStyle::initialOpacity())
41     , m_aspectRatioDenominator(RenderStyle::initialAspectRatioDenominator())
42     , m_aspectRatioNumerator(RenderStyle::initialAspectRatioNumerator())
43     , m_perspective(RenderStyle::initialPerspective())
44     , m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX())
45     , m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY())
46     , lineClamp(RenderStyle::initialLineClamp())
47 #if ENABLE(DRAGGABLE_REGION)
48     , m_draggableRegionMode(DraggableRegionNone)
49 #endif
50     , m_mask(FillLayer(MaskFillLayer))
51     , m_pageSize()
52     , m_shapeInside(RenderStyle::initialShapeInside())
53     , m_shapeOutside(RenderStyle::initialShapeOutside())
54     , m_shapeMargin(RenderStyle::initialShapeMargin())
55     , m_shapePadding(RenderStyle::initialShapePadding())
56     , m_clipPath(RenderStyle::initialClipPath())
57     , m_visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor())
58     , m_order(RenderStyle::initialOrder())
59     , m_flowThread(RenderStyle::initialFlowThread())
60     , m_regionThread(RenderStyle::initialRegionThread())
61     , m_regionOverflow(RenderStyle::initialRegionOverflow())
62     , m_regionBreakAfter(RenderStyle::initialPageBreak())
63     , m_regionBreakBefore(RenderStyle::initialPageBreak())
64     , m_regionBreakInside(RenderStyle::initialPageBreak())
65     , m_pageSizeType(PAGE_SIZE_AUTO)
66     , m_transformStyle3D(RenderStyle::initialTransformStyle3D())
67     , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility())
68     , m_alignContent(RenderStyle::initialAlignContent())
69     , m_alignItems(RenderStyle::initialAlignItems())
70     , m_alignSelf(RenderStyle::initialAlignSelf())
71     , m_justifyContent(RenderStyle::initialJustifyContent())
72     , userDrag(RenderStyle::initialUserDrag())
73     , textOverflow(RenderStyle::initialTextOverflow())
74     , marginBeforeCollapse(MCOLLAPSE)
75     , marginAfterCollapse(MCOLLAPSE)
76     , m_appearance(RenderStyle::initialAppearance())
77     , m_borderFit(RenderStyle::initialBorderFit())
78     , m_textCombine(RenderStyle::initialTextCombine())
79 #if ENABLE(CSS3_TEXT)
80     , m_textDecorationStyle(RenderStyle::initialTextDecorationStyle())
81 #endif // CSS3_TEXT
82     , m_wrapFlow(RenderStyle::initialWrapFlow())
83     , m_wrapThrough(RenderStyle::initialWrapThrough())
84 #if USE(ACCELERATED_COMPOSITING)
85     , m_runningAcceleratedAnimation(false)
86 #endif
87     , m_hasAspectRatio(false)
88 #if ENABLE(CSS_COMPOSITING)
89     , m_effectiveBlendMode(RenderStyle::initialBlendMode())
90 #endif
91 {
92     m_maskBoxImage.setMaskDefaults();
93 }
94
95 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
96     : RefCounted<StyleRareNonInheritedData>()
97     , opacity(o.opacity)
98     , m_aspectRatioDenominator(o.m_aspectRatioDenominator)
99     , m_aspectRatioNumerator(o.m_aspectRatioNumerator)
100     , m_perspective(o.m_perspective)
101     , m_perspectiveOriginX(o.m_perspectiveOriginX)
102     , m_perspectiveOriginY(o.m_perspectiveOriginY)
103     , lineClamp(o.lineClamp)
104 #if ENABLE(DRAGGABLE_REGION)
105     , m_draggableRegionMode(o.m_draggableRegionMode)
106 #endif
107     , m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox)
108     , m_flexibleBox(o.m_flexibleBox)
109     , m_marquee(o.m_marquee)
110     , m_multiCol(o.m_multiCol)
111     , m_transform(o.m_transform)
112 #if ENABLE(CSS_FILTERS)
113     , m_filter(o.m_filter)
114 #endif
115     , m_grid(o.m_grid)
116     , m_gridItem(o.m_gridItem)
117     , m_content(o.m_content ? o.m_content->clone() : nullptr)
118     , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr)
119     , m_boxShadow(o.m_boxShadow ? adoptPtr(new ShadowData(*o.m_boxShadow)) : nullptr)
120     , m_boxReflect(o.m_boxReflect)
121     , m_animations(o.m_animations ? adoptPtr(new AnimationList(*o.m_animations)) : nullptr)
122     , m_transitions(o.m_transitions ? adoptPtr(new AnimationList(*o.m_transitions)) : nullptr)
123     , m_mask(o.m_mask)
124     , m_maskBoxImage(o.m_maskBoxImage)
125     , m_pageSize(o.m_pageSize)
126     , m_shapeInside(o.m_shapeInside)
127     , m_shapeOutside(o.m_shapeOutside)
128     , m_shapeMargin(o.m_shapeMargin)
129     , m_shapePadding(o.m_shapePadding)
130     , m_clipPath(o.m_clipPath)
131     , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor)
132     , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor)
133     , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor)
134     , m_visitedLinkBorderRightColor(o.m_visitedLinkBorderRightColor)
135     , m_visitedLinkBorderTopColor(o.m_visitedLinkBorderTopColor)
136     , m_visitedLinkBorderBottomColor(o.m_visitedLinkBorderBottomColor)
137     , m_order(o.m_order)
138     , m_flowThread(o.m_flowThread)
139     , m_regionThread(o.m_regionThread)
140     , m_regionOverflow(o.m_regionOverflow)
141     , m_regionBreakAfter(o.m_regionBreakAfter)
142     , m_regionBreakBefore(o.m_regionBreakBefore)
143     , m_regionBreakInside(o.m_regionBreakInside)
144     , m_pageSizeType(o.m_pageSizeType)
145     , m_transformStyle3D(o.m_transformStyle3D)
146     , m_backfaceVisibility(o.m_backfaceVisibility)
147     , m_alignContent(o.m_alignContent)
148     , m_alignItems(o.m_alignItems)
149     , m_alignSelf(o.m_alignSelf)
150     , m_justifyContent(o.m_justifyContent)
151     , userDrag(o.userDrag)
152     , textOverflow(o.textOverflow)
153     , marginBeforeCollapse(o.marginBeforeCollapse)
154     , marginAfterCollapse(o.marginAfterCollapse)
155     , m_appearance(o.m_appearance)
156     , m_borderFit(o.m_borderFit)
157     , m_textCombine(o.m_textCombine)
158 #if ENABLE(CSS3_TEXT)
159     , m_textDecorationStyle(o.m_textDecorationStyle)
160 #endif // CSS3_TEXT
161     , m_wrapFlow(o.m_wrapFlow)
162     , m_wrapThrough(o.m_wrapThrough)
163 #if USE(ACCELERATED_COMPOSITING)
164     , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
165 #endif
166     , m_hasAspectRatio(o.m_hasAspectRatio)
167 #if ENABLE(CSS_COMPOSITING)
168     , m_effectiveBlendMode(o.m_effectiveBlendMode)
169 #endif
170 {
171 }
172
173 StyleRareNonInheritedData::~StyleRareNonInheritedData()
174 {
175 }
176
177 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
178 {
179     return opacity == o.opacity
180         && m_aspectRatioDenominator == o.m_aspectRatioDenominator
181         && m_aspectRatioNumerator == o.m_aspectRatioNumerator
182         && m_perspective == o.m_perspective
183         && m_perspectiveOriginX == o.m_perspectiveOriginX
184         && m_perspectiveOriginY == o.m_perspectiveOriginY
185         && lineClamp == o.lineClamp
186 #if ENABLE(DASHBOARD_SUPPORT)
187         && m_dashboardRegions == o.m_dashboardRegions
188 #endif
189 #if ENABLE(DRAGGABLE_REGION)
190         && m_draggableRegionMode == o.m_draggableRegionMode
191 #endif
192         && m_deprecatedFlexibleBox == o.m_deprecatedFlexibleBox
193         && m_flexibleBox == o.m_flexibleBox
194         && m_marquee == o.m_marquee
195         && m_multiCol == o.m_multiCol
196         && m_transform == o.m_transform
197 #if ENABLE(CSS_FILTERS)
198         && m_filter == o.m_filter
199 #endif
200         && m_grid == o.m_grid
201         && m_gridItem == o.m_gridItem
202         && contentDataEquivalent(o)
203         && counterDataEquivalent(o)
204         && shadowDataEquivalent(o)
205         && reflectionDataEquivalent(o)
206         && animationDataEquivalent(o)
207         && transitionDataEquivalent(o)
208         && m_mask == o.m_mask
209         && m_maskBoxImage == o.m_maskBoxImage
210         && m_pageSize == o.m_pageSize
211         && m_shapeInside == o.m_shapeInside
212         && m_shapeOutside == o.m_shapeOutside
213         && m_shapeMargin == o.m_shapeMargin
214         && m_shapePadding == o.m_shapePadding
215         && m_clipPath == o.m_clipPath
216         && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
217         && m_visitedLinkOutlineColor == o.m_visitedLinkOutlineColor
218         && m_visitedLinkBorderLeftColor == o.m_visitedLinkBorderLeftColor
219         && m_visitedLinkBorderRightColor == o.m_visitedLinkBorderRightColor
220         && m_visitedLinkBorderTopColor == o.m_visitedLinkBorderTopColor
221         && m_visitedLinkBorderBottomColor == o.m_visitedLinkBorderBottomColor
222         && m_order == o.m_order
223         && m_flowThread == o.m_flowThread
224         && m_regionThread == o.m_regionThread
225         && m_regionOverflow == o.m_regionOverflow
226         && m_regionBreakAfter == o.m_regionBreakAfter
227         && m_regionBreakBefore == o.m_regionBreakBefore
228         && m_regionBreakInside == o.m_regionBreakInside
229         && m_pageSizeType == o.m_pageSizeType
230         && m_transformStyle3D == o.m_transformStyle3D
231         && m_backfaceVisibility == o.m_backfaceVisibility
232         && m_alignContent == o.m_alignContent
233         && m_alignItems == o.m_alignItems
234         && m_alignSelf == o.m_alignSelf
235         && m_justifyContent == o.m_justifyContent
236         && userDrag == o.userDrag
237         && textOverflow == o.textOverflow
238         && marginBeforeCollapse == o.marginBeforeCollapse
239         && marginAfterCollapse == o.marginAfterCollapse
240         && m_appearance == o.m_appearance
241         && m_borderFit == o.m_borderFit
242         && m_textCombine == o.m_textCombine
243 #if ENABLE(CSS3_TEXT)
244         && m_textDecorationStyle == o.m_textDecorationStyle
245 #endif // CSS3_TEXT
246         && m_wrapFlow == o.m_wrapFlow
247         && m_wrapThrough == o.m_wrapThrough
248 #if USE(ACCELERATED_COMPOSITING)
249         && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
250 #endif
251 #if ENABLE(CSS_COMPOSITING)
252         && m_effectiveBlendMode == o.m_effectiveBlendMode
253 #endif
254         && m_hasAspectRatio == o.m_hasAspectRatio;
255 }
256
257 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const
258 {
259     ContentData* a = m_content.get();
260     ContentData* b = o.m_content.get();
261
262     while (a && b && *a == *b) {
263         a = a->next();
264         b = b->next();
265     }
266
267     return !a && !b;
268 }
269
270 bool StyleRareNonInheritedData::counterDataEquivalent(const StyleRareNonInheritedData& o) const
271 {
272     if (m_counterDirectives.get() == o.m_counterDirectives.get())
273         return true;
274         
275     if (m_counterDirectives && o.m_counterDirectives && *m_counterDirectives == *o.m_counterDirectives)
276         return true;
277
278     return false;
279 }
280
281 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
282 {
283     if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow))
284         return false;
285     if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow))
286         return false;
287     return true;
288 }
289
290 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
291 {
292     if (m_boxReflect != o.m_boxReflect) {
293         if (!m_boxReflect || !o.m_boxReflect)
294             return false;
295         return *m_boxReflect == *o.m_boxReflect;
296     }
297     return true;
298 }
299
300 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
301 {
302     if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations))
303         return false;
304     if (m_animations && o.m_animations && (*m_animations != *o.m_animations))
305         return false;
306     return true;
307 }
308
309 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
310 {
311     if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions))
312         return false;
313     if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions))
314         return false;
315     return true;
316 }
317
318 void StyleRareNonInheritedData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
319 {
320     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
321 #if ENABLE(DASHBOARD_SUPPORT)
322     info.addMember(m_dashboardRegions);
323 #endif
324     info.addMember(m_deprecatedFlexibleBox);
325     info.addMember(m_flexibleBox);
326     info.addMember(m_marquee);
327     info.addMember(m_multiCol);
328     info.addMember(m_transform);
329 #if ENABLE(CSS_FILTERS)
330     info.addMember(m_filter);
331 #endif
332     info.addMember(m_grid);
333     info.addMember(m_gridItem);
334     info.addMember(m_content);
335     info.addMember(m_counterDirectives);
336     info.addMember(m_boxShadow);
337     info.addMember(m_boxReflect);
338     info.addMember(m_animations);
339     info.addMember(m_transitions);
340     info.addMember(m_shapeInside);
341     info.addMember(m_shapeOutside);
342     info.addMember(m_clipPath);
343     info.addMember(m_flowThread);
344     info.addMember(m_regionThread);
345 }
346
347 } // namespace WebCore