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(); |
73 } | 76 } |
74 | 77 |
75 CSSValue& operator=(const CSSValue& rhs) | 78 CSSValue& operator=(const CSSValue& rhs) |
76 { | 79 { |
77 rhs.ref(); | 80 rhs.ref(); |
78 deref(); | 81 deref(); |
79 m_data = rhs.m_data; | 82 m_data = rhs.m_data; |
80 return *this; | 83 return *this; |
81 } | 84 } |
82 | 85 |
| 86 CSSValue& operator=(CSSValue&& rhs) |
| 87 { |
| 88 m_data = rhs.m_data; |
| 89 rhs.m_data.clear(); |
| 90 return *this; |
| 91 } |
| 92 |
| 93 CSSValue(CSSValue&& rhs) |
| 94 { |
| 95 m_data = rhs.m_data; |
| 96 } |
| 97 |
83 bool operator==(const CSSValue& other) const | 98 bool operator==(const CSSValue& other) const |
84 { | 99 { |
85 return m_data->equals(*other.m_data); | 100 return m_data->equals(*other.m_data); |
86 } | 101 } |
87 | 102 |
88 // TODO: Remove this and update callsites to use operator== instead. | 103 // TODO: Remove this and update callsites to use operator== instead. |
89 bool equals(const CSSValue& other) const | 104 bool equals(const CSSValue& other) const |
90 { | 105 { |
91 return m_data->equals(*other.m_data); | 106 return m_data->equals(*other.m_data); |
92 } | 107 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 ~NullableCSSValue() | 239 ~NullableCSSValue() |
225 { | 240 { |
226 deref(); | 241 deref(); |
227 }; | 242 }; |
228 | 243 |
229 operator bool() const | 244 operator bool() const |
230 { | 245 { |
231 return m_data; | 246 return m_data; |
232 } | 247 } |
233 | 248 |
| 249 NullableCSSValue(NullableCSSValue&& rhs) |
| 250 { |
| 251 m_data = rhs.m_data; |
| 252 rhs.m_data = nullptr; |
| 253 } |
| 254 |
234 NullableCSSValue& operator=(const NullableCSSValue& rhs) | 255 NullableCSSValue& operator=(const NullableCSSValue& rhs) |
235 { | 256 { |
236 rhs.ref(); | 257 rhs.ref(); |
237 deref(); | 258 deref(); |
238 m_data = rhs.m_data; | 259 m_data = rhs.m_data; |
239 return *this; | 260 return *this; |
240 } | 261 } |
241 | 262 |
242 bool operator==(const NullableCSSValue& rhs) | 263 NullableCSSValue& operator=(NullableCSSValue&& rhs) |
| 264 { |
| 265 m_data = rhs.m_data; |
| 266 rhs.m_data.clear(); |
| 267 return *this; |
| 268 } |
| 269 |
| 270 bool operator==(const NullableCSSValue& rhs) const |
243 { | 271 { |
244 return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(rhs.m_
data); | 272 return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(rhs.m_
data); |
245 } | 273 } |
246 | 274 |
247 bool operator!=(const NullableCSSValue& rhs) | 275 bool operator!=(const NullableCSSValue& rhs) |
248 { | 276 { |
249 return !(*this == rhs); | 277 return !(*this == rhs); |
250 } | 278 } |
251 | 279 |
252 CSSValue& operator*() | 280 CSSValue& operator*() |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \ | 375 ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \ |
348 return static_cast<thisType*>(value.get()); \ | 376 return static_cast<thisType*>(value.get()); \ |
349 } | 377 } |
350 | 378 |
351 } // namespace blink | 379 } // namespace blink |
352 | 380 |
353 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); | 381 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue); |
354 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); | 382 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); |
355 | 383 |
356 #endif // CSSValue_h | 384 #endif // CSSValue_h |
OLD | NEW |