09d5aa4547075dd37d652e570a882e9968a74891
[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 "StyleScrollSnapPoints.h"
34 #include <wtf/PointerComparison.h>
35 #include <wtf/RefPtr.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     , m_initialLetter(RenderStyle::initialInitialLetter())
48     , m_deprecatedFlexibleBox(StyleDeprecatedFlexibleBoxData::create())
49     , m_flexibleBox(StyleFlexibleBoxData::create())
50     , m_marquee(StyleMarqueeData::create())
51     , m_multiCol(StyleMultiColData::create())
52     , m_transform(StyleTransformData::create())
53     , m_filter(StyleFilterData::create())
54 #if ENABLE(FILTERS_LEVEL_2)
55     , m_backdropFilter(StyleFilterData::create())
56 #endif
57 #if ENABLE(CSS_GRID_LAYOUT)
58     , m_grid(StyleGridData::create())
59     , m_gridItem(StyleGridItemData::create())
60 #endif
61 #if ENABLE(CSS_SCROLL_SNAP)
62     , m_scrollSnapPoints(StyleScrollSnapPoints::create())
63 #endif
64     , m_willChange(RenderStyle::initialWillChange())
65     , m_mask(FillLayer(MaskFillLayer))
66     , m_objectPosition(RenderStyle::initialObjectPosition())
67 #if ENABLE(CSS_SHAPES)
68     , m_shapeOutside(RenderStyle::initialShapeOutside())
69     , m_shapeMargin(RenderStyle::initialShapeMargin())
70     , m_shapeImageThreshold(RenderStyle::initialShapeImageThreshold())
71 #endif
72     , m_clipPath(RenderStyle::initialClipPath())
73     , m_visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor())
74     , m_order(RenderStyle::initialOrder())
75     , m_flowThread(RenderStyle::initialFlowThread())
76     , m_regionThread(RenderStyle::initialRegionThread())
77     , m_alignContent(RenderStyle::initialContentAlignment())
78     , m_alignItems(RenderStyle::initialDefaultAlignment())
79     , m_alignSelf(RenderStyle::initialSelfAlignment())
80     , m_justifyContent(RenderStyle::initialContentAlignment())
81     , m_justifyItems(RenderStyle::initialSelfAlignment())
82     , m_justifySelf(RenderStyle::initialSelfAlignment())
83 #if ENABLE(TOUCH_EVENTS)
84     , m_touchAction(static_cast<unsigned>(RenderStyle::initialTouchAction()))
85 #endif
86 #if ENABLE(CSS_SCROLL_SNAP)
87     , m_scrollSnapType(static_cast<unsigned>(RenderStyle::initialScrollSnapType()))
88 #endif
89     , m_regionFragment(RenderStyle::initialRegionFragment())
90     , m_pageSizeType(PAGE_SIZE_AUTO)
91     , m_transformStyle3D(RenderStyle::initialTransformStyle3D())
92     , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility())
93     , userDrag(RenderStyle::initialUserDrag())
94     , textOverflow(RenderStyle::initialTextOverflow())
95     , marginBeforeCollapse(MCOLLAPSE)
96     , marginAfterCollapse(MCOLLAPSE)
97     , m_appearance(RenderStyle::initialAppearance())
98     , m_borderFit(RenderStyle::initialBorderFit())
99     , m_textCombine(RenderStyle::initialTextCombine())
100     , m_textDecorationStyle(RenderStyle::initialTextDecorationStyle())
101     , m_runningAcceleratedAnimation(false)
102     , m_aspectRatioType(RenderStyle::initialAspectRatioType())
103 #if ENABLE(CSS_COMPOSITING)
104     , m_effectiveBlendMode(RenderStyle::initialBlendMode())
105     , m_isolation(RenderStyle::initialIsolation())
106 #endif
107     , m_objectFit(RenderStyle::initialObjectFit())
108     , m_breakBefore(RenderStyle::initialBreakBetween())
109     , m_breakAfter(RenderStyle::initialBreakBetween())
110     , m_breakInside(RenderStyle::initialBreakInside())
111     , m_resize(RenderStyle::initialResize())
112     , m_hasAttrContent(false)
113     , m_isPlaceholderStyle(false)
114 {
115     m_maskBoxImage.setMaskDefaults();
116 }
117
118 inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
119     : RefCounted<StyleRareNonInheritedData>()
120     , opacity(o.opacity)
121     , m_aspectRatioDenominator(o.m_aspectRatioDenominator)
122     , m_aspectRatioNumerator(o.m_aspectRatioNumerator)
123     , m_perspective(o.m_perspective)
124     , m_perspectiveOriginX(o.m_perspectiveOriginX)
125     , m_perspectiveOriginY(o.m_perspectiveOriginY)
126     , lineClamp(o.lineClamp)
127     , m_initialLetter(o.m_initialLetter)
128     , m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox)
129     , m_flexibleBox(o.m_flexibleBox)
130     , m_marquee(o.m_marquee)
131     , m_multiCol(o.m_multiCol)
132     , m_transform(o.m_transform)
133     , m_filter(o.m_filter)
134 #if ENABLE(FILTERS_LEVEL_2)
135     , m_backdropFilter(o.m_backdropFilter)
136 #endif
137 #if ENABLE(CSS_GRID_LAYOUT)
138     , m_grid(o.m_grid)
139     , m_gridItem(o.m_gridItem)
140 #endif
141 #if ENABLE(CSS_SCROLL_SNAP)
142     , m_scrollSnapPoints(o.m_scrollSnapPoints)
143 #endif
144     , m_content(o.m_content ? o.m_content->clone() : nullptr)
145     , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr)
146     , m_altText(o.m_altText)
147     , m_boxShadow(o.m_boxShadow ? std::make_unique<ShadowData>(*o.m_boxShadow) : nullptr)
148     , m_willChange(o.m_willChange)
149     , m_boxReflect(o.m_boxReflect)
150     , m_animations(o.m_animations ? std::make_unique<AnimationList>(*o.m_animations) : nullptr)
151     , m_transitions(o.m_transitions ? std::make_unique<AnimationList>(*o.m_transitions) : nullptr)
152     , m_mask(o.m_mask)
153     , m_maskBoxImage(o.m_maskBoxImage)
154     , m_pageSize(o.m_pageSize)
155     , m_objectPosition(o.m_objectPosition)
156 #if ENABLE(CSS_SHAPES)
157     , m_shapeOutside(o.m_shapeOutside)
158     , m_shapeMargin(o.m_shapeMargin)
159     , m_shapeImageThreshold(o.m_shapeImageThreshold)
160 #endif
161     , m_clipPath(o.m_clipPath)
162     , m_textDecorationColor(o.m_textDecorationColor)
163     , m_visitedLinkTextDecorationColor(o.m_visitedLinkTextDecorationColor)
164     , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor)
165     , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor)
166     , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor)
167     , m_visitedLinkBorderRightColor(o.m_visitedLinkBorderRightColor)
168     , m_visitedLinkBorderTopColor(o.m_visitedLinkBorderTopColor)
169     , m_visitedLinkBorderBottomColor(o.m_visitedLinkBorderBottomColor)
170     , m_order(o.m_order)
171     , m_flowThread(o.m_flowThread)
172     , m_regionThread(o.m_regionThread)
173     , m_alignContent(o.m_alignContent)
174     , m_alignItems(o.m_alignItems)
175     , m_alignSelf(o.m_alignSelf)
176     , m_justifyContent(o.m_justifyContent)
177     , m_justifyItems(o.m_justifyItems)
178     , m_justifySelf(o.m_justifySelf)
179 #if ENABLE(TOUCH_EVENTS)
180     , m_touchAction(o.m_touchAction)
181 #endif
182 #if ENABLE(CSS_SCROLL_SNAP)
183     , m_scrollSnapType(o.m_scrollSnapType)
184 #endif
185     , m_regionFragment(o.m_regionFragment)
186     , m_pageSizeType(o.m_pageSizeType)
187     , m_transformStyle3D(o.m_transformStyle3D)
188     , m_backfaceVisibility(o.m_backfaceVisibility)
189     , userDrag(o.userDrag)
190     , textOverflow(o.textOverflow)
191     , marginBeforeCollapse(o.marginBeforeCollapse)
192     , marginAfterCollapse(o.marginAfterCollapse)
193     , m_appearance(o.m_appearance)
194     , m_borderFit(o.m_borderFit)
195     , m_textCombine(o.m_textCombine)
196     , m_textDecorationStyle(o.m_textDecorationStyle)
197     , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
198     , m_aspectRatioType(o.m_aspectRatioType)
199 #if ENABLE(CSS_COMPOSITING)
200     , m_effectiveBlendMode(o.m_effectiveBlendMode)
201     , m_isolation(o.m_isolation)
202 #endif
203     , m_objectFit(o.m_objectFit)
204     , m_breakBefore(o.m_breakBefore)
205     , m_breakAfter(o.m_breakAfter)
206     , m_breakInside(o.m_breakInside)
207     , m_resize(o.m_resize)
208     , m_hasAttrContent(o.m_hasAttrContent)
209     , m_isPlaceholderStyle(o.m_isPlaceholderStyle)
210 {
211 }
212
213 Ref<StyleRareNonInheritedData> StyleRareNonInheritedData::copy() const
214 {
215     return adoptRef(*new StyleRareNonInheritedData(*this));
216 }
217
218 StyleRareNonInheritedData::~StyleRareNonInheritedData()
219 {
220 }
221
222 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
223 {
224     return opacity == o.opacity
225         && m_aspectRatioDenominator == o.m_aspectRatioDenominator
226         && m_aspectRatioNumerator == o.m_aspectRatioNumerator
227         && m_perspective == o.m_perspective
228         && m_perspectiveOriginX == o.m_perspectiveOriginX
229         && m_perspectiveOriginY == o.m_perspectiveOriginY
230         && lineClamp == o.lineClamp
231         && m_initialLetter == o.m_initialLetter
232 #if ENABLE(DASHBOARD_SUPPORT)
233         && m_dashboardRegions == o.m_dashboardRegions
234 #endif
235         && m_deprecatedFlexibleBox == o.m_deprecatedFlexibleBox
236         && m_flexibleBox == o.m_flexibleBox
237         && m_marquee == o.m_marquee
238         && m_multiCol == o.m_multiCol
239         && m_transform == o.m_transform
240         && m_filter == o.m_filter
241 #if ENABLE(FILTERS_LEVEL_2)
242         && m_backdropFilter == o.m_backdropFilter
243 #endif
244 #if ENABLE(CSS_GRID_LAYOUT)
245         && m_grid == o.m_grid
246         && m_gridItem == o.m_gridItem
247 #endif
248 #if ENABLE(CSS_SCROLL_SNAP)
249         && m_scrollSnapPoints == o.m_scrollSnapPoints
250 #endif
251         && contentDataEquivalent(o)
252         && arePointingToEqualData(m_counterDirectives, o.m_counterDirectives)
253         && m_altText == o.m_altText
254         && arePointingToEqualData(m_boxShadow, o.m_boxShadow)
255         && arePointingToEqualData(m_willChange, o.m_willChange)
256         && arePointingToEqualData(m_boxReflect, o.m_boxReflect)
257         && arePointingToEqualData(m_animations, o.m_animations)
258         && arePointingToEqualData(m_transitions, o.m_transitions)
259         && m_mask == o.m_mask
260         && m_maskBoxImage == o.m_maskBoxImage
261         && m_pageSize == o.m_pageSize
262         && m_objectPosition == o.m_objectPosition
263 #if ENABLE(CSS_SHAPES)
264         && arePointingToEqualData(m_shapeOutside, o.m_shapeOutside)
265         && m_shapeMargin == o.m_shapeMargin
266         && m_shapeImageThreshold == o.m_shapeImageThreshold
267 #endif
268         && arePointingToEqualData(m_clipPath, o.m_clipPath)
269         && m_textDecorationColor == o.m_textDecorationColor
270         && m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor
271         && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
272         && m_visitedLinkOutlineColor == o.m_visitedLinkOutlineColor
273         && m_visitedLinkBorderLeftColor == o.m_visitedLinkBorderLeftColor
274         && m_visitedLinkBorderRightColor == o.m_visitedLinkBorderRightColor
275         && m_visitedLinkBorderTopColor == o.m_visitedLinkBorderTopColor
276         && m_visitedLinkBorderBottomColor == o.m_visitedLinkBorderBottomColor
277         && m_order == o.m_order
278         && m_flowThread == o.m_flowThread
279         && m_alignContent == o.m_alignContent
280         && m_alignItems == o.m_alignItems
281         && m_alignSelf == o.m_alignSelf
282         && m_justifyContent == o.m_justifyContent
283         && m_justifyItems == o.m_justifyItems
284         && m_justifySelf == o.m_justifySelf
285         && m_regionThread == o.m_regionThread
286         && m_regionFragment == o.m_regionFragment
287         && m_pageSizeType == o.m_pageSizeType
288         && m_transformStyle3D == o.m_transformStyle3D
289         && m_backfaceVisibility == o.m_backfaceVisibility
290         && userDrag == o.userDrag
291         && textOverflow == o.textOverflow
292         && marginBeforeCollapse == o.marginBeforeCollapse
293         && marginAfterCollapse == o.marginAfterCollapse
294         && m_appearance == o.m_appearance
295         && m_borderFit == o.m_borderFit
296         && m_textCombine == o.m_textCombine
297         && m_textDecorationStyle == o.m_textDecorationStyle
298 #if ENABLE(TOUCH_EVENTS)
299         && m_touchAction == o.m_touchAction
300 #endif
301 #if ENABLE(CSS_SCROLL_SNAP)
302         && m_scrollSnapType == o.m_scrollSnapType
303 #endif
304         && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
305 #if ENABLE(CSS_COMPOSITING)
306         && m_effectiveBlendMode == o.m_effectiveBlendMode
307         && m_isolation == o.m_isolation
308 #endif
309         && m_aspectRatioType == o.m_aspectRatioType
310         && m_objectFit == o.m_objectFit
311         && m_breakAfter == o.m_breakAfter
312         && m_breakBefore == o.m_breakBefore
313         && m_breakInside == o.m_breakInside
314         && m_resize == o.m_resize
315         && m_hasAttrContent == o.m_hasAttrContent
316         && m_isPlaceholderStyle == o.m_isPlaceholderStyle;
317 }
318
319 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const
320 {
321     ContentData* a = m_content.get();
322     ContentData* b = o.m_content.get();
323
324     while (a && b && *a == *b) {
325         a = a->next();
326         b = b->next();
327     }
328
329     return !a && !b;
330 }
331
332 bool StyleRareNonInheritedData::hasFilters() const
333 {
334     return m_filter.get() && !m_filter->m_operations.isEmpty();
335 }
336
337 #if ENABLE(FILTERS_LEVEL_2)
338 bool StyleRareNonInheritedData::hasBackdropFilters() const
339 {
340     return m_backdropFilter.get() && !m_backdropFilter->m_operations.isEmpty();
341 }
342 #endif
343
344 } // namespace WebCore