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