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 "core/rendering/style/StyleRareNonInheritedData.h"
24
25 #include "core/rendering/style/ContentData.h"
26 #include "core/rendering/style/DataEquivalency.h"
27 #include "core/rendering/style/RenderStyle.h"
28 #include "core/rendering/style/ShadowList.h"
29 #include "core/rendering/style/StyleFilterData.h"
30 #include "core/rendering/style/StyleTransformData.h"
31 #include "core/rendering/svg/ReferenceFilterBuilder.h"
32
33 namespace blink {
34
StyleRareNonInheritedData()35 StyleRareNonInheritedData::StyleRareNonInheritedData()
36 : opacity(RenderStyle::initialOpacity())
37 , m_aspectRatioDenominator(RenderStyle::initialAspectRatioDenominator())
38 , m_aspectRatioNumerator(RenderStyle::initialAspectRatioNumerator())
39 , m_perspective(RenderStyle::initialPerspective())
40 , m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX())
41 , m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY())
42 , lineClamp(RenderStyle::initialLineClamp())
43 , m_draggableRegionMode(DraggableRegionNone)
44 , m_mask(MaskFillLayer, true)
45 , m_pageSize()
46 , m_shapeOutside(RenderStyle::initialShapeOutside())
47 , m_shapeMargin(RenderStyle::initialShapeMargin())
48 , m_shapeImageThreshold(RenderStyle::initialShapeImageThreshold())
49 , m_clipPath(RenderStyle::initialClipPath())
50 , m_textDecorationColor(StyleColor::currentColor())
51 , m_visitedLinkTextDecorationColor(StyleColor::currentColor())
52 , m_visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor())
53 , m_visitedLinkOutlineColor(StyleColor::currentColor())
54 , m_visitedLinkBorderLeftColor(StyleColor::currentColor())
55 , m_visitedLinkBorderRightColor(StyleColor::currentColor())
56 , m_visitedLinkBorderTopColor(StyleColor::currentColor())
57 , m_visitedLinkBorderBottomColor(StyleColor::currentColor())
58 , m_order(RenderStyle::initialOrder())
59 , m_objectPosition(RenderStyle::initialObjectPosition())
60 , m_pageSizeType(PAGE_SIZE_AUTO)
61 , m_transformStyle3D(RenderStyle::initialTransformStyle3D())
62 , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility())
63 , m_alignContent(RenderStyle::initialAlignContent())
64 , m_alignItems(RenderStyle::initialAlignItems())
65 , m_alignItemsOverflowAlignment(RenderStyle::initialAlignItemsOverflowAlignment())
66 , m_alignSelf(RenderStyle::initialAlignSelf())
67 , m_alignSelfOverflowAlignment(RenderStyle::initialAlignSelfOverflowAlignment())
68 , m_justifyContent(RenderStyle::initialJustifyContent())
69 , userDrag(RenderStyle::initialUserDrag())
70 , textOverflow(RenderStyle::initialTextOverflow())
71 , marginBeforeCollapse(MCOLLAPSE)
72 , marginAfterCollapse(MCOLLAPSE)
73 , m_appearance(RenderStyle::initialAppearance())
74 , m_borderFit(RenderStyle::initialBorderFit())
75 , m_textCombine(RenderStyle::initialTextCombine())
76 , m_textDecorationStyle(RenderStyle::initialTextDecorationStyle())
77 , m_wrapFlow(RenderStyle::initialWrapFlow())
78 , m_wrapThrough(RenderStyle::initialWrapThrough())
79 , m_hasCurrentOpacityAnimation(false)
80 , m_hasCurrentTransformAnimation(false)
81 , m_hasCurrentFilterAnimation(false)
82 , m_runningOpacityAnimationOnCompositor(false)
83 , m_runningTransformAnimationOnCompositor(false)
84 , m_runningFilterAnimationOnCompositor(false)
85 , m_hasAspectRatio(false)
86 , m_effectiveBlendMode(RenderStyle::initialBlendMode())
87 , m_touchAction(RenderStyle::initialTouchAction())
88 , m_objectFit(RenderStyle::initialObjectFit())
89 , m_isolation(RenderStyle::initialIsolation())
90 , m_justifyItems(RenderStyle::initialJustifyItems())
91 , m_justifyItemsOverflowAlignment(RenderStyle::initialJustifyItemsOverflowAlignment())
92 , m_justifyItemsPositionType(RenderStyle::initialJustifyItemsPositionType())
93 , m_justifySelf(RenderStyle::initialJustifySelf())
94 , m_justifySelfOverflowAlignment(RenderStyle::initialJustifySelfOverflowAlignment())
95 , m_scrollBehavior(RenderStyle::initialScrollBehavior())
96 , m_requiresAcceleratedCompositingForExternalReasons(false)
97 , m_hasInlineTransform(false)
98 {
99 m_maskBoxImage.setMaskDefaults();
100 }
101
StyleRareNonInheritedData(const StyleRareNonInheritedData & o)102 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
103 : RefCounted<StyleRareNonInheritedData>()
104 , opacity(o.opacity)
105 , m_aspectRatioDenominator(o.m_aspectRatioDenominator)
106 , m_aspectRatioNumerator(o.m_aspectRatioNumerator)
107 , m_perspective(o.m_perspective)
108 , m_perspectiveOriginX(o.m_perspectiveOriginX)
109 , m_perspectiveOriginY(o.m_perspectiveOriginY)
110 , lineClamp(o.lineClamp)
111 , m_draggableRegionMode(o.m_draggableRegionMode)
112 , m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox)
113 , m_flexibleBox(o.m_flexibleBox)
114 , m_marquee(o.m_marquee)
115 , m_multiCol(o.m_multiCol)
116 , m_transform(o.m_transform)
117 , m_willChange(o.m_willChange)
118 , m_filter(o.m_filter)
119 , m_grid(o.m_grid)
120 , m_gridItem(o.m_gridItem)
121 , m_content(o.m_content ? o.m_content->clone() : nullptr)
122 , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr)
123 , m_boxShadow(o.m_boxShadow)
124 , m_boxReflect(o.m_boxReflect)
125 , m_animations(o.m_animations ? CSSAnimationData::create(*o.m_animations) : nullptr)
126 , m_transitions(o.m_transitions ? CSSTransitionData::create(*o.m_transitions) : nullptr)
127 , m_mask(o.m_mask)
128 , m_maskBoxImage(o.m_maskBoxImage)
129 , m_pageSize(o.m_pageSize)
130 , m_shapeOutside(o.m_shapeOutside)
131 , m_shapeMargin(o.m_shapeMargin)
132 , m_shapeImageThreshold(o.m_shapeImageThreshold)
133 , m_clipPath(o.m_clipPath)
134 , m_textDecorationColor(o.m_textDecorationColor)
135 , m_visitedLinkTextDecorationColor(o.m_visitedLinkTextDecorationColor)
136 , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor)
137 , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor)
138 , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor)
139 , m_visitedLinkBorderRightColor(o.m_visitedLinkBorderRightColor)
140 , m_visitedLinkBorderTopColor(o.m_visitedLinkBorderTopColor)
141 , m_visitedLinkBorderBottomColor(o.m_visitedLinkBorderBottomColor)
142 , m_order(o.m_order)
143 , m_objectPosition(o.m_objectPosition)
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_alignItemsOverflowAlignment(o.m_alignItemsOverflowAlignment)
150 , m_alignSelf(o.m_alignSelf)
151 , m_alignSelfOverflowAlignment(o.m_alignSelfOverflowAlignment)
152 , m_justifyContent(o.m_justifyContent)
153 , userDrag(o.userDrag)
154 , textOverflow(o.textOverflow)
155 , marginBeforeCollapse(o.marginBeforeCollapse)
156 , marginAfterCollapse(o.marginAfterCollapse)
157 , m_appearance(o.m_appearance)
158 , m_borderFit(o.m_borderFit)
159 , m_textCombine(o.m_textCombine)
160 , m_textDecorationStyle(o.m_textDecorationStyle)
161 , m_wrapFlow(o.m_wrapFlow)
162 , m_wrapThrough(o.m_wrapThrough)
163 , m_hasCurrentOpacityAnimation(o.m_hasCurrentOpacityAnimation)
164 , m_hasCurrentTransformAnimation(o.m_hasCurrentTransformAnimation)
165 , m_hasCurrentFilterAnimation(o.m_hasCurrentFilterAnimation)
166 , m_runningOpacityAnimationOnCompositor(o.m_runningOpacityAnimationOnCompositor)
167 , m_runningTransformAnimationOnCompositor(o.m_runningTransformAnimationOnCompositor)
168 , m_runningFilterAnimationOnCompositor(o.m_runningFilterAnimationOnCompositor)
169 , m_hasAspectRatio(o.m_hasAspectRatio)
170 , m_effectiveBlendMode(o.m_effectiveBlendMode)
171 , m_touchAction(o.m_touchAction)
172 , m_objectFit(o.m_objectFit)
173 , m_isolation(o.m_isolation)
174 , m_justifyItems(o.m_justifyItems)
175 , m_justifyItemsOverflowAlignment(o.m_justifyItemsOverflowAlignment)
176 , m_justifyItemsPositionType(o.m_justifyItemsPositionType)
177 , m_justifySelf(o.m_justifySelf)
178 , m_justifySelfOverflowAlignment(o.m_justifySelfOverflowAlignment)
179 , m_scrollBehavior(o.m_scrollBehavior)
180 , m_requiresAcceleratedCompositingForExternalReasons(o.m_requiresAcceleratedCompositingForExternalReasons)
181 , m_hasInlineTransform(o.m_hasInlineTransform)
182 {
183 }
184
~StyleRareNonInheritedData()185 StyleRareNonInheritedData::~StyleRareNonInheritedData()
186 {
187 const FilterOperations& filterOperations = m_filter->m_operations;
188 for (unsigned i = 0; i < filterOperations.size(); ++i)
189 ReferenceFilterBuilder::clearDocumentResourceReference(filterOperations.at(i));
190 }
191
operator ==(const StyleRareNonInheritedData & o) const192 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
193 {
194 return opacity == o.opacity
195 && m_aspectRatioDenominator == o.m_aspectRatioDenominator
196 && m_aspectRatioNumerator == o.m_aspectRatioNumerator
197 && m_perspective == o.m_perspective
198 && m_perspectiveOriginX == o.m_perspectiveOriginX
199 && m_perspectiveOriginY == o.m_perspectiveOriginY
200 && lineClamp == o.lineClamp
201 && m_draggableRegionMode == o.m_draggableRegionMode
202 && m_deprecatedFlexibleBox == o.m_deprecatedFlexibleBox
203 && m_flexibleBox == o.m_flexibleBox
204 && m_marquee == o.m_marquee
205 && m_multiCol == o.m_multiCol
206 && m_transform == o.m_transform
207 && m_willChange == o.m_willChange
208 && m_filter == o.m_filter
209 && m_grid == o.m_grid
210 && m_gridItem == o.m_gridItem
211 && contentDataEquivalent(o)
212 && counterDataEquivalent(o)
213 && shadowDataEquivalent(o)
214 && reflectionDataEquivalent(o)
215 && animationDataEquivalent(o)
216 && transitionDataEquivalent(o)
217 && m_mask == o.m_mask
218 && m_maskBoxImage == o.m_maskBoxImage
219 && m_pageSize == o.m_pageSize
220 && m_shapeOutside == o.m_shapeOutside
221 && m_shapeMargin == o.m_shapeMargin
222 && m_shapeImageThreshold == o.m_shapeImageThreshold
223 && m_clipPath == o.m_clipPath
224 && m_textDecorationColor == o.m_textDecorationColor
225 && m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor
226 && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
227 && m_visitedLinkOutlineColor == o.m_visitedLinkOutlineColor
228 && m_visitedLinkBorderLeftColor == o.m_visitedLinkBorderLeftColor
229 && m_visitedLinkBorderRightColor == o.m_visitedLinkBorderRightColor
230 && m_visitedLinkBorderTopColor == o.m_visitedLinkBorderTopColor
231 && m_visitedLinkBorderBottomColor == o.m_visitedLinkBorderBottomColor
232 && m_order == o.m_order
233 && m_objectPosition == o.m_objectPosition
234 && m_callbackSelectors == o.m_callbackSelectors
235 && m_pageSizeType == o.m_pageSizeType
236 && m_transformStyle3D == o.m_transformStyle3D
237 && m_backfaceVisibility == o.m_backfaceVisibility
238 && m_alignContent == o.m_alignContent
239 && m_alignItems == o.m_alignItems
240 && m_alignItemsOverflowAlignment == o.m_alignItemsOverflowAlignment
241 && m_alignSelf == o.m_alignSelf
242 && m_alignSelfOverflowAlignment == o.m_alignSelfOverflowAlignment
243 && m_justifyContent == o.m_justifyContent
244 && userDrag == o.userDrag
245 && textOverflow == o.textOverflow
246 && marginBeforeCollapse == o.marginBeforeCollapse
247 && marginAfterCollapse == o.marginAfterCollapse
248 && m_appearance == o.m_appearance
249 && m_borderFit == o.m_borderFit
250 && m_textCombine == o.m_textCombine
251 && m_textDecorationStyle == o.m_textDecorationStyle
252 && m_wrapFlow == o.m_wrapFlow
253 && m_wrapThrough == o.m_wrapThrough
254 && m_hasCurrentOpacityAnimation == o.m_hasCurrentOpacityAnimation
255 && m_hasCurrentTransformAnimation == o.m_hasCurrentTransformAnimation
256 && m_hasCurrentFilterAnimation == o.m_hasCurrentFilterAnimation
257 && m_effectiveBlendMode == o.m_effectiveBlendMode
258 && m_hasAspectRatio == o.m_hasAspectRatio
259 && m_touchAction == o.m_touchAction
260 && m_objectFit == o.m_objectFit
261 && m_isolation == o.m_isolation
262 && m_justifyItems == o.m_justifyItems
263 && m_justifyItemsOverflowAlignment == o.m_justifyItemsOverflowAlignment
264 && m_justifyItemsPositionType == o.m_justifyItemsPositionType
265 && m_justifySelf == o.m_justifySelf
266 && m_justifySelfOverflowAlignment == o.m_justifySelfOverflowAlignment
267 && m_scrollBehavior == o.m_scrollBehavior
268 && m_requiresAcceleratedCompositingForExternalReasons == o.m_requiresAcceleratedCompositingForExternalReasons
269 && m_hasInlineTransform == o.m_hasInlineTransform;
270 }
271
contentDataEquivalent(const StyleRareNonInheritedData & o) const272 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const
273 {
274 ContentData* a = m_content.get();
275 ContentData* b = o.m_content.get();
276
277 while (a && b && *a == *b) {
278 a = a->next();
279 b = b->next();
280 }
281
282 return !a && !b;
283 }
284
counterDataEquivalent(const StyleRareNonInheritedData & o) const285 bool StyleRareNonInheritedData::counterDataEquivalent(const StyleRareNonInheritedData& o) const
286 {
287 return dataEquivalent(m_counterDirectives, o.m_counterDirectives);
288 }
289
shadowDataEquivalent(const StyleRareNonInheritedData & o) const290 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
291 {
292 return dataEquivalent(m_boxShadow, o.m_boxShadow);
293 }
294
reflectionDataEquivalent(const StyleRareNonInheritedData & o) const295 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
296 {
297 return dataEquivalent(m_boxReflect, o.m_boxReflect);
298 }
299
animationDataEquivalent(const StyleRareNonInheritedData & o) const300 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
301 {
302 if (!m_animations && !o.m_animations)
303 return true;
304 if (!m_animations || !o.m_animations)
305 return false;
306 return m_animations->animationsMatchForStyleRecalc(*o.m_animations);
307 }
308
transitionDataEquivalent(const StyleRareNonInheritedData & o) const309 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
310 {
311 if (!m_transitions && !o.m_transitions)
312 return true;
313 if (!m_transitions || !o.m_transitions)
314 return false;
315 return m_transitions->transitionsMatchForStyleRecalc(*o.m_transitions);
316 }
317
hasFilters() const318 bool StyleRareNonInheritedData::hasFilters() const
319 {
320 return m_filter.get() && !m_filter->m_operations.isEmpty();
321 }
322
323 } // namespace blink
324