Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / 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 "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 WebCore {
34
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_justifySelf(RenderStyle::initialJustifySelf())
91     , m_justifySelfOverflowAlignment(RenderStyle::initialJustifySelfOverflowAlignment())
92     , m_scrollBehavior(RenderStyle::initialScrollBehavior())
93 {
94     m_maskBoxImage.setMaskDefaults();
95 }
96
97 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
98     : RefCounted<StyleRareNonInheritedData>()
99     , opacity(o.opacity)
100     , m_aspectRatioDenominator(o.m_aspectRatioDenominator)
101     , m_aspectRatioNumerator(o.m_aspectRatioNumerator)
102     , m_perspective(o.m_perspective)
103     , m_perspectiveOriginX(o.m_perspectiveOriginX)
104     , m_perspectiveOriginY(o.m_perspectiveOriginY)
105     , lineClamp(o.lineClamp)
106     , m_draggableRegionMode(o.m_draggableRegionMode)
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     , m_willChange(o.m_willChange)
113     , m_filter(o.m_filter)
114     , m_grid(o.m_grid)
115     , m_gridItem(o.m_gridItem)
116     , m_content(o.m_content ? o.m_content->clone() : nullptr)
117     , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr)
118     , m_boxShadow(o.m_boxShadow)
119     , m_boxReflect(o.m_boxReflect)
120     , m_animations(o.m_animations ? adoptPtrWillBeNoop(new CSSAnimationDataList(*o.m_animations)) : nullptr)
121     , m_transitions(o.m_transitions ? adoptPtrWillBeNoop(new CSSAnimationDataList(*o.m_transitions)) : nullptr)
122     , m_mask(o.m_mask)
123     , m_maskBoxImage(o.m_maskBoxImage)
124     , m_pageSize(o.m_pageSize)
125     , m_shapeOutside(o.m_shapeOutside)
126     , m_shapeMargin(o.m_shapeMargin)
127     , m_shapeImageThreshold(o.m_shapeImageThreshold)
128     , m_clipPath(o.m_clipPath)
129     , m_textDecorationColor(o.m_textDecorationColor)
130     , m_visitedLinkTextDecorationColor(o.m_visitedLinkTextDecorationColor)
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_objectPosition(o.m_objectPosition)
139     , m_pageSizeType(o.m_pageSizeType)
140     , m_transformStyle3D(o.m_transformStyle3D)
141     , m_backfaceVisibility(o.m_backfaceVisibility)
142     , m_alignContent(o.m_alignContent)
143     , m_alignItems(o.m_alignItems)
144     , m_alignItemsOverflowAlignment(o.m_alignItemsOverflowAlignment)
145     , m_alignSelf(o.m_alignSelf)
146     , m_alignSelfOverflowAlignment(o.m_alignSelfOverflowAlignment)
147     , m_justifyContent(o.m_justifyContent)
148     , userDrag(o.userDrag)
149     , textOverflow(o.textOverflow)
150     , marginBeforeCollapse(o.marginBeforeCollapse)
151     , marginAfterCollapse(o.marginAfterCollapse)
152     , m_appearance(o.m_appearance)
153     , m_borderFit(o.m_borderFit)
154     , m_textCombine(o.m_textCombine)
155     , m_textDecorationStyle(o.m_textDecorationStyle)
156     , m_wrapFlow(o.m_wrapFlow)
157     , m_wrapThrough(o.m_wrapThrough)
158     , m_hasCurrentOpacityAnimation(o.m_hasCurrentOpacityAnimation)
159     , m_hasCurrentTransformAnimation(o.m_hasCurrentTransformAnimation)
160     , m_hasCurrentFilterAnimation(o.m_hasCurrentFilterAnimation)
161     , m_runningOpacityAnimationOnCompositor(o.m_runningOpacityAnimationOnCompositor)
162     , m_runningTransformAnimationOnCompositor(o.m_runningTransformAnimationOnCompositor)
163     , m_runningFilterAnimationOnCompositor(o.m_runningFilterAnimationOnCompositor)
164     , m_hasAspectRatio(o.m_hasAspectRatio)
165     , m_effectiveBlendMode(o.m_effectiveBlendMode)
166     , m_touchAction(o.m_touchAction)
167     , m_objectFit(o.m_objectFit)
168     , m_isolation(o.m_isolation)
169     , m_justifySelf(o.m_justifySelf)
170     , m_justifySelfOverflowAlignment(o.m_justifySelfOverflowAlignment)
171     , m_scrollBehavior(o.m_scrollBehavior)
172 {
173 }
174
175 StyleRareNonInheritedData::~StyleRareNonInheritedData()
176 {
177     const FilterOperations& filterOperations = m_filter->m_operations;
178     for (unsigned i = 0; i < filterOperations.size(); ++i)
179         ReferenceFilterBuilder::clearDocumentResourceReference(filterOperations.at(i));
180 }
181
182 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
183 {
184     return opacity == o.opacity
185         && m_aspectRatioDenominator == o.m_aspectRatioDenominator
186         && m_aspectRatioNumerator == o.m_aspectRatioNumerator
187         && m_perspective == o.m_perspective
188         && m_perspectiveOriginX == o.m_perspectiveOriginX
189         && m_perspectiveOriginY == o.m_perspectiveOriginY
190         && lineClamp == o.lineClamp
191         && m_draggableRegionMode == o.m_draggableRegionMode
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         && m_willChange == o.m_willChange
198         && m_filter == o.m_filter
199         && m_grid == o.m_grid
200         && m_gridItem == o.m_gridItem
201         && contentDataEquivalent(o)
202         && counterDataEquivalent(o)
203         && shadowDataEquivalent(o)
204         && reflectionDataEquivalent(o)
205         && animationDataEquivalent(o)
206         && transitionDataEquivalent(o)
207         && m_mask == o.m_mask
208         && m_maskBoxImage == o.m_maskBoxImage
209         && m_pageSize == o.m_pageSize
210         && m_shapeOutside == o.m_shapeOutside
211         && m_shapeMargin == o.m_shapeMargin
212         && m_shapeImageThreshold == o.m_shapeImageThreshold
213         && m_clipPath == o.m_clipPath
214         && m_textDecorationColor == o.m_textDecorationColor
215         && m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor
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_objectPosition == o.m_objectPosition
224         && m_callbackSelectors == o.m_callbackSelectors
225         && m_pageSizeType == o.m_pageSizeType
226         && m_transformStyle3D == o.m_transformStyle3D
227         && m_backfaceVisibility == o.m_backfaceVisibility
228         && m_alignContent == o.m_alignContent
229         && m_alignItems == o.m_alignItems
230         && m_alignItemsOverflowAlignment == o.m_alignItemsOverflowAlignment
231         && m_alignSelf == o.m_alignSelf
232         && m_alignSelfOverflowAlignment == o.m_alignSelfOverflowAlignment
233         && m_justifyContent == o.m_justifyContent
234         && userDrag == o.userDrag
235         && textOverflow == o.textOverflow
236         && marginBeforeCollapse == o.marginBeforeCollapse
237         && marginAfterCollapse == o.marginAfterCollapse
238         && m_appearance == o.m_appearance
239         && m_borderFit == o.m_borderFit
240         && m_textCombine == o.m_textCombine
241         && m_textDecorationStyle == o.m_textDecorationStyle
242         && m_wrapFlow == o.m_wrapFlow
243         && m_wrapThrough == o.m_wrapThrough
244         && m_hasCurrentOpacityAnimation == o.m_hasCurrentOpacityAnimation
245         && m_hasCurrentTransformAnimation == o.m_hasCurrentTransformAnimation
246         && m_hasCurrentFilterAnimation == o.m_hasCurrentFilterAnimation
247         && m_effectiveBlendMode == o.m_effectiveBlendMode
248         && m_hasAspectRatio == o.m_hasAspectRatio
249         && m_touchAction == o.m_touchAction
250         && m_objectFit == o.m_objectFit
251         && m_isolation == o.m_isolation
252         && m_justifySelf == o.m_justifySelf
253         && m_justifySelfOverflowAlignment == o.m_justifySelfOverflowAlignment
254         && m_scrollBehavior == o.m_scrollBehavior;
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     return dataEquivalent(m_counterDirectives, o.m_counterDirectives);
273 }
274
275 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
276 {
277     return dataEquivalent(m_boxShadow, o.m_boxShadow);
278 }
279
280 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
281 {
282     return dataEquivalent(m_boxReflect, o.m_boxReflect);
283 }
284
285 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
286 {
287     return dataEquivalent(m_animations, o.m_animations);
288 }
289
290 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
291 {
292     return dataEquivalent(m_transitions, o.m_transitions);
293 }
294
295 bool StyleRareNonInheritedData::hasFilters() const
296 {
297     return m_filter.get() && !m_filter->m_operations.isEmpty();
298 }
299
300 } // namespace WebCore