Bumping manifests a=b2g-bump
[gecko.git] / dom / base / nsWrapperCacheInlines.h
blob6eec9de9d97528e850f290c1d853e3226ea10acb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsWrapperCacheInline_h___
7 #define nsWrapperCacheInline_h___
9 #include "nsWrapperCache.h"
10 #include "js/GCAPI.h"
11 #include "js/TracingAPI.h"
13 inline JSObject*
14 nsWrapperCache::GetWrapper() const
16 JSObject* obj = GetWrapperPreserveColor();
17 if (obj) {
18 JS::ExposeObjectToActiveJS(obj);
20 return obj;
23 inline bool
24 nsWrapperCache::IsBlack()
26 JSObject* o = GetWrapperPreserveColor();
27 return o && !JS::GCThingIsMarkedGray(o);
30 static void
31 SearchGray(void* aGCThing, const char* aName, void* aClosure)
33 bool* hasGrayObjects = static_cast<bool*>(aClosure);
34 if (!*hasGrayObjects && aGCThing && JS::GCThingIsMarkedGray(aGCThing)) {
35 *hasGrayObjects = true;
39 inline bool
40 nsWrapperCache::HasNothingToTrace(nsISupports* aThis)
42 nsXPCOMCycleCollectionParticipant* participant = nullptr;
43 CallQueryInterface(aThis, &participant);
44 bool hasGrayObjects = false;
45 participant->Trace(aThis, TraceCallbackFunc(SearchGray), &hasGrayObjects);
46 return !hasGrayObjects;
49 inline bool
50 nsWrapperCache::IsBlackAndDoesNotNeedTracing(nsISupports* aThis)
52 return IsBlack() && HasNothingToTrace(aThis);
55 inline void
56 nsWrapperCache::TraceWrapperJSObject(JSTracer* aTrc, const char* aName)
58 JS_CallObjectTracer(aTrc, &mWrapper, aName);
61 #endif /* nsWrapperCache_h___ */