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 "RenderStyle.h"
27
28 namespace WebCore {
29
StyleRareNonInheritedData()30 StyleRareNonInheritedData::StyleRareNonInheritedData()
31 : lineClamp(RenderStyle::initialLineClamp())
32 , opacity(RenderStyle::initialOpacity())
33 , m_content(0)
34 , m_counterDirectives(0)
35 , userDrag(RenderStyle::initialUserDrag())
36 , textOverflow(RenderStyle::initialTextOverflow())
37 , marginTopCollapse(MCOLLAPSE)
38 , marginBottomCollapse(MCOLLAPSE)
39 , matchNearestMailBlockquoteColor(RenderStyle::initialMatchNearestMailBlockquoteColor())
40 , m_appearance(RenderStyle::initialAppearance())
41 , m_borderFit(RenderStyle::initialBorderFit())
42 , m_boxShadow(0)
43 , m_animations(0)
44 , m_transitions(0)
45 , m_mask(FillLayer(MaskFillLayer))
46 #if ENABLE(XBL)
47 , bindingURI(0)
48 #endif
49 {
50 }
51
StyleRareNonInheritedData(const StyleRareNonInheritedData & o)52 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
53 : RefCounted<StyleRareNonInheritedData>()
54 , lineClamp(o.lineClamp)
55 , opacity(o.opacity)
56 , flexibleBox(o.flexibleBox)
57 , marquee(o.marquee)
58 , m_multiCol(o.m_multiCol)
59 , m_transform(o.m_transform)
60 , m_content(0)
61 , m_counterDirectives(0)
62 , userDrag(o.userDrag)
63 , textOverflow(o.textOverflow)
64 , marginTopCollapse(o.marginTopCollapse)
65 , marginBottomCollapse(o.marginBottomCollapse)
66 , matchNearestMailBlockquoteColor(o.matchNearestMailBlockquoteColor)
67 , m_appearance(o.m_appearance)
68 , m_borderFit(o.m_borderFit)
69 , m_boxShadow(o.m_boxShadow ? new ShadowData(*o.m_boxShadow) : 0)
70 , m_boxReflect(o.m_boxReflect)
71 , m_animations(o.m_animations ? new AnimationList(*o.m_animations) : 0)
72 , m_transitions(o.m_transitions ? new AnimationList(*o.m_transitions) : 0)
73 , m_mask(o.m_mask)
74 , m_maskBoxImage(o.m_maskBoxImage)
75 #if ENABLE(XBL)
76 , bindingURI(o.bindingURI ? o.bindingURI->copy() : 0)
77 #endif
78 {
79 }
80
~StyleRareNonInheritedData()81 StyleRareNonInheritedData::~StyleRareNonInheritedData()
82 {
83 }
84
85 #if ENABLE(XBL)
bindingsEquivalent(const StyleRareNonInheritedData & o) const86 bool StyleRareNonInheritedData::bindingsEquivalent(const StyleRareNonInheritedData& o) const
87 {
88 if (this == &o) return true;
89 if (!bindingURI && o.bindingURI || bindingURI && !o.bindingURI)
90 return false;
91 if (bindingURI && o.bindingURI && (*bindingURI != *o.bindingURI))
92 return false;
93 return true;
94 }
95 #endif
96
operator ==(const StyleRareNonInheritedData & o) const97 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const
98 {
99 return lineClamp == o.lineClamp
100 #if ENABLE(DASHBOARD_SUPPORT)
101 && m_dashboardRegions == o.m_dashboardRegions
102 #endif
103 && opacity == o.opacity
104 && flexibleBox == o.flexibleBox
105 && marquee == o.marquee
106 && m_multiCol == o.m_multiCol
107 && m_transform == o.m_transform
108 && m_content == o.m_content
109 && m_counterDirectives == o.m_counterDirectives
110 && userDrag == o.userDrag
111 && textOverflow == o.textOverflow
112 && marginTopCollapse == o.marginTopCollapse
113 && marginBottomCollapse == o.marginBottomCollapse
114 && matchNearestMailBlockquoteColor == o.matchNearestMailBlockquoteColor
115 && m_appearance == o.m_appearance
116 && m_borderFit == o.m_borderFit
117 && shadowDataEquivalent(o)
118 && reflectionDataEquivalent(o)
119 && animationDataEquivalent(o)
120 && transitionDataEquivalent(o)
121 && m_mask == o.m_mask
122 && m_maskBoxImage == o.m_maskBoxImage
123 #if ENABLE(XBL)
124 && bindingsEquivalent(o)
125 #endif
126 ;
127 }
128
shadowDataEquivalent(const StyleRareNonInheritedData & o) const129 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
130 {
131 if (!m_boxShadow && o.m_boxShadow || m_boxShadow && !o.m_boxShadow)
132 return false;
133 if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow))
134 return false;
135 return true;
136 }
137
reflectionDataEquivalent(const StyleRareNonInheritedData & o) const138 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
139 {
140 if (m_boxReflect != o.m_boxReflect) {
141 if (!m_boxReflect || !o.m_boxReflect)
142 return false;
143 return *m_boxReflect == *o.m_boxReflect;
144 }
145 return true;
146
147 }
148
animationDataEquivalent(const StyleRareNonInheritedData & o) const149 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
150 {
151 if (!m_animations && o.m_animations || m_animations && !o.m_animations)
152 return false;
153 if (m_animations && o.m_animations && (*m_animations != *o.m_animations))
154 return false;
155 return true;
156 }
157
transitionDataEquivalent(const StyleRareNonInheritedData & o) const158 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
159 {
160 if (!m_transitions && o.m_transitions || m_transitions && !o.m_transitions)
161 return false;
162 if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions))
163 return false;
164 return true;
165 }
166
167 } // namespace WebCore
168