| 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, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 inline bool isTaggedPtr() const | 438 inline bool isTaggedPtr() const |
| 439 { | 439 { |
| 440 return reinterpret_cast<uintptr_t>(this) & 1; | 440 return reinterpret_cast<uintptr_t>(this) & 1; |
| 441 } | 441 } |
| 442 | 442 |
| 443 static inline CSSPrimitiveValue* toPtr(CSSTaggedPtrValue taggedPtr) | 443 static inline CSSPrimitiveValue* toPtr(CSSTaggedPtrValue taggedPtr) |
| 444 { | 444 { |
| 445 return reinterpret_cast<CSSPrimitiveValue*&>(taggedPtr); | 445 return reinterpret_cast<CSSPrimitiveValue*&>(taggedPtr); |
| 446 } | 446 } |
| 447 | 447 |
| 448 inline CSSTaggedPtrValue toTaggedPtr() const | |
| 449 { | |
| 450 CSSPrimitiveValue* nonConstThis = const_cast<CSSPrimitiveValue*>(this); | |
| 451 return reinterpret_cast<CSSTaggedPtrValue&&>(nonConstThis); | |
| 452 } | |
| 453 | |
| 454 inline UnitType type() const | 448 inline UnitType type() const |
| 455 { | 449 { |
| 456 if (!isTaggedPtr()) | 450 if (!isTaggedPtr()) |
| 457 return static_cast<UnitType>(m_primitiveUnitType); | 451 return static_cast<UnitType>(m_primitiveUnitType); |
| 458 return static_cast<UnitType>(toTaggedPtr().type); | 452 |
| 453 const CSSPrimitiveValue* const& lValue = this; |
| 454 const CSSTaggedPtrValue& taggedPtr = reinterpret_cast<const CSSTaggedPtr
Value&>(lValue); |
| 455 return static_cast<UnitType>(taggedPtr.type); |
| 459 } | 456 } |
| 460 | 457 |
| 461 inline CSSPrimitiveValueData value() const | 458 inline CSSPrimitiveValueData value() const |
| 462 { | 459 { |
| 463 if (!isTaggedPtr()) | 460 if (!isTaggedPtr()) |
| 464 return m_value; | 461 return m_value; |
| 465 | 462 |
| 466 CSSPrimitiveValueData data; | 463 CSSPrimitiveValueData data; |
| 464 const CSSPrimitiveValue* const& lValue = this; |
| 465 const CSSTaggedPtrValue& taggedPtr = reinterpret_cast<const CSSTaggedPtr
Value&>(lValue); |
| 467 switch (type()) { | 466 switch (type()) { |
| 468 case CSSPrimitiveValue::CSS_PROPERTY_ID: | 467 case CSSPrimitiveValue::CSS_PROPERTY_ID: |
| 469 data.propertyID = static_cast<CSSPropertyID>(toTaggedPtr().value); | 468 data.propertyID = static_cast<CSSPropertyID>(taggedPtr.value); |
| 470 break; | 469 break; |
| 471 case CSSPrimitiveValue::CSS_VALUE_ID: | 470 case CSSPrimitiveValue::CSS_VALUE_ID: |
| 472 data.valueID = static_cast<CSSValueID>(toTaggedPtr().value); | 471 data.valueID = static_cast<CSSValueID>(taggedPtr.value); |
| 473 break; | 472 break; |
| 474 case CSSPrimitiveValue::CSS_RGBCOLOR: { | 473 case CSSPrimitiveValue::CSS_RGBCOLOR: { |
| 475 uintptr_t valueRawVar = toTaggedPtr().value; | 474 uintptr_t colorRaw = taggedPtr.value; |
| 476 packedColor color = *reinterpret_cast<packedColor*>(&valueRawVar); | 475 packedColor color = reinterpret_cast<packedColor&>(colorRaw); |
| 477 unsigned alpha; | 476 unsigned alpha; |
| 478 #if CPU(32BIT) | 477 #if CPU(32BIT) |
| 479 alpha = color.alpha == 1 ? 255 : 0; | 478 alpha = color.alpha == 1 ? 255 : 0; |
| 480 #elif CPU(64BIT) | 479 #elif CPU(64BIT) |
| 481 alpha = color.alpha; | 480 alpha = color.alpha; |
| 482 #endif | 481 #endif |
| 483 data.rgbcolor = makeRGBA(color.red, color.green, color.blue, alpha); | 482 data.rgbcolor = makeRGBA(color.red, color.green, color.blue, alpha); |
| 484 break; | 483 break; |
| 485 } | 484 } |
| 486 default: | 485 default: |
| 487 uint64_t shiftedValue = toTaggedPtr().value; | 486 uint64_t shiftedValue = taggedPtr.value; |
| 488 shiftedValue = shiftedValue << doubleShiftAmount; | 487 shiftedValue = shiftedValue << doubleShiftAmount; |
| 489 data.num = *reinterpret_cast<double*>(&shiftedValue); | 488 data.num = reinterpret_cast<double&>(shiftedValue); |
| 490 break; | 489 break; |
| 491 } | 490 } |
| 492 return data; | 491 return data; |
| 493 } | 492 } |
| 494 | 493 |
| 495 CSSPrimitiveValueData m_value; | 494 CSSPrimitiveValueData m_value; |
| 496 }; | 495 }; |
| 497 | 496 |
| 498 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; | 497 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; |
| 499 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; | 498 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 511 // Immediates (non-pointers) end in a 1. | 510 // Immediates (non-pointers) end in a 1. |
| 512 if (!(reinterpret_cast<uintptr_t>(p) & 1)) | 511 if (!(reinterpret_cast<uintptr_t>(p) & 1)) |
| 513 adopted(p); | 512 adopted(p); |
| 514 return PassRefPtr<blink::CSSPrimitiveValue>(p, PassRefPtr<blink::CSSPrimitiv
eValue>::AdoptRef); | 513 return PassRefPtr<blink::CSSPrimitiveValue>(p, PassRefPtr<blink::CSSPrimitiv
eValue>::AdoptRef); |
| 515 } | 514 } |
| 516 #endif | 515 #endif |
| 517 | 516 |
| 518 } // namespace WTF | 517 } // namespace WTF |
| 519 | 518 |
| 520 #endif // CSSPrimitiveValue_h | 519 #endif // CSSPrimitiveValue_h |
| OLD | NEW |