Remove CSS regions related fields from RenderStyle
[WebKit-https.git] / Source / WebCore / rendering / style / StyleRareNonInheritedData.cpp
1 /*
2  * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3  * Copyright (C) 2004-2017 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     , aspectRatioDenominator(RenderStyle::initialAspectRatioDenominator())
42     , aspectRatioNumerator(RenderStyle::initialAspectRatioNumerator())
43     , perspective(RenderStyle::initialPerspective())
44     , perspectiveOriginX(RenderStyle::initialPerspectiveOriginX())
45     , perspectiveOriginY(RenderStyle::initialPerspectiveOriginY())
46     , lineClamp(RenderStyle::initialLineClamp())
47     , initialLetter(RenderStyle::initialInitialLetter())
48     , deprecatedFlexibleBox(StyleDeprecatedFlexibleBoxData::create())
49     , flexibleBox(StyleFlexibleBoxData::create())
50     , marquee(StyleMarqueeData::create())
51     , multiCol(StyleMultiColData::create())
52     , transform(StyleTransformData::create())
53     , filter(StyleFilterData::create())
54 #if ENABLE(FILTERS_LEVEL_2)
55     , backdropFilter(StyleFilterData::create())
56 #endif
57     , grid(StyleGridData::create())
58     , gridItem(StyleGridItemData::create())
59 #if ENABLE(CSS_SCROLL_SNAP)
60     , scrollSnapPort(StyleScrollSnapPort::create())
61     , scrollSnapArea(StyleScrollSnapArea::create())
62 #endif
63     , willChange(RenderStyle::initialWillChange())
64     , mask(FillLayer(MaskFillLayer))
65     , objectPosition(RenderStyle::initialObjectPosition())
66     , shapeOutside(RenderStyle::initialShapeOutside())
67     , shapeMargin(RenderStyle::initialShapeMargin())
68     , shapeImageThreshold(RenderStyle::initialShapeImageThreshold())
69     , clipPath(RenderStyle::initialClipPath())
70     , visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor())
71     , order(RenderStyle::initialOrder())
72     , alignContent(RenderStyle::initialContentAlignment())
73     , alignItems(RenderStyle::initialDefaultAlignment())
74     , alignSelf(RenderStyle::initialSelfAlignment())
75     , justifyContent(RenderStyle::initialContentAlignment())
76     , justifyItems(RenderStyle::initialSelfAlignment())
77     , justifySelf(RenderStyle::initialSelfAlignment())
78 #if ENABLE(TOUCH_EVENTS)
79     , touchAction(static_cast<unsigned>(RenderStyle::initialTouchAction()))
80 #endif
81     , pageSizeType(PAGE_SIZE_AUTO)
82     , transformStyle3D(RenderStyle::initialTransformStyle3D())
83     , backfaceVisibility(RenderStyle::initialBackfaceVisibility())
84     , userDrag(RenderStyle::initialUserDrag())
85     , textOverflow(RenderStyle::initialTextOverflow())
86     , marginBeforeCollapse(MCOLLAPSE)
87     , marginAfterCollapse(MCOLLAPSE)
88     , appearance(RenderStyle::initialAppearance())
89     , borderFit(RenderStyle::initialBorderFit())
90     , textCombine(RenderStyle::initialTextCombine())
91     , textDecorationStyle(RenderStyle::initialTextDecorationStyle())
92     , aspectRatioType(RenderStyle::initialAspectRatioType())
93 #if ENABLE(CSS_COMPOSITING)
94     , effectiveBlendMode(RenderStyle::initialBlendMode())
95     , isolation(RenderStyle::initialIsolation())
96 #endif
97 #if ENABLE(APPLE_PAY)
98     , applePayButtonStyle(static_cast<unsigned>(RenderStyle::initialApplePayButtonStyle()))
99     , applePayButtonType(static_cast<unsigned>(RenderStyle::initialApplePayButtonType()))
100 #endif
101     , objectFit(RenderStyle::initialObjectFit())
102     , breakBefore(RenderStyle::initialBreakBetween())
103     , breakAfter(RenderStyle::initialBreakBetween())
104     , breakInside(RenderStyle::initialBreakInside())
105     , resize(RenderStyle::initialResize())
106     , hasAttrContent(false)
107     , isNotFinal(false)
108 {
109     maskBoxImage.setMaskDefaults();
110 }
111
112 inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
113     : RefCounted<StyleRareNonInheritedData>()
114     , opacity(o.opacity)
115     , aspectRatioDenominator(o.aspectRatioDenominator)
116     , aspectRatioNumerator(o.aspectRatioNumerator)
117     , perspective(o.perspective)
118     , perspectiveOriginX(o.perspectiveOriginX)
119     , perspectiveOriginY(o.perspectiveOriginY)
120     , lineClamp(o.lineClamp)
121     , initialLetter(o.initialLetter)
122     , deprecatedFlexibleBox(o.deprecatedFlexibleBox)
123     , flexibleBox(o.flexibleBox)
124     , marquee(o.marquee)
125     , multiCol(o.multiCol)
126     , transform(o.transform)
127     , filter(o.filter)
128 #if ENABLE(FILTERS_LEVEL_2)
129     , backdropFilter(o.backdropFilter)
130 #endif
131     , grid(o.grid)
132     , gridItem(o.gridItem)
133 #if ENABLE(CSS_SCROLL_SNAP)
134     , scrollSnapPort(o.scrollSnapPort)
135     , scrollSnapArea(o.scrollSnapArea)
136 #endif
137     , content(o.content ? o.content->clone() : nullptr)
138     , counterDirectives(o.counterDirectives ? clone(*o.counterDirectives) : nullptr)
139     , altText(o.altText)
140     , boxShadow(o.boxShadow ? std::make_unique<ShadowData>(*o.boxShadow) : nullptr)
141     , willChange(o.willChange)
142     , boxReflect(o.boxReflect)
143     , animations(o.animations ? std::make_unique<AnimationList>(*o.animations) : nullptr)
144     , transitions(o.transitions ? std::make_unique<AnimationList>(*o.transitions) : nullptr)
145     , mask(o.mask)
146     , maskBoxImage(o.maskBoxImage)
147     , pageSize(o.pageSize)
148     , objectPosition(o.objectPosition)
149     , shapeOutside(o.shapeOutside)
150     , shapeMargin(o.shapeMargin)
151     , shapeImageThreshold(o.shapeImageThreshold)
152     , clipPath(o.clipPath)
153     , textDecorationColor(o.textDecorationColor)
154     , visitedLinkTextDecorationColor(o.visitedLinkTextDecorationColor)
155     , visitedLinkBackgroundColor(o.visitedLinkBackgroundColor)
156     , visitedLinkOutlineColor(o.visitedLinkOutlineColor)
157     , visitedLinkBorderLeftColor(o.visitedLinkBorderLeftColor)
158     , visitedLinkBorderRightColor(o.visitedLinkBorderRightColor)
159     , visitedLinkBorderTopColor(o.visitedLinkBorderTopColor)
160     , visitedLinkBorderBottomColor(o.visitedLinkBorderBottomColor)
161     , order(o.order)
162     , alignContent(o.alignContent)
163     , alignItems(o.alignItems)
164     , alignSelf(o.alignSelf)
165     , justifyContent(o.justifyContent)
166     , justifyItems(o.justifyItems)
167     , justifySelf(o.justifySelf)
168 #if ENABLE(TOUCH_EVENTS)
169     , touchAction(o.touchAction)
170 #endif
171     , pageSizeType(o.pageSizeType)
172     , transformStyle3D(o.transformStyle3D)
173     , backfaceVisibility(o.backfaceVisibility)
174     , userDrag(o.userDrag)
175     , textOverflow(o.textOverflow)
176     , marginBeforeCollapse(o.marginBeforeCollapse)
177     , marginAfterCollapse(o.marginAfterCollapse)
178     , appearance(o.appearance)
179     , borderFit(o.borderFit)
180     , textCombine(o.textCombine)
181     , textDecorationStyle(o.textDecorationStyle)
182     , aspectRatioType(o.aspectRatioType)
183 #if ENABLE(CSS_COMPOSITING)
184     , effectiveBlendMode(o.effectiveBlendMode)
185     , isolation(o.isolation)
186 #endif
187 #if ENABLE(APPLE_PAY)
188     , applePayButtonStyle(o.applePayButtonStyle)
189     , applePayButtonType(o.applePayButtonType)
190 #endif
191     , objectFit(o.objectFit)
192     , breakBefore(o.breakBefore)
193     , breakAfter(o.breakAfter)
194     , breakInside(o.breakInside)
195     , resize(o.resize)
196     , hasAttrContent(o.hasAttrContent)
197     , isNotFinal(o.isNotFinal)
198 {
199 }
200
201 Ref<StyleRareNonInheritedData> StyleRareNonInheritedData::copy() const
202 {
203     return adoptRef(*new StyleRareNonInheritedData(*this));
204 }
205
206 StyleRareNonInheritedData::~StyleRareNonInheritedData()
207 {
208 }
209
210 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
211 {
212     return opacity == o.opacity
213         && aspectRatioDenominator == o.aspectRatioDenominator
214         && aspectRatioNumerator == o.aspectRatioNumerator
215         && perspective == o.perspective
216         && perspectiveOriginX == o.perspectiveOriginX
217         && perspectiveOriginY == o.perspectiveOriginY
218         && lineClamp == o.lineClamp
219         && initialLetter == o.initialLetter
220 #if ENABLE(DASHBOARD_SUPPORT)
221         && dashboardRegions == o.dashboardRegions
222 #endif
223         && deprecatedFlexibleBox == o.deprecatedFlexibleBox
224         && flexibleBox == o.flexibleBox
225         && marquee == o.marquee
226         && multiCol == o.multiCol
227         && transform == o.transform
228         && filter == o.filter
229 #if ENABLE(FILTERS_LEVEL_2)
230         && backdropFilter == o.backdropFilter
231 #endif
232         && grid == o.grid
233         && gridItem == o.gridItem
234 #if ENABLE(CSS_SCROLL_SNAP)
235         && scrollSnapPort == o.scrollSnapPort
236         && scrollSnapArea == o.scrollSnapArea
237 #endif
238         && contentDataEquivalent(o)
239         && arePointingToEqualData(counterDirectives, o.counterDirectives)
240         && altText == o.altText
241         && arePointingToEqualData(boxShadow, o.boxShadow)
242         && arePointingToEqualData(willChange, o.willChange)
243         && arePointingToEqualData(boxReflect, o.boxReflect)
244         && arePointingToEqualData(animations, o.animations)
245         && arePointingToEqualData(transitions, o.transitions)
246         && mask == o.mask
247         && maskBoxImage == o.maskBoxImage
248         && pageSize == o.pageSize
249         && objectPosition == o.objectPosition
250         && arePointingToEqualData(shapeOutside, o.shapeOutside)
251         && shapeMargin == o.shapeMargin
252         && shapeImageThreshold == o.shapeImageThreshold
253         && arePointingToEqualData(clipPath, o.clipPath)
254         && textDecorationColor == o.textDecorationColor
255         && visitedLinkTextDecorationColor == o.visitedLinkTextDecorationColor
256         && visitedLinkBackgroundColor == o.visitedLinkBackgroundColor
257         && visitedLinkOutlineColor == o.visitedLinkOutlineColor
258         && visitedLinkBorderLeftColor == o.visitedLinkBorderLeftColor
259         && visitedLinkBorderRightColor == o.visitedLinkBorderRightColor
260         && visitedLinkBorderTopColor == o.visitedLinkBorderTopColor
261         && visitedLinkBorderBottomColor == o.visitedLinkBorderBottomColor
262         && order == o.order
263         && alignContent == o.alignContent
264         && alignItems == o.alignItems
265         && alignSelf == o.alignSelf
266         && justifyContent == o.justifyContent
267         && justifyItems == o.justifyItems
268         && justifySelf == o.justifySelf
269         && pageSizeType == o.pageSizeType
270         && transformStyle3D == o.transformStyle3D
271         && backfaceVisibility == o.backfaceVisibility
272         && userDrag == o.userDrag
273         && textOverflow == o.textOverflow
274         && marginBeforeCollapse == o.marginBeforeCollapse
275         && marginAfterCollapse == o.marginAfterCollapse
276         && appearance == o.appearance
277         && borderFit == o.borderFit
278         && textCombine == o.textCombine
279         && textDecorationStyle == o.textDecorationStyle
280 #if ENABLE(TOUCH_EVENTS)
281         && touchAction == o.touchAction
282 #endif
283 #if ENABLE(CSS_COMPOSITING)
284         && effectiveBlendMode == o.effectiveBlendMode
285         && isolation == o.isolation
286 #endif
287 #if ENABLE(APPLE_PAY)
288         && applePayButtonStyle == o.applePayButtonStyle
289         && applePayButtonType == o.applePayButtonType
290 #endif
291         && aspectRatioType == o.aspectRatioType
292         && objectFit == o.objectFit
293         && breakAfter == o.breakAfter
294         && breakBefore == o.breakBefore
295         && breakInside == o.breakInside
296         && resize == o.resize
297         && hasAttrContent == o.hasAttrContent
298         && isNotFinal == o.isNotFinal;
299 }
300
301 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& other) const
302 {
303     auto* a = content.get();
304     auto* b = other.content.get();
305     while (a && b && *a == *b) {
306         a = a->next();
307         b = b->next();
308     }
309     return !a && !b;
310 }
311
312 bool StyleRareNonInheritedData::hasFilters() const
313 {
314     return !filter->operations.isEmpty();
315 }
316
317 #if ENABLE(FILTERS_LEVEL_2)
318
319 bool StyleRareNonInheritedData::hasBackdropFilters() const
320 {
321     return !backdropFilter->operations.isEmpty();
322 }
323
324 #endif
325
326 } // namespace WebCore