| 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 "core/css/CSSKeyframesRule.h" | 26 #include "core/css/CSSKeyframesRule.h" |
| 27 #include "core/css/CSSMediaRule.h" | 27 #include "core/css/CSSMediaRule.h" |
| 28 #include "core/css/CSSNamespaceRule.h" | 28 #include "core/css/CSSNamespaceRule.h" |
| 29 #include "core/css/CSSPageRule.h" | 29 #include "core/css/CSSPageRule.h" |
| 30 #include "core/css/CSSStyleRule.h" | 30 #include "core/css/CSSStyleRule.h" |
| 31 #include "core/css/CSSSupportsRule.h" | 31 #include "core/css/CSSSupportsRule.h" |
| 32 #include "core/css/CSSViewportRule.h" | 32 #include "core/css/CSSViewportRule.h" |
| 33 #include "core/css/StyleRuleImport.h" | 33 #include "core/css/StyleRuleImport.h" |
| 34 #include "core/css/StyleRuleKeyframe.h" | 34 #include "core/css/StyleRuleKeyframe.h" |
| 35 #include "core/css/StyleRuleNamespace.h" | 35 #include "core/css/StyleRuleNamespace.h" |
| 36 #include "core/css/serializer/CSSDeserializeStream.h" |
| 37 #include "core/css/serializer/CSSSerializeStream.h" |
| 36 | 38 |
| 37 namespace blink { | 39 namespace blink { |
| 38 | 40 |
| 39 struct SameSizeAsStyleRuleBase : public RefCountedWillBeGarbageCollectedFinalize
d<SameSizeAsStyleRuleBase> { | 41 struct SameSizeAsStyleRuleBase : public RefCountedWillBeGarbageCollectedFinalize
d<SameSizeAsStyleRuleBase> { |
| 40 unsigned bitfields; | 42 unsigned bitfields; |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu
leBase should stay small"); | 45 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu
leBase should stay small"); |
| 44 | 46 |
| 45 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet*
parentSheet) const | 47 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet*
parentSheet) const |
| 46 { | 48 { |
| 47 return createCSSOMWrapper(parentSheet, 0); | 49 return createCSSOMWrapper(parentSheet, 0); |
| 48 } | 50 } |
| 49 | 51 |
| 50 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* paren
tRule) const | 52 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* paren
tRule) const |
| 51 { | 53 { |
| 52 return createCSSOMWrapper(0, parentRule); | 54 return createCSSOMWrapper(0, parentRule); |
| 53 } | 55 } |
| 54 | 56 |
| 57 PassRefPtrWillBeRawPtr<StyleRuleBase> StyleRuleBase::deserialize(CSSDeserializeS
tream* stream) |
| 58 { |
| 59 Type type = static_cast<Type>(stream->readUnsigned()); |
| 60 |
| 61 switch (type) { |
| 62 case Style: |
| 63 return StyleRule::deserializeAfterDispatch(stream); |
| 64 case Media: |
| 65 return StyleRuleMedia::deserializeAfterDispatch(stream); |
| 66 case Keyframes: |
| 67 return StyleRuleKeyframes::deserializeAfterDispatch(stream); |
| 68 case Keyframe: |
| 69 return StyleRuleKeyframe::deserializeAfterDispatch(stream); |
| 70 case FontFace: |
| 71 return StyleRuleFontFace::deserializeAfterDispatch(stream); |
| 72 |
| 73 default: |
| 74 ASSERT_NOT_REACHED(); |
| 75 return nullptr; |
| 76 } |
| 77 } |
| 78 |
| 79 void StyleRuleBase::serialize(CSSSerializeStream* stream) const |
| 80 { |
| 81 stream->writeUnsigned(type()); |
| 82 switch (type()) { |
| 83 /* |
| 84 case Charset: |
| 85 toStyleRuleCharset(this)->serializeAfterDispatch(stream); |
| 86 return; |
| 87 */ |
| 88 case Style: |
| 89 toStyleRule(this)->serializeAfterDispatch(stream); |
| 90 return; |
| 91 /* |
| 92 case Page: |
| 93 toStyleRulePage(this)->serializeAfterDispatch(stream); |
| 94 return; |
| 95 */ |
| 96 case FontFace: |
| 97 toStyleRuleFontFace(this)->serializeAfterDispatch(stream); |
| 98 return; |
| 99 case Media: |
| 100 toStyleRuleMedia(this)->serializeAfterDispatch(stream); |
| 101 return; |
| 102 /* |
| 103 case Supports: |
| 104 toStyleRuleSupports(this)->serializeAfterDispatch(stream); |
| 105 return; |
| 106 case Import: |
| 107 toStyleRuleImport(this)->serializeAfterDispatch(stream); |
| 108 return; |
| 109 */ |
| 110 case Keyframes: |
| 111 toStyleRuleKeyframes(this)->serializeAfterDispatch(stream); |
| 112 return; |
| 113 case Keyframe: |
| 114 toStyleRuleKeyframe(this)->serializeAfterDispatch(stream); |
| 115 return; |
| 116 /* |
| 117 case Namespace: |
| 118 toStyleRuleNamespace(this)->serializeAfterDispatch(stream); |
| 119 return; |
| 120 case Viewport: |
| 121 toStyleRuleViewport(this)->serializeAfterDispatch(stream); |
| 122 return; |
| 123 */ |
| 124 default: |
| 125 break; |
| 126 } |
| 127 ASSERT_NOT_REACHED(); |
| 128 } |
| 129 |
| 55 DEFINE_TRACE(StyleRuleBase) | 130 DEFINE_TRACE(StyleRuleBase) |
| 56 { | 131 { |
| 57 switch (type()) { | 132 switch (type()) { |
| 58 case Charset: | 133 case Charset: |
| 59 toStyleRuleCharset(this)->traceAfterDispatch(visitor); | 134 toStyleRuleCharset(this)->traceAfterDispatch(visitor); |
| 60 return; | 135 return; |
| 61 case Style: | 136 case Style: |
| 62 toStyleRule(this)->traceAfterDispatch(visitor); | 137 toStyleRule(this)->traceAfterDispatch(visitor); |
| 63 return; | 138 return; |
| 64 case Page: | 139 case Page: |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 { | 343 { |
| 269 } | 344 } |
| 270 | 345 |
| 271 MutableStylePropertySet& StyleRule::mutableProperties() | 346 MutableStylePropertySet& StyleRule::mutableProperties() |
| 272 { | 347 { |
| 273 if (!m_properties->isMutable()) | 348 if (!m_properties->isMutable()) |
| 274 m_properties = m_properties->mutableCopy(); | 349 m_properties = m_properties->mutableCopy(); |
| 275 return *toMutableStylePropertySet(m_properties.get()); | 350 return *toMutableStylePropertySet(m_properties.get()); |
| 276 } | 351 } |
| 277 | 352 |
| 353 PassRefPtrWillBeRawPtr<StyleRule> StyleRule::deserializeAfterDispatch(CSSDeseria
lizeStream* stream) |
| 354 { |
| 355 RefPtrWillBeMember<StylePropertySet> properties = ImmutableStylePropertySet:
:deserialize(stream); |
| 356 CSSSelectorList selectorList = CSSSelectorList::deserialize(stream); |
| 357 return StyleRule::create(std::move(selectorList), properties); |
| 358 } |
| 359 |
| 360 void StyleRule::serializeAfterDispatch(CSSSerializeStream* stream) const |
| 361 { |
| 362 CSDEBUG("StyleRule::serializeAfterDispatch()\n"); |
| 363 m_properties->serialize(stream); |
| 364 m_selectorList.serialize(stream); |
| 365 } |
| 366 |
| 278 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) | 367 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) |
| 279 { | 368 { |
| 280 visitor->trace(m_properties); | 369 visitor->trace(m_properties); |
| 281 StyleRuleBase::traceAfterDispatch(visitor); | 370 StyleRuleBase::traceAfterDispatch(visitor); |
| 282 } | 371 } |
| 283 | 372 |
| 284 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, PassRefPtrWillBeRawPt
r<StylePropertySet> properties) | 373 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, PassRefPtrWillBeRawPt
r<StylePropertySet> properties) |
| 285 : StyleRuleBase(Page) | 374 : StyleRuleBase(Page) |
| 286 , m_properties(properties) | 375 , m_properties(properties) |
| 287 , m_selectorList(std::move(selectorList)) | 376 , m_selectorList(std::move(selectorList)) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 { | 417 { |
| 329 } | 418 } |
| 330 | 419 |
| 331 MutableStylePropertySet& StyleRuleFontFace::mutableProperties() | 420 MutableStylePropertySet& StyleRuleFontFace::mutableProperties() |
| 332 { | 421 { |
| 333 if (!m_properties->isMutable()) | 422 if (!m_properties->isMutable()) |
| 334 m_properties = m_properties->mutableCopy(); | 423 m_properties = m_properties->mutableCopy(); |
| 335 return *toMutableStylePropertySet(m_properties); | 424 return *toMutableStylePropertySet(m_properties); |
| 336 } | 425 } |
| 337 | 426 |
| 427 void StyleRuleFontFace::serializeAfterDispatch(CSSSerializeStream* stream) const |
| 428 { |
| 429 CSDEBUG("StyleRuleFontFace::serializeAfterDispatch()\n"); |
| 430 m_properties->serialize(stream); |
| 431 } |
| 432 |
| 433 PassRefPtrWillBeRawPtr<StyleRuleFontFace> StyleRuleFontFace::deserializeAfterDis
patch(CSSDeserializeStream* stream) |
| 434 { |
| 435 CSDEBUG("StyleRuleFontFace::deserializeAfterDispatch()\n"); |
| 436 RefPtrWillBeRawPtr<StylePropertySet> properties = ImmutableStylePropertySet:
:deserialize(stream); |
| 437 return create(properties.release()); |
| 438 } |
| 439 |
| 338 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleFontFace) | 440 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleFontFace) |
| 339 { | 441 { |
| 340 visitor->trace(m_properties); | 442 visitor->trace(m_properties); |
| 341 StyleRuleBase::traceAfterDispatch(visitor); | 443 StyleRuleBase::traceAfterDispatch(visitor); |
| 342 } | 444 } |
| 343 | 445 |
| 344 StyleRuleGroup::StyleRuleGroup(Type type, WillBeHeapVector<RefPtrWillBeMember<St
yleRuleBase>>& adoptRule) | 446 StyleRuleGroup::StyleRuleGroup(Type type, WillBeHeapVector<RefPtrWillBeMember<St
yleRuleBase>>& adoptRule) |
| 345 : StyleRuleBase(type) | 447 : StyleRuleBase(type) |
| 346 { | 448 { |
| 347 m_childRules.swap(adoptRule); | 449 m_childRules.swap(adoptRule); |
| 348 } | 450 } |
| 349 | 451 |
| 350 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) | 452 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) |
| 351 : StyleRuleBase(o) | 453 : StyleRuleBase(o) |
| 352 , m_childRules(o.m_childRules.size()) | 454 , m_childRules(o.m_childRules.size()) |
| 353 { | 455 { |
| 354 for (unsigned i = 0; i < m_childRules.size(); ++i) | 456 for (unsigned i = 0; i < m_childRules.size(); ++i) |
| 355 m_childRules[i] = o.m_childRules[i]->copy(); | 457 m_childRules[i] = o.m_childRules[i]->copy(); |
| 356 } | 458 } |
| 357 | 459 |
| 460 void StyleRuleGroup::serializeAfterDispatch(CSSSerializeStream* stream) const |
| 461 { |
| 462 CSDEBUG("StyleRuleGroup::serializeAfterDispatch()\n"); |
| 463 stream->writeUnsigned(m_childRules.size()); |
| 464 for (const RefPtrWillBeMember<StyleRuleBase>& childRule : m_childRules) |
| 465 childRule->serialize(stream); |
| 466 } |
| 467 |
| 468 void StyleRuleGroup::deserializeAfterDispatch(CSSDeserializeStream* stream) |
| 469 { |
| 470 CSDEBUG("StyleRuleGroup::deserializeAfterDispatch()\n"); |
| 471 ASSERT(m_childRules.isEmpty()); |
| 472 unsigned size = stream->readUnsigned(); |
| 473 m_childRules.reserveCapacity(size); |
| 474 for (unsigned i = 0; i < size; ++ i) |
| 475 m_childRules.append(StyleRule::deserialize(stream)); |
| 476 } |
| 477 |
| 358 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtrWillBeRawPtr<St
yleRuleBase> rule) | 478 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtrWillBeRawPtr<St
yleRuleBase> rule) |
| 359 { | 479 { |
| 360 m_childRules.insert(index, rule); | 480 m_childRules.insert(index, rule); |
| 361 } | 481 } |
| 362 | 482 |
| 363 void StyleRuleGroup::wrapperRemoveRule(unsigned index) | 483 void StyleRuleGroup::wrapperRemoveRule(unsigned index) |
| 364 { | 484 { |
| 365 m_childRules.remove(index); | 485 m_childRules.remove(index); |
| 366 } | 486 } |
| 367 | 487 |
| 368 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup) | 488 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup) |
| 369 { | 489 { |
| 370 visitor->trace(m_childRules); | 490 visitor->trace(m_childRules); |
| 371 StyleRuleBase::traceAfterDispatch(visitor); | 491 StyleRuleBase::traceAfterDispatch(visitor); |
| 372 } | 492 } |
| 373 | 493 |
| 374 StyleRuleMedia::StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet> media, Will
BeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules) | 494 StyleRuleMedia::StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet> media, Will
BeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules) |
| 375 : StyleRuleGroup(Media, adoptRules) | 495 : StyleRuleGroup(Media, adoptRules) |
| 376 , m_mediaQueries(media) | 496 , m_mediaQueries(media) |
| 377 { | 497 { |
| 378 } | 498 } |
| 379 | 499 |
| 380 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) | 500 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) |
| 381 : StyleRuleGroup(o) | 501 : StyleRuleGroup(o) |
| 382 { | 502 { |
| 383 if (o.m_mediaQueries) | 503 if (o.m_mediaQueries) |
| 384 m_mediaQueries = o.m_mediaQueries->copy(); | 504 m_mediaQueries = o.m_mediaQueries->copy(); |
| 385 } | 505 } |
| 386 | 506 |
| 507 void StyleRuleMedia::serializeAfterDispatch(CSSSerializeStream* stream) const |
| 508 { |
| 509 CSDEBUG("StyleRuleMedia::serializeAfterDispatch()\n"); |
| 510 StyleRuleGroup::serializeAfterDispatch(stream); |
| 511 m_mediaQueries->serialize(stream); |
| 512 } |
| 513 |
| 514 PassRefPtrWillBeRawPtr<StyleRuleMedia> StyleRuleMedia::deserializeAfterDispatch(
CSSDeserializeStream* stream) |
| 515 { |
| 516 RefPtrWillBeRawPtr<StyleRuleMedia> rule = adoptRefWillBeNoop(new StyleRuleMe
dia()); |
| 517 rule->StyleRuleGroup::deserializeAfterDispatch(stream); |
| 518 rule->m_mediaQueries = MediaQuerySet::deserialize(stream); |
| 519 return rule.release(); |
| 520 } |
| 521 |
| 387 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleMedia) | 522 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleMedia) |
| 388 { | 523 { |
| 389 visitor->trace(m_mediaQueries); | 524 visitor->trace(m_mediaQueries); |
| 390 StyleRuleGroup::traceAfterDispatch(visitor); | 525 StyleRuleGroup::traceAfterDispatch(visitor); |
| 391 } | 526 } |
| 392 | 527 |
| 393 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition
IsSupported, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules) | 528 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition
IsSupported, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules) |
| 394 : StyleRuleGroup(Supports, adoptRules) | 529 : StyleRuleGroup(Supports, adoptRules) |
| 395 , m_conditionText(conditionText) | 530 , m_conditionText(conditionText) |
| 396 , m_conditionIsSupported(conditionIsSupported) | 531 , m_conditionIsSupported(conditionIsSupported) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 427 return *toMutableStylePropertySet(m_properties); | 562 return *toMutableStylePropertySet(m_properties); |
| 428 } | 563 } |
| 429 | 564 |
| 430 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) | 565 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) |
| 431 { | 566 { |
| 432 visitor->trace(m_properties); | 567 visitor->trace(m_properties); |
| 433 StyleRuleBase::traceAfterDispatch(visitor); | 568 StyleRuleBase::traceAfterDispatch(visitor); |
| 434 } | 569 } |
| 435 | 570 |
| 436 } // namespace blink | 571 } // namespace blink |
| OLD | NEW |