Move CSS3 text decoration implementation behind ENABLE(CSS3_TEXT_DECORATION)
[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
34 namespace WebCore {
35
36 StyleRareNonInheritedData::StyleRareNonInheritedData()
37     : opacity(RenderStyle::initialOpacity())
38     , m_aspectRatioDenominator(RenderStyle::initialAspectRatioDenominator())
39     , m_aspectRatioNumerator(RenderStyle::initialAspectRatioNumerator())
40     , m_perspective(RenderStyle::initialPerspective())
41     , m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX())
42     , m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY())
43     , lineClamp(RenderStyle::initialLineClamp())
44 #if ENABLE(DRAGGABLE_REGION)
45     , m_draggableRegionMode(DraggableRegionNone)
46 #endif
47     , m_deprecatedFlexibleBox(StyleDeprecatedFlexibleBoxData::create())
48     , m_flexibleBox(StyleFlexibleBoxData::create())
49     , m_marquee(StyleMarqueeData::create())
50     , m_multiCol(StyleMultiColData::create())
51     , m_transform(StyleTransformData::create())
52 #if ENABLE(CSS_FILTERS)
53     , m_filter(StyleFilterData::create())
54 #endif
55     , m_grid(StyleGridData::create())
56     , m_gridItem(StyleGridItemData::create())
57     , m_mask(FillLayer(MaskFillLayer))
58     , m_pageSize()
59 #if ENABLE(CSS_SHAPES)
60     , m_shapeInside(RenderStyle::initialShapeInside())
61     , m_shapeOutside(RenderStyle::initialShapeOutside())
62     , m_shapeMargin(RenderStyle::initialShapeMargin())
63     , m_shapePadding(RenderStyle::initialShapePadding())
64     , m_shapeImageThreshold(RenderStyle::initialShapeImageThreshold())
65 #endif
66     , m_clipPath(RenderStyle::initialClipPath())
67     , m_visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor())
68     , m_order(RenderStyle::initialOrder())
69     , m_flowThread(RenderStyle::initialFlowThread())
70     , m_regionThread(RenderStyle::initialRegionThread())
71     , m_regionFragment(RenderStyle::initialRegionFragment())
72     , m_regionBreakAfter(RenderStyle::initialPageBreak())
73     , m_regionBreakBefore(RenderStyle::initialPageBreak())
74     , m_regionBreakInside(RenderStyle::initialPageBreak())
75     , m_pageSizeType(PAGE_SIZE_AUTO)
76     , m_transformStyle3D(RenderStyle::initialTransformStyle3D())
77     , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility())
78     , m_alignContent(RenderStyle::initialAlignContent())
79     , m_alignItems(RenderStyle::initialAlignItems())
80     , m_alignSelf(RenderStyle::initialAlignSelf())
81     , m_justifyContent(RenderStyle::initialJustifyContent())
82     , userDrag(RenderStyle::initialUserDrag())
83     , textOverflow(RenderStyle::initialTextOverflow())
84     , marginBeforeCollapse(MCOLLAPSE)
85     , marginAfterCollapse(MCOLLAPSE)
86     , m_appearance(RenderStyle::initialAppearance())
87     , m_borderFit(RenderStyle::initialBorderFit())
88     , m_textCombine(RenderStyle::initialTextCombine())
89 #if ENABLE(CSS3_TEXT_DECORATION)
90     , m_textDecorationStyle(RenderStyle::initialTextDecorationStyle())
91 #endif
92     , m_wrapFlow(RenderStyle::initialWrapFlow())
93     , m_wrapThrough(RenderStyle::initialWrapThrough())
94 #if USE(ACCELERATED_COMPOSITING)
95     , m_runningAcceleratedAnimation(false)
96 #endif
97     , m_hasAspectRatio(false)
98 #if ENABLE(CSS_COMPOSITING)
99     , m_effectiveBlendMode(RenderStyle::initialBlendMode())
100 #endif
101     , m_objectFit(RenderStyle::initialObjectFit())
102 {
103     m_maskBoxImage.setMaskDefaults();
104 }
105
106 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
107     : RefCounted<StyleRareNonInheritedData>()
108     , opacity(o.opacity)
109     , m_aspectRatioDenominator(o.m_aspectRatioDenominator)
110     , m_aspectRatioNumerator(o.m_aspectRatioNumerator)
111     , m_perspective(o.m_perspective)
112     , m_perspectiveOriginX(o.m_perspectiveOriginX)
113     , m_perspectiveOriginY(o.m_perspectiveOriginY)
114     , lineClamp(o.lineClamp)
115 #if ENABLE(DRAGGABLE_REGION)
116     , m_draggableRegionMode(o.m_draggableRegionMode)
117 #endif
118     , m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox)
119     , m_flexibleBox(o.m_flexibleBox)
120     , m_marquee(o.m_marquee)
121     , m_multiCol(o.m_multiCol)
122     , m_transform(o.m_transform)
123 #if ENABLE(CSS_FILTERS)
124     , m_filter(o.m_filter)
125 #endif
126     , m_grid(o.m_grid)
127     , m_gridItem(o.m_gridItem)
128     , m_content(o.m_content ? o.m_content->clone() : nullptr)
129     , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr)
130     , m_boxShadow(o.m_boxShadow ? adoptPtr(new ShadowData(*o.m_boxShadow)) : nullptr)
131     , m_boxReflect(o.m_boxReflect)
132     , m_animations(o.m_animations ? adoptPtr(new AnimationList(*o.m_animations)) : nullptr)
133     , m_transitions(o.m_transitions ? adoptPtr(new AnimationList(*o.m_transitions)) : nullptr)
134     , m_mask(o.m_mask)
135     , m_maskBoxImage(o.m_maskBoxImage)
136     , m_pageSize(o.m_pageSize)
137 #if ENABLE(CSS_SHAPES)
138     , m_shapeInside(o.m_shapeInside)
139     , m_shapeOutside(o.m_shapeOutside)
140     , m_shapeMargin(o.m_shapeMargin)
141     , m_shapePadding(o.m_shapePadding)
142     , m_shapeImageThreshold(o.m_shapeImageThreshold)
143 #endif
144     , m_clipPath(o.m_clipPath)
145 #if ENABLE(CSS3_TEXT_DECORATION)
146     , m_textDecorationColor(o.m_textDecorationColor)
147     , m_visitedLinkTextDecorationColor(o.m_visitedLinkTextDecorationColor)
148 #endif
149     , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor)
150     , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor)
151     , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor)
152     , m_visitedLinkBorderRightColor(o.m_visitedLinkBorderRightColor)
153     , m_visitedLinkBorderTopColor(o.m_visitedLinkBorderTopColor)
154     , m_visitedLinkBorderBottomColor(o.m_visitedLinkBorderBottomColor)
155     , m_order(o.m_order)
156     , m_flowThread(o.m_flowThread)
157     , m_regionThread(o.m_regionThread)
158     , m_regionFragment(o.m_regionFragment)
159     , m_regionBreakAfter(o.m_regionBreakAfter)
160     , m_regionBreakBefore(o.m_regionBreakBefore)
161     , m_regionBreakInside(o.m_regionBreakInside)
162     , m_pageSizeType(o.m_pageSizeType)
163     , m_transformStyle3D(o.m_transformStyle3D)
164     , m_backfaceVisibility(o.m_backfaceVisibility)
165     , m_alignContent(o.m_alignContent)
166     , m_alignItems(o.m_alignItems)
167     , m_alignSelf(o.m_alignSelf)
168     , m_justifyContent(o.m_justifyContent)
169     , userDrag(o.userDrag)
170     , textOverflow(o.textOverflow)
171     , marginBeforeCollapse(o.marginBeforeCollapse)
172     , marginAfterCollapse(o.marginAfterCollapse)
173     , m_appearance(o.m_appearance)
174     , m_borderFit(o.m_borderFit)
175     , m_textCombine(o.m_textCombine)
176 #if ENABLE(CSS3_TEXT_DECORATION)
177     , m_textDecorationStyle(o.m_textDecorationStyle)
178 #endif
179     , m_wrapFlow(o.m_wrapFlow)
180     , m_wrapThrough(o.m_wrapThrough)
181 #if USE(ACCELERATED_COMPOSITING)
182     , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
183 #endif
184     , m_hasAspectRatio(o.m_hasAspectRatio)
185 #if ENABLE(CSS_COMPOSITING)
186     , m_effectiveBlendMode(o.m_effectiveBlendMode)
187 #endif
188     , m_objectFit(o.m_objectFit)
189 {
190 }
191
192 StyleRareNonInheritedData::~StyleRareNonInheritedData()
193 {
194 }
195
196 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
197 {
198     return opacity == o.opacity
199         && m_aspectRatioDenominator == o.m_aspectRatioDenominator
200         && m_aspectRatioNumerator == o.m_aspectRatioNumerator
201         && m_perspective == o.m_perspective
202         && m_perspectiveOriginX == o.m_perspectiveOriginX
203         && m_perspectiveOriginY == o.m_perspectiveOriginY
204         && lineClamp == o.lineClamp
205 #if ENABLE(DASHBOARD_SUPPORT)
206         && m_dashboardRegions == o.m_dashboardRegions
207 #endif
208 #if ENABLE(DRAGGABLE_REGION)
209         && m_draggableRegionMode == o.m_draggableRegionMode
210 #endif
211         && m_deprecatedFlexibleBox == o.m_deprecatedFlexibleBox
212         && m_flexibleBox == o.m_flexibleBox
213         && m_marquee == o.m_marquee
214         && m_multiCol == o.m_multiCol
215         && m_transform == o.m_transform
216 #if ENABLE(CSS_FILTERS)
217         && m_filter == o.m_filter
218 #endif
219         && m_grid == o.m_grid
220         && m_gridItem == o.m_gridItem
221         && contentDataEquivalent(o)
222         && counterDataEquivalent(o)
223         && shadowDataEquivalent(o)
224         && reflectionDataEquivalent(o)
225         && animationDataEquivalent(o)
226         && transitionDataEquivalent(o)
227         && m_mask == o.m_mask
228         && m_maskBoxImage == o.m_maskBoxImage
229         && m_pageSize == o.m_pageSize
230 #if ENABLE(CSS_SHAPES)
231         && m_shapeInside == o.m_shapeInside
232         && m_shapeOutside == o.m_shapeOutside
233         && m_shapeMargin == o.m_shapeMargin
234         && m_shapePadding == o.m_shapePadding
235         && m_shapeImageThreshold == o.m_shapeImageThreshold
236 #endif
237         && m_clipPath == o.m_clipPath
238 #if ENABLE(CSS3_TEXT_DECORATION)
239         && m_textDecorationColor == o.m_textDecorationColor
240         && m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor
241 #endif
242         && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
243         && m_visitedLinkOutlineColor == o.m_visitedLinkOutlineColor
244         && m_visitedLinkBorderLeftColor == o.m_visitedLinkBorderLeftColor
245         && m_visitedLinkBorderRightColor == o.m_visitedLinkBorderRightColor
246         && m_visitedLinkBorderTopColor == o.m_visitedLinkBorderTopColor
247         && m_visitedLinkBorderBottomColor == o.m_visitedLinkBorderBottomColor
248         && m_order == o.m_order
249         && m_flowThread == o.m_flowThread
250         && m_regionThread == o.m_regionThread
251         && m_regionFragment == o.m_regionFragment
252         && m_regionBreakAfter == o.m_regionBreakAfter
253         && m_regionBreakBefore == o.m_regionBreakBefore
254         && m_regionBreakInside == o.m_regionBreakInside
255         && m_pageSizeType == o.m_pageSizeType
256         && m_transformStyle3D == o.m_transformStyle3D
257         && m_backfaceVisibility == o.m_backfaceVisibility
258         && m_alignContent == o.m_alignContent
259         && m_alignItems == o.m_alignItems
260         && m_alignSelf == o.m_alignSelf
261         && m_justifyContent == o.m_justifyContent
262         && userDrag == o.userDrag
263         && textOverflow == o.textOverflow
264         && marginBeforeCollapse == o.marginBeforeCollapse
265         && marginAfterCollapse == o.marginAfterCollapse
266         && m_appearance == o.m_appearance
267         && m_borderFit == o.m_borderFit
268         && m_textCombine == o.m_textCombine
269 #if ENABLE(CSS3_TEXT_DECORATION)
270         && m_textDecorationStyle == o.m_textDecorationStyle
271 #endif
272         && m_wrapFlow == o.m_wrapFlow
273         && m_wrapThrough == o.m_wrapThrough
274 #if USE(ACCELERATED_COMPOSITING)
275         && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
276 #endif
277 #if ENABLE(CSS_COMPOSITING)
278         && m_effectiveBlendMode == o.m_effectiveBlendMode
279 #endif
280         && m_hasAspectRatio == o.m_hasAspectRatio
281         && m_objectFit == o.m_objectFit;
282 }
283
284 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const
285 {
286     ContentData* a = m_content.get();
287     ContentData* b = o.m_content.get();
288
289     while (a && b && *a == *b) {
290         a = a->next();
291         b = b->next();
292     }
293
294     return !a && !b;
295 }
296
297 bool StyleRareNonInheritedData::counterDataEquivalent(const StyleRareNonInheritedData& o) const
298 {
299     if (m_counterDirectives.get() == o.m_counterDirectives.get())
300         return true;
301         
302     if (m_counterDirectives && o.m_counterDirectives && *m_counterDirectives == *o.m_counterDirectives)
303         return true;
304
305     return false;
306 }
307
308 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
309 {
310     if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow))
311         return false;
312     if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow))
313         return false;
314     return true;
315 }
316
317 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
318 {
319     if (m_boxReflect != o.m_boxReflect) {
320         if (!m_boxReflect || !o.m_boxReflect)
321             return false;
322         return *m_boxReflect == *o.m_boxReflect;
323     }
324     return true;
325 }
326
327 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
328 {
329     if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations))
330         return false;
331     if (m_animations && o.m_animations && (*m_animations != *o.m_animations))
332         return false;
333     return true;
334 }
335
336 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
337 {
338     if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions))
339         return false;
340     if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions))
341         return false;
342     return true;
343 }
344
345 bool StyleRareNonInheritedData::hasFilters() const
346 {
347 #if ENABLE(CSS_FILTERS)
348     return m_filter.get() && !m_filter->m_operations.isEmpty();
349 #else
350     return false;
351 #endif
352 }
353
354 } // namespace WebCore