OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) | 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) |
4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. | 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "config.h" | 22 #include "config.h" |
23 #include "core/css/StyleRule.h" | 23 #include "core/css/StyleRule.h" |
24 | 24 |
| 25 #include "RuntimeEnabledFeatures.h" |
25 #include "core/css/CSSCharsetRule.h" | 26 #include "core/css/CSSCharsetRule.h" |
26 #include "core/css/CSSFontFaceRule.h" | 27 #include "core/css/CSSFontFaceRule.h" |
27 #include "core/css/CSSHostRule.h" | 28 #include "core/css/CSSHostRule.h" |
28 #include "core/css/CSSImportRule.h" | 29 #include "core/css/CSSImportRule.h" |
29 #include "core/css/CSSMediaRule.h" | 30 #include "core/css/CSSMediaRule.h" |
30 #include "core/css/CSSPageRule.h" | 31 #include "core/css/CSSPageRule.h" |
31 #include "core/css/CSSStyleRule.h" | 32 #include "core/css/CSSStyleRule.h" |
32 #include "core/css/CSSSupportsRule.h" | 33 #include "core/css/CSSSupportsRule.h" |
33 #include "core/css/CSSUnknownRule.h" | 34 #include "core/css/CSSUnknownRule.h" |
34 #include "core/css/StylePropertySet.h" | 35 #include "core/css/StylePropertySet.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return; | 68 return; |
68 case Page: | 69 case Page: |
69 static_cast<const StyleRulePage*>(this)->reportDescendantMemoryUsage(mem
oryObjectInfo); | 70 static_cast<const StyleRulePage*>(this)->reportDescendantMemoryUsage(mem
oryObjectInfo); |
70 return; | 71 return; |
71 case FontFace: | 72 case FontFace: |
72 static_cast<const StyleRuleFontFace*>(this)->reportDescendantMemoryUsage
(memoryObjectInfo); | 73 static_cast<const StyleRuleFontFace*>(this)->reportDescendantMemoryUsage
(memoryObjectInfo); |
73 return; | 74 return; |
74 case Media: | 75 case Media: |
75 static_cast<const StyleRuleMedia*>(this)->reportDescendantMemoryUsage(me
moryObjectInfo); | 76 static_cast<const StyleRuleMedia*>(this)->reportDescendantMemoryUsage(me
moryObjectInfo); |
76 return; | 77 return; |
77 #if ENABLE(CSS_REGIONS) | |
78 case Region: | 78 case Region: |
79 static_cast<const StyleRuleRegion*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); | 79 static_cast<const StyleRuleRegion*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); |
80 return; | 80 return; |
81 #endif | |
82 case Import: | 81 case Import: |
83 static_cast<const StyleRuleImport*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); | 82 static_cast<const StyleRuleImport*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); |
84 return; | 83 return; |
85 case Keyframes: | 84 case Keyframes: |
86 static_cast<const StyleRuleKeyframes*>(this)->reportDescendantMemoryUsag
e(memoryObjectInfo); | 85 static_cast<const StyleRuleKeyframes*>(this)->reportDescendantMemoryUsag
e(memoryObjectInfo); |
87 return; | 86 return; |
88 case Supports: | 87 case Supports: |
89 case HostInternal: | 88 case HostInternal: |
90 static_cast<const StyleRuleHost*>(this)->reportDescendantMemoryUsage(mem
oryObjectInfo); | 89 static_cast<const StyleRuleHost*>(this)->reportDescendantMemoryUsage(mem
oryObjectInfo); |
91 return; | 90 return; |
92 #if ENABLE(CSS_DEVICE_ADAPTATION) | 91 #if ENABLE(CSS_DEVICE_ADAPTATION) |
93 case Viewport: | 92 case Viewport: |
94 static_cast<const StyleRuleViewport*>(this)->reportDescendantMemoryUsage
(memoryObjectInfo); | 93 static_cast<const StyleRuleViewport*>(this)->reportDescendantMemoryUsage
(memoryObjectInfo); |
95 return; | 94 return; |
96 #endif | 95 #endif |
97 case Filter: | 96 case Filter: |
98 static_cast<const StyleRuleFilter*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); | 97 static_cast<const StyleRuleFilter*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); |
99 return; | 98 return; |
100 case Unknown: | 99 case Unknown: |
101 case Charset: | 100 case Charset: |
102 case Keyframe: | 101 case Keyframe: |
103 #if !ENABLE(CSS_REGIONS) | |
104 case Region: | |
105 #endif | |
106 ASSERT_NOT_REACHED(); | 102 ASSERT_NOT_REACHED(); |
107 return; | 103 return; |
108 } | 104 } |
109 ASSERT_NOT_REACHED(); | 105 ASSERT_NOT_REACHED(); |
110 } | 106 } |
111 | 107 |
112 void StyleRuleBase::destroy() | 108 void StyleRuleBase::destroy() |
113 { | 109 { |
114 switch (type()) { | 110 switch (type()) { |
115 case Style: | 111 case Style: |
116 delete static_cast<StyleRule*>(this); | 112 delete static_cast<StyleRule*>(this); |
117 return; | 113 return; |
118 case Page: | 114 case Page: |
119 delete static_cast<StyleRulePage*>(this); | 115 delete static_cast<StyleRulePage*>(this); |
120 return; | 116 return; |
121 case FontFace: | 117 case FontFace: |
122 delete static_cast<StyleRuleFontFace*>(this); | 118 delete static_cast<StyleRuleFontFace*>(this); |
123 return; | 119 return; |
124 case Media: | 120 case Media: |
125 delete static_cast<StyleRuleMedia*>(this); | 121 delete static_cast<StyleRuleMedia*>(this); |
126 return; | 122 return; |
127 case Supports: | 123 case Supports: |
128 delete static_cast<StyleRuleSupports*>(this); | 124 delete static_cast<StyleRuleSupports*>(this); |
129 return; | 125 return; |
130 #if ENABLE(CSS_REGIONS) | |
131 case Region: | 126 case Region: |
132 delete static_cast<StyleRuleRegion*>(this); | 127 delete static_cast<StyleRuleRegion*>(this); |
133 return; | 128 return; |
134 #endif | |
135 case Import: | 129 case Import: |
136 delete static_cast<StyleRuleImport*>(this); | 130 delete static_cast<StyleRuleImport*>(this); |
137 return; | 131 return; |
138 case Keyframes: | 132 case Keyframes: |
139 delete static_cast<StyleRuleKeyframes*>(this); | 133 delete static_cast<StyleRuleKeyframes*>(this); |
140 return; | 134 return; |
141 case HostInternal: | 135 case HostInternal: |
142 delete static_cast<StyleRuleHost*>(this); | 136 delete static_cast<StyleRuleHost*>(this); |
143 return; | 137 return; |
144 #if ENABLE(CSS_DEVICE_ADAPTATION) | 138 #if ENABLE(CSS_DEVICE_ADAPTATION) |
145 case Viewport: | 139 case Viewport: |
146 delete static_cast<StyleRuleViewport*>(this); | 140 delete static_cast<StyleRuleViewport*>(this); |
147 return; | 141 return; |
148 #endif | 142 #endif |
149 case Filter: | 143 case Filter: |
150 delete static_cast<StyleRuleFilter*>(this); | 144 delete static_cast<StyleRuleFilter*>(this); |
151 return; | 145 return; |
152 case Unknown: | 146 case Unknown: |
153 case Charset: | 147 case Charset: |
154 case Keyframe: | 148 case Keyframe: |
155 #if !ENABLE(CSS_REGIONS) | |
156 case Region: | |
157 #endif | |
158 ASSERT_NOT_REACHED(); | 149 ASSERT_NOT_REACHED(); |
159 return; | 150 return; |
160 } | 151 } |
161 ASSERT_NOT_REACHED(); | 152 ASSERT_NOT_REACHED(); |
162 } | 153 } |
163 | 154 |
164 PassRefPtr<StyleRuleBase> StyleRuleBase::copy() const | 155 PassRefPtr<StyleRuleBase> StyleRuleBase::copy() const |
165 { | 156 { |
166 switch (type()) { | 157 switch (type()) { |
167 case Style: | 158 case Style: |
168 return static_cast<const StyleRule*>(this)->copy(); | 159 return static_cast<const StyleRule*>(this)->copy(); |
169 case Page: | 160 case Page: |
170 return static_cast<const StyleRulePage*>(this)->copy(); | 161 return static_cast<const StyleRulePage*>(this)->copy(); |
171 case FontFace: | 162 case FontFace: |
172 return static_cast<const StyleRuleFontFace*>(this)->copy(); | 163 return static_cast<const StyleRuleFontFace*>(this)->copy(); |
173 case Media: | 164 case Media: |
174 return static_cast<const StyleRuleMedia*>(this)->copy(); | 165 return static_cast<const StyleRuleMedia*>(this)->copy(); |
175 case Supports: | 166 case Supports: |
176 return static_cast<const StyleRuleSupports*>(this)->copy(); | 167 return static_cast<const StyleRuleSupports*>(this)->copy(); |
177 #if ENABLE(CSS_REGIONS) | |
178 case Region: | 168 case Region: |
179 return static_cast<const StyleRuleRegion*>(this)->copy(); | 169 return static_cast<const StyleRuleRegion*>(this)->copy(); |
180 #endif | |
181 case Import: | 170 case Import: |
182 // FIXME: Copy import rules. | 171 // FIXME: Copy import rules. |
183 ASSERT_NOT_REACHED(); | 172 ASSERT_NOT_REACHED(); |
184 return 0; | 173 return 0; |
185 case Keyframes: | 174 case Keyframes: |
186 return static_cast<const StyleRuleKeyframes*>(this)->copy(); | 175 return static_cast<const StyleRuleKeyframes*>(this)->copy(); |
187 case HostInternal: | 176 case HostInternal: |
188 return static_cast<const StyleRuleHost*>(this)->copy(); | 177 return static_cast<const StyleRuleHost*>(this)->copy(); |
189 #if ENABLE(CSS_DEVICE_ADAPTATION) | 178 #if ENABLE(CSS_DEVICE_ADAPTATION) |
190 case Viewport: | 179 case Viewport: |
191 return static_cast<const StyleRuleViewport*>(this)->copy(); | 180 return static_cast<const StyleRuleViewport*>(this)->copy(); |
192 #endif | 181 #endif |
193 case Filter: | 182 case Filter: |
194 return static_cast<const StyleRuleFilter*>(this)->copy(); | 183 return static_cast<const StyleRuleFilter*>(this)->copy(); |
195 case Unknown: | 184 case Unknown: |
196 case Charset: | 185 case Charset: |
197 case Keyframe: | 186 case Keyframe: |
198 #if !ENABLE(CSS_REGIONS) | |
199 case Region: | |
200 #endif | |
201 ASSERT_NOT_REACHED(); | 187 ASSERT_NOT_REACHED(); |
202 return 0; | 188 return 0; |
203 } | 189 } |
204 ASSERT_NOT_REACHED(); | 190 ASSERT_NOT_REACHED(); |
205 return 0; | 191 return 0; |
206 } | 192 } |
207 | 193 |
208 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
, CSSRule* parentRule) const | 194 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
, CSSRule* parentRule) const |
209 { | 195 { |
210 RefPtr<CSSRule> rule; | 196 RefPtr<CSSRule> rule; |
211 StyleRuleBase* self = const_cast<StyleRuleBase*>(this); | 197 StyleRuleBase* self = const_cast<StyleRuleBase*>(this); |
212 switch (type()) { | 198 switch (type()) { |
213 case Style: | 199 case Style: |
214 rule = CSSStyleRule::create(static_cast<StyleRule*>(self), parentSheet); | 200 rule = CSSStyleRule::create(static_cast<StyleRule*>(self), parentSheet); |
215 break; | 201 break; |
216 case Page: | 202 case Page: |
217 rule = CSSPageRule::create(static_cast<StyleRulePage*>(self), parentShee
t); | 203 rule = CSSPageRule::create(static_cast<StyleRulePage*>(self), parentShee
t); |
218 break; | 204 break; |
219 case FontFace: | 205 case FontFace: |
220 rule = CSSFontFaceRule::create(static_cast<StyleRuleFontFace*>(self), pa
rentSheet); | 206 rule = CSSFontFaceRule::create(static_cast<StyleRuleFontFace*>(self), pa
rentSheet); |
221 break; | 207 break; |
222 case Media: | 208 case Media: |
223 rule = CSSMediaRule::create(static_cast<StyleRuleMedia*>(self), parentSh
eet); | 209 rule = CSSMediaRule::create(static_cast<StyleRuleMedia*>(self), parentSh
eet); |
224 break; | 210 break; |
225 case Supports: | 211 case Supports: |
226 rule = CSSSupportsRule::create(static_cast<StyleRuleSupports*>(self), pa
rentSheet); | 212 rule = CSSSupportsRule::create(static_cast<StyleRuleSupports*>(self), pa
rentSheet); |
227 break; | 213 break; |
228 #if ENABLE(CSS_REGIONS) | |
229 case Region: | 214 case Region: |
230 rule = WebKitCSSRegionRule::create(static_cast<StyleRuleRegion*>(self),
parentSheet); | 215 rule = WebKitCSSRegionRule::create(static_cast<StyleRuleRegion*>(self),
parentSheet); |
231 break; | 216 break; |
232 #endif | |
233 case Import: | 217 case Import: |
234 rule = CSSImportRule::create(static_cast<StyleRuleImport*>(self), parent
Sheet); | 218 rule = CSSImportRule::create(static_cast<StyleRuleImport*>(self), parent
Sheet); |
235 break; | 219 break; |
236 case Keyframes: | 220 case Keyframes: |
237 rule = WebKitCSSKeyframesRule::create(static_cast<StyleRuleKeyframes*>(s
elf), parentSheet); | 221 rule = WebKitCSSKeyframesRule::create(static_cast<StyleRuleKeyframes*>(s
elf), parentSheet); |
238 break; | 222 break; |
239 #if ENABLE(CSS_DEVICE_ADAPTATION) | 223 #if ENABLE(CSS_DEVICE_ADAPTATION) |
240 case Viewport: | 224 case Viewport: |
241 rule = WebKitCSSViewportRule::create(static_cast<StyleRuleViewport*>(sel
f), parentSheet); | 225 rule = WebKitCSSViewportRule::create(static_cast<StyleRuleViewport*>(sel
f), parentSheet); |
242 break; | 226 break; |
243 #endif | 227 #endif |
244 case HostInternal: | 228 case HostInternal: |
245 rule = CSSHostRule::create(static_cast<StyleRuleHost*>(self), parentShee
t); | 229 rule = CSSHostRule::create(static_cast<StyleRuleHost*>(self), parentShee
t); |
246 break; | 230 break; |
247 case Filter: | 231 case Filter: |
248 rule = WebKitCSSFilterRule::create(static_cast<StyleRuleFilter*>(self),
parentSheet); | 232 rule = WebKitCSSFilterRule::create(static_cast<StyleRuleFilter*>(self),
parentSheet); |
249 break; | 233 break; |
250 case Unknown: | 234 case Unknown: |
251 case Charset: | 235 case Charset: |
252 case Keyframe: | 236 case Keyframe: |
253 #if !ENABLE(CSS_REGIONS) | |
254 case Region: | |
255 #endif | |
256 ASSERT_NOT_REACHED(); | 237 ASSERT_NOT_REACHED(); |
257 return 0; | 238 return 0; |
258 } | 239 } |
259 if (parentRule) | 240 if (parentRule) |
260 rule->setParentRule(parentRule); | 241 rule->setParentRule(parentRule); |
261 return rule.release(); | 242 return rule.release(); |
262 } | 243 } |
263 | 244 |
264 unsigned StyleRule::averageSizeInBytes() | 245 unsigned StyleRule::averageSizeInBytes() |
265 { | 246 { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) | 411 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) |
431 : StyleRuleGroup(o) | 412 : StyleRuleGroup(o) |
432 , m_conditionText(o.m_conditionText) | 413 , m_conditionText(o.m_conditionText) |
433 , m_conditionIsSupported(o.m_conditionIsSupported) | 414 , m_conditionIsSupported(o.m_conditionIsSupported) |
434 { | 415 { |
435 } | 416 } |
436 | 417 |
437 StyleRuleRegion::StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >* selectors,
Vector<RefPtr<StyleRuleBase> >& adoptRules) | 418 StyleRuleRegion::StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >* selectors,
Vector<RefPtr<StyleRuleBase> >& adoptRules) |
438 : StyleRuleGroup(Region, adoptRules) | 419 : StyleRuleGroup(Region, adoptRules) |
439 { | 420 { |
| 421 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); |
440 m_selectorList.adoptSelectorVector(*selectors); | 422 m_selectorList.adoptSelectorVector(*selectors); |
441 } | 423 } |
442 | 424 |
443 StyleRuleRegion::StyleRuleRegion(const StyleRuleRegion& o) | 425 StyleRuleRegion::StyleRuleRegion(const StyleRuleRegion& o) |
444 : StyleRuleGroup(o) | 426 : StyleRuleGroup(o) |
445 , m_selectorList(o.m_selectorList) | 427 , m_selectorList(o.m_selectorList) |
446 { | 428 { |
| 429 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); |
447 } | 430 } |
448 | 431 |
449 void StyleRuleRegion::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObject
Info) const | 432 void StyleRuleRegion::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObject
Info) const |
450 { | 433 { |
451 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | 434 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); |
452 info.addMember(m_selectorList, "selectorList"); | 435 info.addMember(m_selectorList, "selectorList"); |
453 } | 436 } |
454 | 437 |
455 #if ENABLE(CSS_DEVICE_ADAPTATION) | 438 #if ENABLE(CSS_DEVICE_ADAPTATION) |
456 StyleRuleViewport::StyleRuleViewport() | 439 StyleRuleViewport::StyleRuleViewport() |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 } | 500 } |
518 | 501 |
519 void StyleRuleFilter::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObject
Info) const | 502 void StyleRuleFilter::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObject
Info) const |
520 { | 503 { |
521 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | 504 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); |
522 info.addMember(m_filterName); | 505 info.addMember(m_filterName); |
523 info.addMember(m_properties); | 506 info.addMember(m_properties); |
524 } | 507 } |
525 | 508 |
526 } // namespace WebCore | 509 } // namespace WebCore |
OLD | NEW |