Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/Nullable.h

Issue 2145643002: Purge UnspecifiedBoolType from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/api/LayoutItem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void set(std::nullptr_t) 58 void set(std::nullptr_t)
59 { 59 {
60 m_value = T(); 60 m_value = T();
61 m_isNull = true; 61 m_isNull = true;
62 } 62 }
63 63
64 const T& get() const { ASSERT(!m_isNull); return m_value; } 64 const T& get() const { ASSERT(!m_isNull); return m_value; }
65 T& get() { ASSERT(!m_isNull); return m_value; } 65 T& get() { ASSERT(!m_isNull); return m_value; }
66 bool isNull() const { return m_isNull; } 66 bool isNull() const { return m_isNull; }
67 67
68 // See comment in RefPtr.h about what UnspecifiedBoolType is. 68 explicit operator bool() const { return !m_isNull; }
69 typedef const T* UnspecifiedBoolType;
70 operator UnspecifiedBoolType() const { return m_isNull ? 0 : &m_value; }
71 69
72 bool operator==(const Nullable& other) const 70 bool operator==(const Nullable& other) const
73 { 71 {
74 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && m_value == other.m_value); 72 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && m_value == other.m_value);
75 } 73 }
76 74
77 DEFINE_INLINE_TRACE() 75 DEFINE_INLINE_TRACE()
78 { 76 {
79 TraceIfNeeded<T>::trace(visitor, m_value); 77 TraceIfNeeded<T>::trace(visitor, m_value);
80 } 78 }
81 79
82 private: 80 private:
83 T m_value; 81 T m_value;
84 bool m_isNull; 82 bool m_isNull;
85 }; 83 };
86 84
87 } // namespace blink 85 } // namespace blink
88 86
89 #endif // Nullable_h 87 #endif // Nullable_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/api/LayoutItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698