| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 // Implicit conversion from CSSPrimitiveValue. | 74 // Implicit conversion from CSSPrimitiveValue. |
| 75 CSSValue(const 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 // Although m_data can't be null, a move constructor from NullableCSSVal
ue |
| 84 // could make it null for a short time. |
| 85 if (m_data) |
| 86 deref(); |
| 84 } | 87 } |
| 85 | 88 |
| 86 CSSValue& operator=(const CSSValue& rhs) | 89 CSSValue& operator=(const CSSValue& rhs) |
| 87 { | 90 { |
| 88 rhs.ref(); | 91 rhs.ref(); |
| 89 deref(); | 92 deref(); |
| 90 m_data = rhs.m_data; | 93 m_data = rhs.m_data; |
| 91 return *this; | 94 return *this; |
| 92 } | 95 } |
| 93 | 96 |
| 97 CSSValue& operator=(CSSValue&& rhs) |
| 98 { |
| 99 m_data = rhs.m_data; |
| 100 rhs.m_data.clear(); |
| 101 return *this; |
| 102 } |
| 103 |
| 104 CSSValue(CSSValue&& rhs) |
| 105 { |
| 106 m_data = rhs.m_data; |
| 107 } |
| 108 |
| 94 bool operator==(const CSSValue& other) const | 109 bool operator==(const CSSValue& other) const |
| 95 { | 110 { |
| 96 if (m_data == other.m_data) | 111 if (m_data == other.m_data) |
| 97 return true; | 112 return true; |
| 98 if (!isObject() || !other.isObject()) | 113 if (!isObject() || !other.isObject()) |
| 99 return false; | 114 return false; |
| 100 return m_data->equals(*other.m_data); | 115 return m_data->equals(*other.m_data); |
| 101 } | 116 } |
| 102 | 117 |
| 103 // TODO: Remove this and update callsites to use operator== instead. | 118 // TODO: Remove this and update callsites to use operator== instead. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 ~NullableCSSValue() | 277 ~NullableCSSValue() |
| 263 { | 278 { |
| 264 deref(); | 279 deref(); |
| 265 }; | 280 }; |
| 266 | 281 |
| 267 explicit operator bool() const | 282 explicit operator bool() const |
| 268 { | 283 { |
| 269 return m_data; | 284 return m_data; |
| 270 } | 285 } |
| 271 | 286 |
| 287 NullableCSSValue(NullableCSSValue&& rhs) |
| 288 { |
| 289 m_data = rhs.m_data; |
| 290 rhs.m_data = nullptr; |
| 291 } |
| 292 |
| 272 NullableCSSValue& operator=(const NullableCSSValue& rhs) | 293 NullableCSSValue& operator=(const NullableCSSValue& rhs) |
| 273 { | 294 { |
| 274 rhs.ref(); | 295 rhs.ref(); |
| 275 deref(); | 296 deref(); |
| 276 m_data = rhs.m_data; | 297 m_data = rhs.m_data; |
| 277 return *this; | 298 return *this; |
| 278 } | 299 } |
| 279 | 300 |
| 301 NullableCSSValue& operator=(NullableCSSValue&& rhs) |
| 302 { |
| 303 m_data = rhs.m_data; |
| 304 rhs.m_data.clear(); |
| 305 return *this; |
| 306 } |
| 307 |
| 280 bool operator==(const NullableCSSValue& rhs) const | 308 bool operator==(const NullableCSSValue& rhs) const |
| 281 { | 309 { |
| 282 if (m_data == rhs.m_data) | 310 if (m_data == rhs.m_data) |
| 283 return true; | 311 return true; |
| 284 if (!isObject() || (rhs && !rhs.isObject())) | 312 if (!isObject() || (rhs && !rhs.isObject())) |
| 285 return false; | 313 return false; |
| 286 return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(rhs.m_
data); | 314 return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(rhs.m_
data); |
| 287 } | 315 } |
| 288 | 316 |
| 289 bool operator!=(const NullableCSSValue& rhs) const | 317 bool operator!=(const NullableCSSValue& rhs) const |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 return *const_cast<CSSPrimitiveValue*>(reinterpret_cast<const CSSPrimitiveVa
lue*>(&value)); | 442 return *const_cast<CSSPrimitiveValue*>(reinterpret_cast<const CSSPrimitiveVa
lue*>(&value)); |
| 415 } | 443 } |
| 416 */ | 444 */ |
| 417 | 445 |
| 418 } // namespace blink | 446 } // namespace blink |
| 419 | 447 |
| 420 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); | 448 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); |
| 421 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); | 449 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); |
| 422 | 450 |
| 423 #endif // CSSValue_h | 451 #endif // CSSValue_h |
| OLD | NEW |