@@ -99,64 +99,6 @@ namespace widget {
99
99
struct IMEState ;
100
100
} // namespace widget
101
101
102
- /* *
103
- * CachedWeakPtr stores a pointer to a class which inherits nsIWeakReference.
104
- * If the instance of the class has already been destroyed, this returns
105
- * nullptr. Otherwise, returns cached pointer.
106
- * If class T inherits nsISupports a lot, specify Base explicitly for avoiding
107
- * ambiguous conversion to nsISupports.
108
- */
109
- template <class T , class Base = nsISupports>
110
- class CachedWeakPtr final {
111
- public:
112
- CachedWeakPtr<T, Base>() : mCache (nullptr ) {}
113
- explicit CachedWeakPtr<T, Base>(T* aObject) {
114
- mWeakPtr = do_GetWeakReference (static_cast <Base*>(aObject));
115
- mCache = aObject;
116
- }
117
- explicit CachedWeakPtr<T, Base>(const nsCOMPtr<T>& aOther) {
118
- mWeakPtr = do_GetWeakReference (static_cast <Base*>(aOther.get ()));
119
- mCache = aOther;
120
- }
121
- explicit CachedWeakPtr<T, Base>(already_AddRefed<T>& aOther) {
122
- RefPtr<T> other = aOther;
123
- mWeakPtr = do_GetWeakReference (static_cast <Base*>(other.get ()));
124
- mCache = other;
125
- }
126
-
127
- CachedWeakPtr<T, Base>& operator =(T* aObject) {
128
- mWeakPtr = do_GetWeakReference (static_cast <Base*>(aObject));
129
- mCache = aObject;
130
- return *this ;
131
- }
132
- CachedWeakPtr<T, Base>& operator =(const nsCOMPtr<T>& aOther) {
133
- mWeakPtr = do_GetWeakReference (static_cast <Base*>(aOther.get ()));
134
- mCache = aOther;
135
- return *this ;
136
- }
137
- CachedWeakPtr<T, Base>& operator =(already_AddRefed<T>& aOther) {
138
- RefPtr<T> other = aOther;
139
- mWeakPtr = do_GetWeakReference (static_cast <Base*>(other.get ()));
140
- mCache = other;
141
- return *this ;
142
- }
143
-
144
- bool IsAlive () const { return mWeakPtr && mWeakPtr ->IsAlive (); }
145
-
146
- explicit operator bool () const { return mWeakPtr ; }
147
- operator T*() const { return get (); }
148
- T* get () const {
149
- if (mCache && !mWeakPtr ->IsAlive ()) {
150
- const_cast <CachedWeakPtr<T, Base>*>(this )->mCache = nullptr ;
151
- }
152
- return mCache ;
153
- }
154
-
155
- private:
156
- nsWeakPtr mWeakPtr ;
157
- T* MOZ_NON_OWNING_REF mCache ;
158
- };
159
-
160
102
#define kMOZEditorBogusNodeAttrAtom nsGkAtoms::mozeditorbogusnode
161
103
#define kMOZEditorBogusNodeValue NS_LITERAL_STRING (" TRUE" )
162
104
0 commit comments