OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef Nullable_h | 5 #ifndef Nullable_h |
6 #define Nullable_h | 6 #define Nullable_h |
7 | 7 |
8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
9 #include "wtf/Assertions.h" | 9 #include "wtf/Assertions.h" |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // See comment in RefPtr.h about what UnspecifiedBoolType is. | 63 // See comment in RefPtr.h about what UnspecifiedBoolType is. |
64 typedef const T* UnspecifiedBoolType; | 64 typedef const T* UnspecifiedBoolType; |
65 operator UnspecifiedBoolType() const { return m_isNull ? 0 : &m_value; } | 65 operator UnspecifiedBoolType() const { return m_isNull ? 0 : &m_value; } |
66 | 66 |
67 bool operator==(const Nullable& other) const | 67 bool operator==(const Nullable& other) const |
68 { | 68 { |
69 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull &&
m_value == other.m_value); | 69 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull &&
m_value == other.m_value); |
70 } | 70 } |
71 | 71 |
72 void trace(Visitor* visitor) | 72 DEFINE_INLINE_TRACE() |
73 { | 73 { |
74 TraceIfNeeded<T>::trace(visitor, &m_value); | 74 TraceIfNeeded<T>::trace(visitor, &m_value); |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 T m_value; | 78 T m_value; |
79 bool m_isNull; | 79 bool m_isNull; |
80 }; | 80 }; |
81 | 81 |
82 } // namespace blink | 82 } // namespace blink |
83 | 83 |
84 #endif // Nullable_h | 84 #endif // Nullable_h |
OLD | NEW |