| 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 18 matching lines...) Expand all Loading... |
| 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 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 struct SameSizeAsStyleRuleBase : public RefCountedWillBeGarbageCollectedFinalize
d<SameSizeAsStyleRuleBase> { | 39 struct SameSizeAsStyleRuleBase : public GarbageCollectedFinalized<SameSizeAsStyl
eRuleBase> { |
| 40 unsigned bitfields; | 40 unsigned bitfields; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu
leBase should stay small"); | 43 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu
leBase should stay small"); |
| 44 | 44 |
| 45 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet*
parentSheet) const | 45 RawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) co
nst |
| 46 { | 46 { |
| 47 return createCSSOMWrapper(parentSheet, 0); | 47 return createCSSOMWrapper(parentSheet, 0); |
| 48 } | 48 } |
| 49 | 49 |
| 50 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* paren
tRule) const | 50 RawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const |
| 51 { | 51 { |
| 52 return createCSSOMWrapper(0, parentRule); | 52 return createCSSOMWrapper(0, parentRule); |
| 53 } | 53 } |
| 54 | 54 |
| 55 DEFINE_TRACE(StyleRuleBase) | 55 DEFINE_TRACE(StyleRuleBase) |
| 56 { | 56 { |
| 57 switch (type()) { | 57 switch (type()) { |
| 58 case Charset: | 58 case Charset: |
| 59 toStyleRuleCharset(this)->traceAfterDispatch(visitor); | 59 toStyleRuleCharset(this)->traceAfterDispatch(visitor); |
| 60 return; | 60 return; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 case Namespace: | 165 case Namespace: |
| 166 delete toStyleRuleNamespace(this); | 166 delete toStyleRuleNamespace(this); |
| 167 return; | 167 return; |
| 168 case Viewport: | 168 case Viewport: |
| 169 delete toStyleRuleViewport(this); | 169 delete toStyleRuleViewport(this); |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 ASSERT_NOT_REACHED(); | 172 ASSERT_NOT_REACHED(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 PassRefPtrWillBeRawPtr<StyleRuleBase> StyleRuleBase::copy() const | 175 RawPtr<StyleRuleBase> StyleRuleBase::copy() const |
| 176 { | 176 { |
| 177 switch (type()) { | 177 switch (type()) { |
| 178 case Style: | 178 case Style: |
| 179 return toStyleRule(this)->copy(); | 179 return toStyleRule(this)->copy(); |
| 180 case Page: | 180 case Page: |
| 181 return toStyleRulePage(this)->copy(); | 181 return toStyleRulePage(this)->copy(); |
| 182 case FontFace: | 182 case FontFace: |
| 183 return toStyleRuleFontFace(this)->copy(); | 183 return toStyleRuleFontFace(this)->copy(); |
| 184 case Media: | 184 case Media: |
| 185 return toStyleRuleMedia(this)->copy(); | 185 return toStyleRuleMedia(this)->copy(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 196 case Charset: | 196 case Charset: |
| 197 case Keyframe: | 197 case Keyframe: |
| 198 case Namespace: | 198 case Namespace: |
| 199 ASSERT_NOT_REACHED(); | 199 ASSERT_NOT_REACHED(); |
| 200 return nullptr; | 200 return nullptr; |
| 201 } | 201 } |
| 202 ASSERT_NOT_REACHED(); | 202 ASSERT_NOT_REACHED(); |
| 203 return nullptr; | 203 return nullptr; |
| 204 } | 204 } |
| 205 | 205 |
| 206 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet*
parentSheet, CSSRule* parentRule) const | 206 RawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet, CS
SRule* parentRule) const |
| 207 { | 207 { |
| 208 RefPtrWillBeRawPtr<CSSRule> rule = nullptr; | 208 RawPtr<CSSRule> rule = nullptr; |
| 209 StyleRuleBase* self = const_cast<StyleRuleBase*>(this); | 209 StyleRuleBase* self = const_cast<StyleRuleBase*>(this); |
| 210 switch (type()) { | 210 switch (type()) { |
| 211 case Style: | 211 case Style: |
| 212 rule = CSSStyleRule::create(toStyleRule(self), parentSheet); | 212 rule = CSSStyleRule::create(toStyleRule(self), parentSheet); |
| 213 break; | 213 break; |
| 214 case Page: | 214 case Page: |
| 215 rule = CSSPageRule::create(toStyleRulePage(self), parentSheet); | 215 rule = CSSPageRule::create(toStyleRulePage(self), parentSheet); |
| 216 break; | 216 break; |
| 217 case FontFace: | 217 case FontFace: |
| 218 rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet); | 218 rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 243 if (parentRule) | 243 if (parentRule) |
| 244 rule->setParentRule(parentRule); | 244 rule->setParentRule(parentRule); |
| 245 return rule.release(); | 245 return rule.release(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 unsigned StyleRule::averageSizeInBytes() | 248 unsigned StyleRule::averageSizeInBytes() |
| 249 { | 249 { |
| 250 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); | 250 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 StyleRule::StyleRule(CSSSelectorList selectorList, PassRefPtrWillBeRawPtr<StyleP
ropertySet> properties) | 253 StyleRule::StyleRule(CSSSelectorList selectorList, RawPtr<StylePropertySet> prop
erties) |
| 254 : StyleRuleBase(Style) | 254 : StyleRuleBase(Style) |
| 255 , m_properties(properties) | 255 , m_properties(properties) |
| 256 { | 256 { |
| 257 m_selectorList = std::move(selectorList); | 257 m_selectorList = std::move(selectorList); |
| 258 } | 258 } |
| 259 | 259 |
| 260 StyleRule::StyleRule(const StyleRule& o) | 260 StyleRule::StyleRule(const StyleRule& o) |
| 261 : StyleRuleBase(o) | 261 : StyleRuleBase(o) |
| 262 , m_properties(o.m_properties->mutableCopy()) | 262 , m_properties(o.m_properties->mutableCopy()) |
| 263 , m_selectorList(o.m_selectorList.copy()) | 263 , m_selectorList(o.m_selectorList.copy()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 274 m_properties = m_properties->mutableCopy(); | 274 m_properties = m_properties->mutableCopy(); |
| 275 return *toMutableStylePropertySet(m_properties.get()); | 275 return *toMutableStylePropertySet(m_properties.get()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) | 278 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) |
| 279 { | 279 { |
| 280 visitor->trace(m_properties); | 280 visitor->trace(m_properties); |
| 281 StyleRuleBase::traceAfterDispatch(visitor); | 281 StyleRuleBase::traceAfterDispatch(visitor); |
| 282 } | 282 } |
| 283 | 283 |
| 284 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, PassRefPtrWillBeRawPt
r<StylePropertySet> properties) | 284 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, RawPtr<StylePropertyS
et> properties) |
| 285 : StyleRuleBase(Page) | 285 : StyleRuleBase(Page) |
| 286 , m_properties(properties) | 286 , m_properties(properties) |
| 287 , m_selectorList(std::move(selectorList)) | 287 , m_selectorList(std::move(selectorList)) |
| 288 { | 288 { |
| 289 } | 289 } |
| 290 | 290 |
| 291 StyleRulePage::StyleRulePage(const StyleRulePage& o) | 291 StyleRulePage::StyleRulePage(const StyleRulePage& o) |
| 292 : StyleRuleBase(o) | 292 : StyleRuleBase(o) |
| 293 , m_properties(o.m_properties->mutableCopy()) | 293 , m_properties(o.m_properties->mutableCopy()) |
| 294 , m_selectorList(o.m_selectorList.copy()) | 294 , m_selectorList(o.m_selectorList.copy()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 305 m_properties = m_properties->mutableCopy(); | 305 m_properties = m_properties->mutableCopy(); |
| 306 return *toMutableStylePropertySet(m_properties.get()); | 306 return *toMutableStylePropertySet(m_properties.get()); |
| 307 } | 307 } |
| 308 | 308 |
| 309 DEFINE_TRACE_AFTER_DISPATCH(StyleRulePage) | 309 DEFINE_TRACE_AFTER_DISPATCH(StyleRulePage) |
| 310 { | 310 { |
| 311 visitor->trace(m_properties); | 311 visitor->trace(m_properties); |
| 312 StyleRuleBase::traceAfterDispatch(visitor); | 312 StyleRuleBase::traceAfterDispatch(visitor); |
| 313 } | 313 } |
| 314 | 314 |
| 315 StyleRuleFontFace::StyleRuleFontFace(PassRefPtrWillBeRawPtr<StylePropertySet> pr
operties) | 315 StyleRuleFontFace::StyleRuleFontFace(RawPtr<StylePropertySet> properties) |
| 316 : StyleRuleBase(FontFace) | 316 : StyleRuleBase(FontFace) |
| 317 , m_properties(properties) | 317 , m_properties(properties) |
| 318 { | 318 { |
| 319 } | 319 } |
| 320 | 320 |
| 321 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o) | 321 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o) |
| 322 : StyleRuleBase(o) | 322 : StyleRuleBase(o) |
| 323 , m_properties(o.m_properties->mutableCopy()) | 323 , m_properties(o.m_properties->mutableCopy()) |
| 324 { | 324 { |
| 325 } | 325 } |
| 326 | 326 |
| 327 StyleRuleFontFace::~StyleRuleFontFace() | 327 StyleRuleFontFace::~StyleRuleFontFace() |
| 328 { | 328 { |
| 329 } | 329 } |
| 330 | 330 |
| 331 MutableStylePropertySet& StyleRuleFontFace::mutableProperties() | 331 MutableStylePropertySet& StyleRuleFontFace::mutableProperties() |
| 332 { | 332 { |
| 333 if (!m_properties->isMutable()) | 333 if (!m_properties->isMutable()) |
| 334 m_properties = m_properties->mutableCopy(); | 334 m_properties = m_properties->mutableCopy(); |
| 335 return *toMutableStylePropertySet(m_properties); | 335 return *toMutableStylePropertySet(m_properties); |
| 336 } | 336 } |
| 337 | 337 |
| 338 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleFontFace) | 338 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleFontFace) |
| 339 { | 339 { |
| 340 visitor->trace(m_properties); | 340 visitor->trace(m_properties); |
| 341 StyleRuleBase::traceAfterDispatch(visitor); | 341 StyleRuleBase::traceAfterDispatch(visitor); |
| 342 } | 342 } |
| 343 | 343 |
| 344 StyleRuleGroup::StyleRuleGroup(Type type, WillBeHeapVector<RefPtrWillBeMember<St
yleRuleBase>>& adoptRule) | 344 StyleRuleGroup::StyleRuleGroup(Type type, HeapVector<Member<StyleRuleBase>>& ado
ptRule) |
| 345 : StyleRuleBase(type) | 345 : StyleRuleBase(type) |
| 346 { | 346 { |
| 347 m_childRules.swap(adoptRule); | 347 m_childRules.swap(adoptRule); |
| 348 } | 348 } |
| 349 | 349 |
| 350 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) | 350 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) |
| 351 : StyleRuleBase(o) | 351 : StyleRuleBase(o) |
| 352 , m_childRules(o.m_childRules.size()) | 352 , m_childRules(o.m_childRules.size()) |
| 353 { | 353 { |
| 354 for (unsigned i = 0; i < m_childRules.size(); ++i) | 354 for (unsigned i = 0; i < m_childRules.size(); ++i) |
| 355 m_childRules[i] = o.m_childRules[i]->copy(); | 355 m_childRules[i] = o.m_childRules[i]->copy(); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtrWillBeRawPtr<St
yleRuleBase> rule) | 358 void StyleRuleGroup::wrapperInsertRule(unsigned index, RawPtr<StyleRuleBase> rul
e) |
| 359 { | 359 { |
| 360 m_childRules.insert(index, rule); | 360 m_childRules.insert(index, rule); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void StyleRuleGroup::wrapperRemoveRule(unsigned index) | 363 void StyleRuleGroup::wrapperRemoveRule(unsigned index) |
| 364 { | 364 { |
| 365 m_childRules.remove(index); | 365 m_childRules.remove(index); |
| 366 } | 366 } |
| 367 | 367 |
| 368 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup) | 368 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup) |
| 369 { | 369 { |
| 370 visitor->trace(m_childRules); | 370 visitor->trace(m_childRules); |
| 371 StyleRuleBase::traceAfterDispatch(visitor); | 371 StyleRuleBase::traceAfterDispatch(visitor); |
| 372 } | 372 } |
| 373 | 373 |
| 374 StyleRuleMedia::StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet> media, Will
BeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules) | 374 StyleRuleMedia::StyleRuleMedia(RawPtr<MediaQuerySet> media, HeapVector<Member<St
yleRuleBase>>& adoptRules) |
| 375 : StyleRuleGroup(Media, adoptRules) | 375 : StyleRuleGroup(Media, adoptRules) |
| 376 , m_mediaQueries(media) | 376 , m_mediaQueries(media) |
| 377 { | 377 { |
| 378 } | 378 } |
| 379 | 379 |
| 380 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) | 380 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) |
| 381 : StyleRuleGroup(o) | 381 : StyleRuleGroup(o) |
| 382 { | 382 { |
| 383 if (o.m_mediaQueries) | 383 if (o.m_mediaQueries) |
| 384 m_mediaQueries = o.m_mediaQueries->copy(); | 384 m_mediaQueries = o.m_mediaQueries->copy(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleMedia) | 387 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleMedia) |
| 388 { | 388 { |
| 389 visitor->trace(m_mediaQueries); | 389 visitor->trace(m_mediaQueries); |
| 390 StyleRuleGroup::traceAfterDispatch(visitor); | 390 StyleRuleGroup::traceAfterDispatch(visitor); |
| 391 } | 391 } |
| 392 | 392 |
| 393 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition
IsSupported, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules) | 393 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition
IsSupported, HeapVector<Member<StyleRuleBase>>& adoptRules) |
| 394 : StyleRuleGroup(Supports, adoptRules) | 394 : StyleRuleGroup(Supports, adoptRules) |
| 395 , m_conditionText(conditionText) | 395 , m_conditionText(conditionText) |
| 396 , m_conditionIsSupported(conditionIsSupported) | 396 , m_conditionIsSupported(conditionIsSupported) |
| 397 { | 397 { |
| 398 } | 398 } |
| 399 | 399 |
| 400 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) | 400 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) |
| 401 : StyleRuleGroup(o) | 401 : StyleRuleGroup(o) |
| 402 , m_conditionText(o.m_conditionText) | 402 , m_conditionText(o.m_conditionText) |
| 403 , m_conditionIsSupported(o.m_conditionIsSupported) | 403 , m_conditionIsSupported(o.m_conditionIsSupported) |
| 404 { | 404 { |
| 405 } | 405 } |
| 406 | 406 |
| 407 StyleRuleViewport::StyleRuleViewport(PassRefPtrWillBeRawPtr<StylePropertySet> pr
operties) | 407 StyleRuleViewport::StyleRuleViewport(RawPtr<StylePropertySet> properties) |
| 408 : StyleRuleBase(Viewport) | 408 : StyleRuleBase(Viewport) |
| 409 , m_properties(properties) | 409 , m_properties(properties) |
| 410 { | 410 { |
| 411 } | 411 } |
| 412 | 412 |
| 413 StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& o) | 413 StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& o) |
| 414 : StyleRuleBase(o) | 414 : StyleRuleBase(o) |
| 415 , m_properties(o.m_properties->mutableCopy()) | 415 , m_properties(o.m_properties->mutableCopy()) |
| 416 { | 416 { |
| 417 } | 417 } |
| 418 | 418 |
| 419 StyleRuleViewport::~StyleRuleViewport() | 419 StyleRuleViewport::~StyleRuleViewport() |
| 420 { | 420 { |
| 421 } | 421 } |
| 422 | 422 |
| 423 MutableStylePropertySet& StyleRuleViewport::mutableProperties() | 423 MutableStylePropertySet& StyleRuleViewport::mutableProperties() |
| 424 { | 424 { |
| 425 if (!m_properties->isMutable()) | 425 if (!m_properties->isMutable()) |
| 426 m_properties = m_properties->mutableCopy(); | 426 m_properties = m_properties->mutableCopy(); |
| 427 return *toMutableStylePropertySet(m_properties); | 427 return *toMutableStylePropertySet(m_properties); |
| 428 } | 428 } |
| 429 | 429 |
| 430 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) | 430 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) |
| 431 { | 431 { |
| 432 visitor->trace(m_properties); | 432 visitor->trace(m_properties); |
| 433 StyleRuleBase::traceAfterDispatch(visitor); | 433 StyleRuleBase::traceAfterDispatch(visitor); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } // namespace blink | 436 } // namespace blink |
| OLD | NEW |