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 "CSSStyleSelector.h"
26 #include "ContentData.h"
27 #include "RenderCounter.h"
28 #include "RenderStyle.h"
29 #include "ShadowData.h"
30 #include "StyleImage.h"
31
32 namespace WebCore {
33
StyleRareNonInheritedData()34 StyleRareNonInheritedData::StyleRareNonInheritedData()
35 : lineClamp(RenderStyle::initialLineClamp())
36 , opacity(RenderStyle::initialOpacity())
37 , userDrag(RenderStyle::initialUserDrag())
38 , textOverflow(RenderStyle::initialTextOverflow())
39 , marginBeforeCollapse(MCOLLAPSE)
40 , marginAfterCollapse(MCOLLAPSE)
41 , matchNearestMailBlockquoteColor(RenderStyle::initialMatchNearestMailBlockquoteColor())
42 , m_appearance(RenderStyle::initialAppearance())
43 , m_borderFit(RenderStyle::initialBorderFit())
44 , m_textCombine(RenderStyle::initialTextCombine())
45 , m_counterIncrement(0)
46 , m_counterReset(0)
47 #if USE(ACCELERATED_COMPOSITING)
48 , m_runningAcceleratedAnimation(false)
49 #endif
50 , m_mask(FillLayer(MaskFillLayer))
51 , m_transformStyle3D(RenderStyle::initialTransformStyle3D())
52 , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility())
53 , m_perspective(RenderStyle::initialPerspective())
54 , m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX())
55 , m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY())
56 , m_pageSize()
57 , m_pageSizeType(PAGE_SIZE_AUTO)
58 {
59 }
60
StyleRareNonInheritedData(const StyleRareNonInheritedData & o)61 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
62 : RefCounted<StyleRareNonInheritedData>()
63 , lineClamp(o.lineClamp)
64 , opacity(o.opacity)
65 , flexibleBox(o.flexibleBox)
66 , marquee(o.marquee)
67 , m_multiCol(o.m_multiCol)
68 , m_transform(o.m_transform)
69 , userDrag(o.userDrag)
70 , textOverflow(o.textOverflow)
71 , marginBeforeCollapse(o.marginBeforeCollapse)
72 , marginAfterCollapse(o.marginAfterCollapse)
73 , matchNearestMailBlockquoteColor(o.matchNearestMailBlockquoteColor)
74 , m_appearance(o.m_appearance)
75 , m_borderFit(o.m_borderFit)
76 , m_textCombine(o.m_textCombine)
77 , m_counterIncrement(o.m_counterIncrement)
78 , m_counterReset(o.m_counterReset)
79 #if USE(ACCELERATED_COMPOSITING)
80 , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
81 #endif
82 , m_boxShadow(o.m_boxShadow ? adoptPtr(new ShadowData(*o.m_boxShadow)) : nullptr)
83 , m_boxReflect(o.m_boxReflect)
84 , m_animations(o.m_animations ? adoptPtr(new AnimationList(*o.m_animations)) : nullptr)
85 , m_transitions(o.m_transitions ? adoptPtr(new AnimationList(*o.m_transitions)) : nullptr)
86 , m_mask(o.m_mask)
87 , m_maskBoxImage(o.m_maskBoxImage)
88 , m_transformStyle3D(o.m_transformStyle3D)
89 , m_backfaceVisibility(o.m_backfaceVisibility)
90 , m_perspective(o.m_perspective)
91 , m_perspectiveOriginX(o.m_perspectiveOriginX)
92 , m_perspectiveOriginY(o.m_perspectiveOriginY)
93 , m_pageSize(o.m_pageSize)
94 , m_pageSizeType(o.m_pageSizeType)
95 {
96 }
97
~StyleRareNonInheritedData()98 StyleRareNonInheritedData::~StyleRareNonInheritedData()
99 {
100 }
101
operator ==(const StyleRareNonInheritedData & o) const102 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
103 {
104 return lineClamp == o.lineClamp
105 #if ENABLE(DASHBOARD_SUPPORT)
106 && m_dashboardRegions == o.m_dashboardRegions
107 #endif
108 && opacity == o.opacity
109 && flexibleBox == o.flexibleBox
110 && marquee == o.marquee
111 && m_multiCol == o.m_multiCol
112 && m_transform == o.m_transform
113 && contentDataEquivalent(o)
114 && m_counterDirectives == o.m_counterDirectives
115 && userDrag == o.userDrag
116 && textOverflow == o.textOverflow
117 && marginBeforeCollapse == o.marginBeforeCollapse
118 && marginAfterCollapse == o.marginAfterCollapse
119 && matchNearestMailBlockquoteColor == o.matchNearestMailBlockquoteColor
120 && m_appearance == o.m_appearance
121 && m_borderFit == o.m_borderFit
122 && m_textCombine == o.m_textCombine
123 && m_counterIncrement == o.m_counterIncrement
124 && m_counterReset == o.m_counterReset
125 #if USE(ACCELERATED_COMPOSITING)
126 && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
127 #endif
128 && shadowDataEquivalent(o)
129 && reflectionDataEquivalent(o)
130 && animationDataEquivalent(o)
131 && transitionDataEquivalent(o)
132 && m_mask == o.m_mask
133 && m_maskBoxImage == o.m_maskBoxImage
134 && (m_transformStyle3D == o.m_transformStyle3D)
135 && (m_backfaceVisibility == o.m_backfaceVisibility)
136 && (m_perspective == o.m_perspective)
137 && (m_perspectiveOriginX == o.m_perspectiveOriginX)
138 && (m_perspectiveOriginY == o.m_perspectiveOriginY)
139 && (m_pageSize == o.m_pageSize)
140 && (m_pageSizeType == o.m_pageSizeType)
141 ;
142 }
143
contentDataEquivalent(const StyleRareNonInheritedData & o) const144 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const
145 {
146 ContentData* c1 = m_content.get();
147 ContentData* c2 = o.m_content.get();
148
149 while (c1 && c2) {
150 if (!c1->dataEquivalent(*c2))
151 return false;
152 c1 = c1->next();
153 c2 = c2->next();
154 }
155
156 return !c1 && !c2;
157 }
158
shadowDataEquivalent(const StyleRareNonInheritedData & o) const159 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
160 {
161 if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow))
162 return false;
163 if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow))
164 return false;
165 return true;
166 }
167
reflectionDataEquivalent(const StyleRareNonInheritedData & o) const168 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
169 {
170 if (m_boxReflect != o.m_boxReflect) {
171 if (!m_boxReflect || !o.m_boxReflect)
172 return false;
173 return *m_boxReflect == *o.m_boxReflect;
174 }
175 return true;
176
177 }
178
animationDataEquivalent(const StyleRareNonInheritedData & o) const179 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
180 {
181 if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations))
182 return false;
183 if (m_animations && o.m_animations && (*m_animations != *o.m_animations))
184 return false;
185 return true;
186 }
187
transitionDataEquivalent(const StyleRareNonInheritedData & o) const188 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
189 {
190 if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions))
191 return false;
192 if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions))
193 return false;
194 return true;
195 }
196
197 } // namespace WebCore
198