OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 #endif | 66 #endif |
67 | 67 |
68 CSSValue(const CSSValue& cssValue) | 68 CSSValue(const CSSValue& cssValue) |
69 : m_data(cssValue.m_data) | 69 : m_data(cssValue.m_data) |
70 { | 70 { |
71 ref(); | 71 ref(); |
72 } | 72 } |
73 | 73 |
74 // Implicit conversion from CSSPrimitiveValue. | 74 // Implicit conversion from CSSPrimitiveValue. |
75 CSSValue(CSSPrimitiveValue cssPrimitiveValue) | 75 CSSValue(const CSSPrimitiveValue& cssPrimitiveValue) |
76 : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get())) | 76 : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get())) |
77 { | 77 { |
78 ref(); | 78 ref(); |
79 } | 79 } |
80 | 80 |
81 ~CSSValue() | 81 ~CSSValue() |
82 { | 82 { |
83 deref(); | 83 deref(); |
84 } | 84 } |
85 | 85 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 ref(); | 246 ref(); |
247 } | 247 } |
248 | 248 |
249 NullableCSSValue(const CSSValue& cssValue) | 249 NullableCSSValue(const CSSValue& cssValue) |
250 : m_data(cssValue.m_data) | 250 : m_data(cssValue.m_data) |
251 { | 251 { |
252 ref(); | 252 ref(); |
253 } | 253 } |
254 | 254 |
255 // Implicit conversion from CSSPrimitiveValue. | 255 // Implicit conversion from CSSPrimitiveValue. |
256 NullableCSSValue(CSSPrimitiveValue cssPrimitiveValue) | 256 NullableCSSValue(const CSSPrimitiveValue& cssPrimitiveValue) |
257 : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get())) | 257 : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get())) |
258 { | 258 { |
259 ref(); | 259 ref(); |
260 } | 260 } |
261 | 261 |
262 ~NullableCSSValue() | 262 ~NullableCSSValue() |
263 { | 263 { |
264 deref(); | 264 deref(); |
265 }; | 265 }; |
266 | 266 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 { | 356 { |
357 return !(*reinterpret_cast<const uintptr_t*>(&m_data) & 1); | 357 return !(*reinterpret_cast<const uintptr_t*>(&m_data) & 1); |
358 } | 358 } |
359 | 359 |
360 RawPtrWillBeMember<CSSValueObject> m_data; | 360 RawPtrWillBeMember<CSSValueObject> m_data; |
361 }; | 361 }; |
362 | 362 |
363 static_assert(sizeof(CSSValue) == sizeof(void*), "CSSValue should be pointer-siz
ed"); | 363 static_assert(sizeof(CSSValue) == sizeof(void*), "CSSValue should be pointer-siz
ed"); |
364 static_assert(sizeof(NullableCSSValue) == sizeof(void*), "CSSValue should be poi
nter-sized"); | 364 static_assert(sizeof(NullableCSSValue) == sizeof(void*), "CSSValue should be poi
nter-sized"); |
365 static_assert(sizeof(CSSValue) == sizeof(NullableCSSValue), "Both CSSValue conta
iners must contain the same data"); | 365 static_assert(sizeof(CSSValue) == sizeof(NullableCSSValue), "Both CSSValue conta
iners must contain the same data"); |
| 366 static_assert(sizeof(CSSValue) == sizeof(CSSPrimitiveValue), "Both CSSValue and
CSSPrimitiveValue must contain the same data"); |
366 | 367 |
367 template<size_t inlineCapacity> | 368 template<size_t inlineCapacity> |
368 inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacit
y>& firstVector, const WillBeHeapVector<CSSValue, inlineCapacity>& secondVector) | 369 inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacit
y>& firstVector, const WillBeHeapVector<CSSValue, inlineCapacity>& secondVector) |
369 { | 370 { |
370 size_t size = firstVector.size(); | 371 size_t size = firstVector.size(); |
371 if (size != secondVector.size()) | 372 if (size != secondVector.size()) |
372 return false; | 373 return false; |
373 | 374 |
374 for (size_t i = 0; i < size; i++) { | 375 for (size_t i = 0; i < size; i++) { |
375 const CSSValue& firstPtr = firstVector[i]; | 376 const CSSValue& firstPtr = firstVector[i]; |
(...skipping 14 matching lines...) Expand all Loading... |
390 } \ | 391 } \ |
391 inline thisType* to##thisType(const NullableCSSValue& value) \ | 392 inline thisType* to##thisType(const NullableCSSValue& value) \ |
392 { \ | 393 { \ |
393 if (!value) \ | 394 if (!value) \ |
394 return nullptr; \ | 395 return nullptr; \ |
395 ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \ | 396 ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \ |
396 return static_cast<thisType*>(value.get()); \ | 397 return static_cast<thisType*>(value.get()); \ |
397 } | 398 } |
398 | 399 |
399 // Returns by value on purpose. | 400 // Returns by value on purpose. |
400 inline CSSPrimitiveValue toCSSPrimitiveValue(const CSSValue& value) | 401 inline const CSSPrimitiveValue& toCSSPrimitiveValue(const CSSValue& value) |
401 { | 402 { |
402 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); | 403 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); |
403 return CSSPrimitiveValue(static_cast<CSSPrimitiveValue::CSSLargePrimitiveVal
ue*>(value.get())); | 404 return *reinterpret_cast<const CSSPrimitiveValue*>(&value); |
404 } | 405 } |
| 406 /* |
| 407 inline CSSPrimitiveValue& toCSSPrimitiveValue(const CSSValue& value) |
| 408 { |
| 409 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); |
| 410 return *const_cast<CSSPrimitiveValue*>(reinterpret_cast<const CSSPrimitiveVa
lue*>(&value)); |
| 411 } |
| 412 */ |
405 | 413 |
406 } // namespace blink | 414 } // namespace blink |
407 | 415 |
408 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); | 416 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); |
409 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); | 417 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); |
410 | 418 |
411 #endif // CSSValue_h | 419 #endif // CSSValue_h |
OLD | NEW |