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 * |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "CSSFontFaceRule.h" | 26 #include "CSSFontFaceRule.h" |
27 #include "CSSHostRule.h" | 27 #include "CSSHostRule.h" |
28 #include "CSSImportRule.h" | 28 #include "CSSImportRule.h" |
29 #include "CSSMediaRule.h" | 29 #include "CSSMediaRule.h" |
30 #include "CSSPageRule.h" | 30 #include "CSSPageRule.h" |
31 #include "CSSStyleRule.h" | 31 #include "CSSStyleRule.h" |
32 #include "CSSSupportsRule.h" | 32 #include "CSSSupportsRule.h" |
33 #include "CSSUnknownRule.h" | 33 #include "CSSUnknownRule.h" |
34 #include "StylePropertySet.h" | 34 #include "StylePropertySet.h" |
35 #include "StyleRuleImport.h" | 35 #include "StyleRuleImport.h" |
36 #include "WebCoreMemoryInstrumentation.h" | |
37 #include "WebKitCSSFilterRule.h" | 36 #include "WebKitCSSFilterRule.h" |
38 #include "WebKitCSSKeyframeRule.h" | 37 #include "WebKitCSSKeyframeRule.h" |
39 #include "WebKitCSSKeyframesRule.h" | 38 #include "WebKitCSSKeyframesRule.h" |
40 #include "WebKitCSSRegionRule.h" | 39 #include "WebKitCSSRegionRule.h" |
41 #include "WebKitCSSViewportRule.h" | 40 #include "WebKitCSSViewportRule.h" |
42 #include <wtf/MemoryInstrumentationVector.h> | |
43 | 41 |
44 namespace WebCore { | 42 namespace WebCore { |
45 | 43 |
46 struct SameSizeAsStyleRuleBase : public WTF::RefCountedBase { | 44 struct SameSizeAsStyleRuleBase : public WTF::RefCountedBase { |
47 unsigned bitfields; | 45 unsigned bitfields; |
48 }; | 46 }; |
49 | 47 |
50 COMPILE_ASSERT(sizeof(StyleRuleBase) == sizeof(SameSizeAsStyleRuleBase), StyleRu
leBase_should_stay_small); | 48 COMPILE_ASSERT(sizeof(StyleRuleBase) == sizeof(SameSizeAsStyleRuleBase), StyleRu
leBase_should_stay_small); |
51 | 49 |
52 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
) const | 50 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
) const |
53 { | 51 { |
54 return createCSSOMWrapper(parentSheet, 0); | 52 return createCSSOMWrapper(parentSheet, 0); |
55 } | 53 } |
56 | 54 |
57 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const | 55 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const |
58 { | 56 { |
59 return createCSSOMWrapper(0, parentRule); | 57 return createCSSOMWrapper(0, parentRule); |
60 } | 58 } |
61 | 59 |
62 void StyleRuleBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | |
63 { | |
64 switch (type()) { | |
65 case Style: | |
66 static_cast<const StyleRule*>(this)->reportDescendantMemoryUsage(memoryO
bjectInfo); | |
67 return; | |
68 case Page: | |
69 static_cast<const StyleRulePage*>(this)->reportDescendantMemoryUsage(mem
oryObjectInfo); | |
70 return; | |
71 case FontFace: | |
72 static_cast<const StyleRuleFontFace*>(this)->reportDescendantMemoryUsage
(memoryObjectInfo); | |
73 return; | |
74 case Media: | |
75 static_cast<const StyleRuleMedia*>(this)->reportDescendantMemoryUsage(me
moryObjectInfo); | |
76 return; | |
77 #if ENABLE(CSS_REGIONS) | |
78 case Region: | |
79 static_cast<const StyleRuleRegion*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); | |
80 return; | |
81 #endif | |
82 case Import: | |
83 static_cast<const StyleRuleImport*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); | |
84 return; | |
85 case Keyframes: | |
86 static_cast<const StyleRuleKeyframes*>(this)->reportDescendantMemoryUsag
e(memoryObjectInfo); | |
87 return; | |
88 case Supports: | |
89 case HostInternal: | |
90 static_cast<const StyleRuleHost*>(this)->reportDescendantMemoryUsage(mem
oryObjectInfo); | |
91 return; | |
92 #if ENABLE(CSS_DEVICE_ADAPTATION) | |
93 case Viewport: | |
94 static_cast<const StyleRuleViewport*>(this)->reportDescendantMemoryUsage
(memoryObjectInfo); | |
95 return; | |
96 #endif | |
97 case Filter: | |
98 static_cast<const StyleRuleFilter*>(this)->reportDescendantMemoryUsage(m
emoryObjectInfo); | |
99 return; | |
100 case Unknown: | |
101 case Charset: | |
102 case Keyframe: | |
103 #if !ENABLE(CSS_REGIONS) | |
104 case Region: | |
105 #endif | |
106 ASSERT_NOT_REACHED(); | |
107 return; | |
108 } | |
109 ASSERT_NOT_REACHED(); | |
110 } | |
111 | |
112 void StyleRuleBase::destroy() | 60 void StyleRuleBase::destroy() |
113 { | 61 { |
114 switch (type()) { | 62 switch (type()) { |
115 case Style: | 63 case Style: |
116 delete static_cast<StyleRule*>(this); | 64 delete static_cast<StyleRule*>(this); |
117 return; | 65 return; |
118 case Page: | 66 case Page: |
119 delete static_cast<StyleRulePage*>(this); | 67 delete static_cast<StyleRulePage*>(this); |
120 return; | 68 return; |
121 case FontFace: | 69 case FontFace: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 if (parentRule) | 207 if (parentRule) |
260 rule->setParentRule(parentRule); | 208 rule->setParentRule(parentRule); |
261 return rule.release(); | 209 return rule.release(); |
262 } | 210 } |
263 | 211 |
264 unsigned StyleRule::averageSizeInBytes() | 212 unsigned StyleRule::averageSizeInBytes() |
265 { | 213 { |
266 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); | 214 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); |
267 } | 215 } |
268 | 216 |
269 void StyleRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
const | |
270 { | |
271 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
272 info.addMember(m_properties, "properties"); | |
273 info.addMember(m_selectorList, "selectorList"); | |
274 } | |
275 | |
276 StyleRule::StyleRule(int sourceLine) | 217 StyleRule::StyleRule(int sourceLine) |
277 : StyleRuleBase(Style, sourceLine) | 218 : StyleRuleBase(Style, sourceLine) |
278 { | 219 { |
279 } | 220 } |
280 | 221 |
281 StyleRule::StyleRule(const StyleRule& o) | 222 StyleRule::StyleRule(const StyleRule& o) |
282 : StyleRuleBase(o) | 223 : StyleRuleBase(o) |
283 , m_properties(o.m_properties->copy()) | 224 , m_properties(o.m_properties->copy()) |
284 , m_selectorList(o.m_selectorList) | 225 , m_selectorList(o.m_selectorList) |
285 { | 226 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if (!m_properties->isMutable()) | 263 if (!m_properties->isMutable()) |
323 m_properties = m_properties->copy(); | 264 m_properties = m_properties->copy(); |
324 return m_properties.get(); | 265 return m_properties.get(); |
325 } | 266 } |
326 | 267 |
327 void StyleRulePage::setProperties(PassRefPtr<StylePropertySet> properties) | 268 void StyleRulePage::setProperties(PassRefPtr<StylePropertySet> properties) |
328 { | 269 { |
329 m_properties = properties; | 270 m_properties = properties; |
330 } | 271 } |
331 | 272 |
332 void StyleRulePage::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectIn
fo) const | |
333 { | |
334 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
335 info.addMember(m_properties, "properties"); | |
336 info.addMember(m_selectorList, "selectorList"); | |
337 } | |
338 | |
339 StyleRuleFontFace::StyleRuleFontFace() | 273 StyleRuleFontFace::StyleRuleFontFace() |
340 : StyleRuleBase(FontFace, 0) | 274 : StyleRuleBase(FontFace, 0) |
341 { | 275 { |
342 } | 276 } |
343 | 277 |
344 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o) | 278 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o) |
345 : StyleRuleBase(o) | 279 : StyleRuleBase(o) |
346 , m_properties(o.m_properties->copy()) | 280 , m_properties(o.m_properties->copy()) |
347 { | 281 { |
348 } | 282 } |
349 | 283 |
350 StyleRuleFontFace::~StyleRuleFontFace() | 284 StyleRuleFontFace::~StyleRuleFontFace() |
351 { | 285 { |
352 } | 286 } |
353 | 287 |
354 StylePropertySet* StyleRuleFontFace::mutableProperties() | 288 StylePropertySet* StyleRuleFontFace::mutableProperties() |
355 { | 289 { |
356 if (!m_properties->isMutable()) | 290 if (!m_properties->isMutable()) |
357 m_properties = m_properties->copy(); | 291 m_properties = m_properties->copy(); |
358 return m_properties.get(); | 292 return m_properties.get(); |
359 } | 293 } |
360 | 294 |
361 void StyleRuleFontFace::setProperties(PassRefPtr<StylePropertySet> properties) | 295 void StyleRuleFontFace::setProperties(PassRefPtr<StylePropertySet> properties) |
362 { | 296 { |
363 m_properties = properties; | 297 m_properties = properties; |
364 } | 298 } |
365 | 299 |
366 void StyleRuleFontFace::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObje
ctInfo) const | |
367 { | |
368 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
369 info.addMember(m_properties, "properties"); | |
370 } | |
371 | |
372 | 300 |
373 StyleRuleGroup::StyleRuleGroup(Type type, Vector<RefPtr<StyleRuleBase> >& adoptR
ule) | 301 StyleRuleGroup::StyleRuleGroup(Type type, Vector<RefPtr<StyleRuleBase> >& adoptR
ule) |
374 : StyleRuleBase(type, 0) | 302 : StyleRuleBase(type, 0) |
375 { | 303 { |
376 m_childRules.swap(adoptRule); | 304 m_childRules.swap(adoptRule); |
377 } | 305 } |
378 | 306 |
379 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) | 307 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) |
380 : StyleRuleBase(o) | 308 : StyleRuleBase(o) |
381 , m_childRules(o.m_childRules.size()) | 309 , m_childRules(o.m_childRules.size()) |
382 { | 310 { |
383 for (unsigned i = 0; i < m_childRules.size(); ++i) | 311 for (unsigned i = 0; i < m_childRules.size(); ++i) |
384 m_childRules[i] = o.m_childRules[i]->copy(); | 312 m_childRules[i] = o.m_childRules[i]->copy(); |
385 } | 313 } |
386 | 314 |
387 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtr<StyleRuleBase>
rule) | 315 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtr<StyleRuleBase>
rule) |
388 { | 316 { |
389 m_childRules.insert(index, rule); | 317 m_childRules.insert(index, rule); |
390 } | 318 } |
391 | 319 |
392 void StyleRuleGroup::wrapperRemoveRule(unsigned index) | 320 void StyleRuleGroup::wrapperRemoveRule(unsigned index) |
393 { | 321 { |
394 m_childRules.remove(index); | 322 m_childRules.remove(index); |
395 } | 323 } |
396 | 324 |
397 void StyleRuleGroup::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectI
nfo) const | |
398 { | |
399 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
400 info.addMember(m_childRules, "childRules"); | |
401 } | |
402 | 325 |
403 StyleRuleMedia::StyleRuleMedia(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<St
yleRuleBase> >& adoptRules) | 326 StyleRuleMedia::StyleRuleMedia(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<St
yleRuleBase> >& adoptRules) |
404 : StyleRuleGroup(Media, adoptRules) | 327 : StyleRuleGroup(Media, adoptRules) |
405 , m_mediaQueries(media) | 328 , m_mediaQueries(media) |
406 { | 329 { |
407 } | 330 } |
408 | 331 |
409 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) | 332 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) |
410 : StyleRuleGroup(o) | 333 : StyleRuleGroup(o) |
411 { | 334 { |
412 if (o.m_mediaQueries) | 335 if (o.m_mediaQueries) |
413 m_mediaQueries = o.m_mediaQueries->copy(); | 336 m_mediaQueries = o.m_mediaQueries->copy(); |
414 } | 337 } |
415 | 338 |
416 void StyleRuleMedia::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectI
nfo) const | |
417 { | |
418 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
419 info.addMember(m_mediaQueries, "mediaQueries"); | |
420 } | |
421 | |
422 | 339 |
423 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition
IsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules) | 340 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition
IsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules) |
424 : StyleRuleGroup(Supports, adoptRules) | 341 : StyleRuleGroup(Supports, adoptRules) |
425 , m_conditionText(conditionText) | 342 , m_conditionText(conditionText) |
426 , m_conditionIsSupported(conditionIsSupported) | 343 , m_conditionIsSupported(conditionIsSupported) |
427 { | 344 { |
428 } | 345 } |
429 | 346 |
430 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) | 347 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) |
431 : StyleRuleGroup(o) | 348 : StyleRuleGroup(o) |
432 , m_conditionText(o.m_conditionText) | 349 , m_conditionText(o.m_conditionText) |
433 , m_conditionIsSupported(o.m_conditionIsSupported) | 350 , m_conditionIsSupported(o.m_conditionIsSupported) |
434 { | 351 { |
435 } | 352 } |
436 | 353 |
437 StyleRuleRegion::StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >* selectors,
Vector<RefPtr<StyleRuleBase> >& adoptRules) | 354 StyleRuleRegion::StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >* selectors,
Vector<RefPtr<StyleRuleBase> >& adoptRules) |
438 : StyleRuleGroup(Region, adoptRules) | 355 : StyleRuleGroup(Region, adoptRules) |
439 { | 356 { |
440 m_selectorList.adoptSelectorVector(*selectors); | 357 m_selectorList.adoptSelectorVector(*selectors); |
441 } | 358 } |
442 | 359 |
443 StyleRuleRegion::StyleRuleRegion(const StyleRuleRegion& o) | 360 StyleRuleRegion::StyleRuleRegion(const StyleRuleRegion& o) |
444 : StyleRuleGroup(o) | 361 : StyleRuleGroup(o) |
445 , m_selectorList(o.m_selectorList) | 362 , m_selectorList(o.m_selectorList) |
446 { | 363 { |
447 } | 364 } |
448 | 365 |
449 void StyleRuleRegion::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObject
Info) const | |
450 { | |
451 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
452 info.addMember(m_selectorList, "selectorList"); | |
453 } | |
454 | 366 |
455 #if ENABLE(CSS_DEVICE_ADAPTATION) | 367 #if ENABLE(CSS_DEVICE_ADAPTATION) |
456 StyleRuleViewport::StyleRuleViewport() | 368 StyleRuleViewport::StyleRuleViewport() |
457 : StyleRuleBase(Viewport, 0) | 369 : StyleRuleBase(Viewport, 0) |
458 { | 370 { |
459 } | 371 } |
460 | 372 |
461 StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& o) | 373 StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& o) |
462 : StyleRuleBase(o) | 374 : StyleRuleBase(o) |
463 , m_properties(o.m_properties->copy()) | 375 , m_properties(o.m_properties->copy()) |
464 { | 376 { |
465 } | 377 } |
466 | 378 |
467 StyleRuleViewport::~StyleRuleViewport() | 379 StyleRuleViewport::~StyleRuleViewport() |
468 { | 380 { |
469 } | 381 } |
470 | 382 |
471 StylePropertySet* StyleRuleViewport::mutableProperties() | 383 StylePropertySet* StyleRuleViewport::mutableProperties() |
472 { | 384 { |
473 if (!m_properties->isMutable()) | 385 if (!m_properties->isMutable()) |
474 m_properties = m_properties->copy(); | 386 m_properties = m_properties->copy(); |
475 return m_properties.get(); | 387 return m_properties.get(); |
476 } | 388 } |
477 | 389 |
478 void StyleRuleViewport::setProperties(PassRefPtr<StylePropertySet> properties) | 390 void StyleRuleViewport::setProperties(PassRefPtr<StylePropertySet> properties) |
479 { | 391 { |
480 m_properties = properties; | 392 m_properties = properties; |
481 } | 393 } |
482 | |
483 void StyleRuleViewport::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObje
ctInfo) const | |
484 { | |
485 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
486 info.addMember(m_properties, "properties"); | |
487 } | |
488 #endif // ENABLE(CSS_DEVICE_ADAPTATION) | 394 #endif // ENABLE(CSS_DEVICE_ADAPTATION) |
489 | 395 |
490 StyleRuleFilter::StyleRuleFilter(const String& filterName) | 396 StyleRuleFilter::StyleRuleFilter(const String& filterName) |
491 : StyleRuleBase(Filter, 0) | 397 : StyleRuleBase(Filter, 0) |
492 , m_filterName(filterName) | 398 , m_filterName(filterName) |
493 { | 399 { |
494 } | 400 } |
495 | 401 |
496 StyleRuleFilter::StyleRuleFilter(const StyleRuleFilter& o) | 402 StyleRuleFilter::StyleRuleFilter(const StyleRuleFilter& o) |
497 : StyleRuleBase(o) | 403 : StyleRuleBase(o) |
(...skipping 11 matching lines...) Expand all Loading... |
509 if (!m_properties->isMutable()) | 415 if (!m_properties->isMutable()) |
510 m_properties = m_properties->copy(); | 416 m_properties = m_properties->copy(); |
511 return m_properties.get(); | 417 return m_properties.get(); |
512 } | 418 } |
513 | 419 |
514 void StyleRuleFilter::setProperties(PassRefPtr<StylePropertySet> properties) | 420 void StyleRuleFilter::setProperties(PassRefPtr<StylePropertySet> properties) |
515 { | 421 { |
516 m_properties = properties; | 422 m_properties = properties; |
517 } | 423 } |
518 | 424 |
519 void StyleRuleFilter::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObject
Info) const | |
520 { | |
521 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | |
522 info.addMember(m_filterName); | |
523 info.addMember(m_properties); | |
524 } | |
525 | |
526 } // namespace WebCore | 425 } // namespace WebCore |
OLD | NEW |