| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #endif | 62 #endif |
| 63 | 63 |
| 64 CSSValue(const CSSValue& cssValue) | 64 CSSValue(const CSSValue& cssValue) |
| 65 : m_data(cssValue.m_data) | 65 : m_data(cssValue.m_data) |
| 66 { | 66 { |
| 67 ref(); | 67 ref(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 ~CSSValue() | 70 ~CSSValue() |
| 71 { | 71 { |
| 72 deref(); | 72 // Although m_data can't be null, a move constructor from NullableCSSVal
ue |
| 73 // could make it null for a short time. |
| 74 if (m_data) |
| 75 deref(); |
| 76 |
| 73 } | 77 } |
| 74 | 78 |
| 75 CSSValue& operator=(const CSSValue& rhs) | 79 CSSValue& operator=(const CSSValue& rhs) |
| 76 { | 80 { |
| 77 rhs.ref(); | 81 rhs.ref(); |
| 78 deref(); | 82 deref(); |
| 79 m_data = rhs.m_data; | 83 m_data = rhs.m_data; |
| 80 return *this; | 84 return *this; |
| 81 } | 85 } |
| 82 | 86 |
| 87 CSSValue& operator=(CSSValue&& rhs) |
| 88 { |
| 89 m_data = rhs.m_data; |
| 90 rhs.m_data.clear(); |
| 91 return *this; |
| 92 } |
| 93 |
| 94 CSSValue(CSSValue&& rhs) |
| 95 { |
| 96 m_data = rhs.m_data; |
| 97 } |
| 98 |
| 83 bool operator==(const CSSValue& other) const | 99 bool operator==(const CSSValue& other) const |
| 84 { | 100 { |
| 85 return m_data->equals(*other.m_data); | 101 return m_data->equals(*other.m_data); |
| 86 } | 102 } |
| 87 | 103 |
| 88 // TODO: Remove this and update callsites to use operator== instead. | 104 // TODO: Remove this and update callsites to use operator== instead. |
| 89 bool equals(const CSSValue& other) const | 105 bool equals(const CSSValue& other) const |
| 90 { | 106 { |
| 91 return m_data->equals(*other.m_data); | 107 return m_data->equals(*other.m_data); |
| 92 } | 108 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 { | 230 { |
| 215 ref(); | 231 ref(); |
| 216 } | 232 } |
| 217 | 233 |
| 218 NullableCSSValue(const CSSValue& cssValue) | 234 NullableCSSValue(const CSSValue& cssValue) |
| 219 : m_data(cssValue.m_data) | 235 : m_data(cssValue.m_data) |
| 220 { | 236 { |
| 221 ref(); | 237 ref(); |
| 222 } | 238 } |
| 223 | 239 |
| 240 NullableCSSValue(NullableCSSValue&& rhs) |
| 241 { |
| 242 m_data = rhs.m_data; |
| 243 rhs.m_data = nullptr; |
| 244 } |
| 245 |
| 246 |
| 224 ~NullableCSSValue() | 247 ~NullableCSSValue() |
| 225 { | 248 { |
| 226 deref(); | 249 deref(); |
| 227 }; | 250 }; |
| 228 | 251 |
| 229 operator bool() const | 252 operator bool() const |
| 230 { | 253 { |
| 231 return m_data; | 254 return m_data; |
| 232 } | 255 } |
| 233 | 256 |
| 234 NullableCSSValue& operator=(const NullableCSSValue& rhs) | 257 NullableCSSValue& operator=(const NullableCSSValue& rhs) |
| 235 { | 258 { |
| 236 rhs.ref(); | 259 rhs.ref(); |
| 237 deref(); | 260 deref(); |
| 238 m_data = rhs.m_data; | 261 m_data = rhs.m_data; |
| 239 return *this; | 262 return *this; |
| 240 } | 263 } |
| 241 | 264 |
| 242 bool operator==(const NullableCSSValue& rhs) | 265 NullableCSSValue& operator=(NullableCSSValue&& rhs) |
| 266 { |
| 267 m_data = rhs.m_data; |
| 268 rhs.m_data.clear(); |
| 269 return *this; |
| 270 } |
| 271 |
| 272 bool operator==(const NullableCSSValue& rhs) const |
| 243 { | 273 { |
| 244 return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(rhs.m_
data); | 274 return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(rhs.m_
data); |
| 245 } | 275 } |
| 246 | 276 |
| 247 bool operator!=(const NullableCSSValue& rhs) | 277 bool operator!=(const NullableCSSValue& rhs) |
| 248 { | 278 { |
| 249 return !(*this == rhs); | 279 return !(*this == rhs); |
| 250 } | 280 } |
| 251 | 281 |
| 252 CSSValue& operator*() | 282 CSSValue& operator*() |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \ | 377 ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \ |
| 348 return static_cast<thisType*>(value.get()); \ | 378 return static_cast<thisType*>(value.get()); \ |
| 349 } | 379 } |
| 350 | 380 |
| 351 } // namespace blink | 381 } // namespace blink |
| 352 | 382 |
| 353 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); | 383 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); |
| 354 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); | 384 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); |
| 355 | 385 |
| 356 #endif // CSSValue_h | 386 #endif // CSSValue_h |
| OLD | NEW |