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