OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Andreas Kling (kling@webkit.org) | 2 * Copyright (C) 2011 Andreas Kling (kling@webkit.org) |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 struct SameSizeAsCSSValue : public RefCountedWillBeGarbageCollectedFinalized<Sam
eSizeAsCSSValue> | 59 struct SameSizeAsCSSValue : public RefCountedWillBeGarbageCollectedFinalized<Sam
eSizeAsCSSValue> |
60 { | 60 { |
61 uint32_t bitfields; | 61 uint32_t bitfields; |
62 }; | 62 }; |
63 | 63 |
64 static_assert(sizeof(CSSValue) <= sizeof(SameSizeAsCSSValue), "CSSValue should s
tay small"); | 64 static_assert(sizeof(CSSValue) <= sizeof(SameSizeAsCSSValue), "CSSValue should s
tay small"); |
65 | 65 |
66 bool CSSValue::isImplicitInitialValue() const | 66 bool CSSValue::isImplicitInitialValue() const |
67 { | 67 { |
68 return m_classType == InitialClass && toCSSInitialValue(this)->isImplicit(); | 68 return !isTaggedPtr() && classType() == InitialClass && toCSSInitialValue(th
is)->isImplicit(); |
69 } | 69 } |
70 | 70 |
71 bool CSSValue::hasFailedOrCanceledSubresources() const | 71 bool CSSValue::hasFailedOrCanceledSubresources() const |
72 { | 72 { |
| 73 if (isTaggedPtr()) |
| 74 return false; |
| 75 |
73 if (isValueList()) | 76 if (isValueList()) |
74 return toCSSValueList(this)->hasFailedOrCanceledSubresources(); | 77 return toCSSValueList(this)->hasFailedOrCanceledSubresources(); |
75 if (classType() == FontFaceSrcClass) | 78 if (classType() == FontFaceSrcClass) |
76 return toCSSFontFaceSrcValue(this)->hasFailedOrCanceledSubresources(); | 79 return toCSSFontFaceSrcValue(this)->hasFailedOrCanceledSubresources(); |
77 if (classType() == ImageClass) | 80 if (classType() == ImageClass) |
78 return toCSSImageValue(this)->hasFailedOrCanceledSubresources(); | 81 return toCSSImageValue(this)->hasFailedOrCanceledSubresources(); |
79 if (classType() == CrossfadeClass) | 82 if (classType() == CrossfadeClass) |
80 return toCSSCrossfadeValue(this)->hasFailedOrCanceledSubresources(); | 83 return toCSSCrossfadeValue(this)->hasFailedOrCanceledSubresources(); |
81 if (classType() == ImageSetClass) | 84 if (classType() == ImageSetClass) |
82 return toCSSImageSetValue(this)->hasFailedOrCanceledSubresources(); | 85 return toCSSImageSetValue(this)->hasFailedOrCanceledSubresources(); |
83 | 86 |
84 return false; | 87 return false; |
85 } | 88 } |
86 | 89 |
87 template<class ChildClassType> | 90 template<class ChildClassType> |
88 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon
d) | 91 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon
d) |
89 { | 92 { |
90 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch
ildClassType&>(second)); | 93 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch
ildClassType&>(second)); |
91 } | 94 } |
92 | 95 |
93 bool CSSValue::equals(const CSSValue& other) const | 96 bool CSSValue::equals(const CSSValue& other) const |
94 { | 97 { |
| 98 if (isTaggedPtr() && other.isTaggedPtr()) |
| 99 return this == &other; |
| 100 |
| 101 if (isTaggedPtr() || other.isTaggedPtr()) |
| 102 return compareCSSValues<CSSPrimitiveValue>(*this, other); |
| 103 |
95 if (m_classType == other.m_classType) { | 104 if (m_classType == other.m_classType) { |
96 switch (m_classType) { | 105 switch (m_classType) { |
97 case BorderImageSliceClass: | 106 case BorderImageSliceClass: |
98 return compareCSSValues<CSSBorderImageSliceValue>(*this, other); | 107 return compareCSSValues<CSSBorderImageSliceValue>(*this, other); |
99 case CanvasClass: | 108 case CanvasClass: |
100 return compareCSSValues<CSSCanvasValue>(*this, other); | 109 return compareCSSValues<CSSCanvasValue>(*this, other); |
101 case CursorImageClass: | 110 case CursorImageClass: |
102 return compareCSSValues<CSSCursorImageValue>(*this, other); | 111 return compareCSSValues<CSSCursorImageValue>(*this, other); |
103 case FontFaceSrcClass: | 112 case FontFaceSrcClass: |
104 return compareCSSValues<CSSFontFaceSrcValue>(*this, other); | 113 return compareCSSValues<CSSFontFaceSrcValue>(*this, other); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 default: | 162 default: |
154 ASSERT_NOT_REACHED(); | 163 ASSERT_NOT_REACHED(); |
155 return false; | 164 return false; |
156 } | 165 } |
157 } | 166 } |
158 return false; | 167 return false; |
159 } | 168 } |
160 | 169 |
161 String CSSValue::cssText() const | 170 String CSSValue::cssText() const |
162 { | 171 { |
| 172 if (isTaggedPtr()) |
| 173 return toCSSPrimitiveValue(this)->customCSSText(); |
| 174 |
163 switch (classType()) { | 175 switch (classType()) { |
164 case BorderImageSliceClass: | 176 case BorderImageSliceClass: |
165 return toCSSBorderImageSliceValue(this)->customCSSText(); | 177 return toCSSBorderImageSliceValue(this)->customCSSText(); |
166 case CanvasClass: | 178 case CanvasClass: |
167 return toCSSCanvasValue(this)->customCSSText(); | 179 return toCSSCanvasValue(this)->customCSSText(); |
168 case CursorImageClass: | 180 case CursorImageClass: |
169 return toCSSCursorImageValue(this)->customCSSText(); | 181 return toCSSCursorImageValue(this)->customCSSText(); |
170 case FontFaceSrcClass: | 182 case FontFaceSrcClass: |
171 return toCSSFontFaceSrcValue(this)->customCSSText(); | 183 return toCSSFontFaceSrcValue(this)->customCSSText(); |
172 case FontFeatureClass: | 184 case FontFeatureClass: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 return toCSSSVGDocumentValue(this)->customCSSText(); | 229 return toCSSSVGDocumentValue(this)->customCSSText(); |
218 case CSSContentDistributionClass: | 230 case CSSContentDistributionClass: |
219 return toCSSContentDistributionValue(this)->customCSSText(); | 231 return toCSSContentDistributionValue(this)->customCSSText(); |
220 } | 232 } |
221 ASSERT_NOT_REACHED(); | 233 ASSERT_NOT_REACHED(); |
222 return String(); | 234 return String(); |
223 } | 235 } |
224 | 236 |
225 void CSSValue::destroy() | 237 void CSSValue::destroy() |
226 { | 238 { |
| 239 if (isTaggedPtr()) |
| 240 return; |
| 241 |
227 switch (classType()) { | 242 switch (classType()) { |
228 case BorderImageSliceClass: | 243 case BorderImageSliceClass: |
229 delete toCSSBorderImageSliceValue(this); | 244 delete toCSSBorderImageSliceValue(this); |
230 return; | 245 return; |
231 case CanvasClass: | 246 case CanvasClass: |
232 delete toCSSCanvasValue(this); | 247 delete toCSSCanvasValue(this); |
233 return; | 248 return; |
234 case CursorImageClass: | 249 case CursorImageClass: |
235 delete toCSSCursorImageValue(this); | 250 delete toCSSCursorImageValue(this); |
236 return; | 251 return; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 return; | 323 return; |
309 case CSSContentDistributionClass: | 324 case CSSContentDistributionClass: |
310 delete toCSSContentDistributionValue(this); | 325 delete toCSSContentDistributionValue(this); |
311 return; | 326 return; |
312 } | 327 } |
313 ASSERT_NOT_REACHED(); | 328 ASSERT_NOT_REACHED(); |
314 } | 329 } |
315 | 330 |
316 void CSSValue::finalizeGarbageCollectedObject() | 331 void CSSValue::finalizeGarbageCollectedObject() |
317 { | 332 { |
| 333 if (isTaggedPtr()) |
| 334 return; |
| 335 |
318 switch (classType()) { | 336 switch (classType()) { |
319 case BorderImageSliceClass: | 337 case BorderImageSliceClass: |
320 toCSSBorderImageSliceValue(this)->~CSSBorderImageSliceValue(); | 338 toCSSBorderImageSliceValue(this)->~CSSBorderImageSliceValue(); |
321 return; | 339 return; |
322 case CanvasClass: | 340 case CanvasClass: |
323 toCSSCanvasValue(this)->~CSSCanvasValue(); | 341 toCSSCanvasValue(this)->~CSSCanvasValue(); |
324 return; | 342 return; |
325 case CursorImageClass: | 343 case CursorImageClass: |
326 toCSSCursorImageValue(this)->~CSSCursorImageValue(); | 344 toCSSCursorImageValue(this)->~CSSCursorImageValue(); |
327 return; | 345 return; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 return; | 417 return; |
400 case CSSContentDistributionClass: | 418 case CSSContentDistributionClass: |
401 toCSSContentDistributionValue(this)->~CSSContentDistributionValue(); | 419 toCSSContentDistributionValue(this)->~CSSContentDistributionValue(); |
402 return; | 420 return; |
403 } | 421 } |
404 ASSERT_NOT_REACHED(); | 422 ASSERT_NOT_REACHED(); |
405 } | 423 } |
406 | 424 |
407 DEFINE_TRACE(CSSValue) | 425 DEFINE_TRACE(CSSValue) |
408 { | 426 { |
| 427 if (isTaggedPtr()) |
| 428 return; |
| 429 |
409 switch (classType()) { | 430 switch (classType()) { |
410 case BorderImageSliceClass: | 431 case BorderImageSliceClass: |
411 toCSSBorderImageSliceValue(this)->traceAfterDispatch(visitor); | 432 toCSSBorderImageSliceValue(this)->traceAfterDispatch(visitor); |
412 return; | 433 return; |
413 case CanvasClass: | 434 case CanvasClass: |
414 toCSSCanvasValue(this)->traceAfterDispatch(visitor); | 435 toCSSCanvasValue(this)->traceAfterDispatch(visitor); |
415 return; | 436 return; |
416 case CursorImageClass: | 437 case CursorImageClass: |
417 toCSSCursorImageValue(this)->traceAfterDispatch(visitor); | 438 toCSSCursorImageValue(this)->traceAfterDispatch(visitor); |
418 return; | 439 return; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 case CSSSVGDocumentClass: | 509 case CSSSVGDocumentClass: |
489 toCSSSVGDocumentValue(this)->traceAfterDispatch(visitor); | 510 toCSSSVGDocumentValue(this)->traceAfterDispatch(visitor); |
490 return; | 511 return; |
491 case CSSContentDistributionClass: | 512 case CSSContentDistributionClass: |
492 toCSSContentDistributionValue(this)->traceAfterDispatch(visitor); | 513 toCSSContentDistributionValue(this)->traceAfterDispatch(visitor); |
493 return; | 514 return; |
494 } | 515 } |
495 ASSERT_NOT_REACHED(); | 516 ASSERT_NOT_REACHED(); |
496 } | 517 } |
497 | 518 |
498 } | 519 } // namespace blink |
OLD | NEW |