Bug 851465 - Remove slim wrappers - remove slim wrapper macros and rename WN macros. r=bholley.
authorPeter Van der Beken <peterv@propagandism.org>
Fri, 19 Apr 2013 21:58:30 +0200
changeset 142203 aed026a38816dce5355eb6e2f871162a154b51bd
parent 142202 90634822b94d7f310e9c4765df1056f3e3afab00
child 142204 d1b5389de54e07206b2c73b3c424ee8343a08955
push idunknown
push userunknown
push dateunknown
reviewersbholley
bugs851465
milestone24.0a1
Bug 851465 - Remove slim wrappers - remove slim wrapper macros and rename WN macros. r=bholley.
caps/src/nsScriptSecurityManager.cpp
dom/base/nsDOMClassInfo.cpp
js/xpconnect/src/XPCCallContext.cpp
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCJSID.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCQuickStubs.cpp
js/xpconnect/src/XPCVariant.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/src/xpcpublic.h
js/xpconnect/wrappers/AccessCheck.cpp
js/xpconnect/wrappers/WrapperFactory.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -2085,17 +2085,17 @@ nsScriptSecurityManager::old_doGetObject
             jsClass = js::GetObjectClass(obj);
         }
     }
 
     do {
         // Note: jsClass is set before this loop, and also at the
         // *end* of this loop.
         
-        if (IS_WRAPPER_CLASS(jsClass)) {
+        if (IS_WN_CLASS(jsClass)) {
             result = nsXPConnect::XPConnect()->GetPrincipal(obj,
                                                             aAllowShortCircuit);
             if (result) {
                 break;
             }
         } else {
             nsISupports *priv;
             if (!(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -4254,17 +4254,17 @@ ContentWindowGetter(JSContext *cx, unsig
 }
 
 template<class Interface>
 static nsresult
 LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
 {
   // This function duplicates some of the logic in XPC_WN_HelperSetProperty
   obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
-  if (!IS_WN_WRAPPER(obj))
+  if (!IS_WN_REFLECTOR(obj))
       return NS_ERROR_XPC_BAD_CONVERT_JS;
   XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);
 
   // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
   NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
 
   nsCOMPtr<Interface> xpcomObj = do_QueryWrappedNative(wrapper, obj);
   NS_ENSURE_TRUE(xpcomObj, NS_ERROR_UNEXPECTED);
--- a/js/xpconnect/src/XPCCallContext.cpp
+++ b/js/xpconnect/src/XPCCallContext.cpp
@@ -93,17 +93,17 @@ XPCCallContext::XPCCallContext(XPCContex
         mWrapper = UnwrapThisIfAllowed(obj, funobj, argc);
         if (!mWrapper) {
             JS_ReportError(mJSContext, "Permission denied to call method on |this|");
             mState = INIT_FAILED;
             return;
         }
     } else {
         js::Class *clasp = js::GetObjectClass(unwrapped);
-        if (IS_WRAPPER_CLASS(clasp)) {
+        if (IS_WN_CLASS(clasp)) {
             mWrapper = XPCWrappedNative::Get(unwrapped);
         } else if (IS_TEAROFF_CLASS(clasp)) {
             mTearOff = (XPCWrappedNativeTearOff*)js::GetObjectPrivate(unwrapped);
             mWrapper = XPCWrappedNative::Get(js::GetObjectParent(unwrapped));
         }
     }
     if (mWrapper) {
         mFlattenedJSObject = mWrapper->GetFlatJSObject();
@@ -416,18 +416,17 @@ XPCCallContext::UnwrapThisIfAllowed(Hand
 
     // First, get the XPCWN out of the underlying object. We should have a wrapper
     // here, potentially an outer window proxy, and then an XPCWN.
     MOZ_ASSERT(js::IsWrapper(obj));
     RootedObject unwrapped(mJSContext, js::UncheckedUnwrap(obj, /* stopAtOuter = */ false));
     MOZ_ASSERT(unwrapped == JS_ObjectToInnerObject(mJSContext, js::Wrapper::wrappedObject(obj)));
 
     // Make sure we have an XPCWN, and grab it.
-    MOZ_ASSERT(!IS_SLIM_WRAPPER(unwrapped), "security wrapping morphs slim wrappers");
-    if (!IS_WRAPPER_CLASS(js::GetObjectClass(unwrapped)))
+    if (!IS_WN_REFLECTOR(unwrapped))
         return nullptr;
     XPCWrappedNative *wn = (XPCWrappedNative*)js::GetObjectPrivate(unwrapped);
 
     // Next, get the call info off the function object.
     XPCNativeInterface *interface;
     XPCNativeMember *member;
     XPCNativeMember::GetCallInfo(fun, &interface, &member);
 
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3307,17 +3307,17 @@ xpc_CreateSandboxObject(JSContext *cx, j
                 if (!xpc::WrapperFactory::WaiveXrayAndWrap(cx, v.address()))
                     return NS_ERROR_FAILURE;
                 options.proto = &v.toObject();
             }
 
             // Now check what sort of thing we've got in |proto|
             JSObject *unwrappedProto = js::UncheckedUnwrap(options.proto, false);
             js::Class *unwrappedClass = js::GetObjectClass(unwrappedProto);
-            if (IS_WRAPPER_CLASS(unwrappedClass) ||
+            if (IS_WN_CLASS(unwrappedClass) ||
                 mozilla::dom::IsDOMClass(Jsvalify(unwrappedClass))) {
                 // Wrap it up in a proxy that will do the right thing in terms
                 // of this-binding for methods.
                 RootedValue priv(cx, ObjectValue(*options.proto));
                 options.proto = js::NewProxyObject(cx, &xpc::sandboxProxyHandler,
                                                    priv, nullptr, sandbox);
                 if (!options.proto)
                     return NS_ERROR_OUT_OF_MEMORY;
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -857,29 +857,28 @@ XPCConvert::NativeInterface2JSObject(jsv
             if (!iface)
                 return false;
 
             if (Interface)
                 *Interface = iface;
         }
     }
 
-    NS_ASSERTION(!flat || IS_WRAPPER_CLASS(js::GetObjectClass(flat)),
-                 "What kind of wrapper is this?");
+    NS_ASSERTION(!flat || IS_WN_REFLECTOR(flat), "What kind of wrapper is this?");
 
     nsresult rv;
     XPCWrappedNative* wrapper;
     nsRefPtr<XPCWrappedNative> strongWrapper;
     if (!flat) {
         rv = XPCWrappedNative::GetNewOrUsed(aHelper, xpcscope, iface,
                                             getter_AddRefs(strongWrapper));
 
         wrapper = strongWrapper;
     } else {
-        MOZ_ASSERT(IS_WN_WRAPPER_OBJECT(flat));
+        MOZ_ASSERT(IS_WN_REFLECTOR(flat));
 
         wrapper = static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(flat));
 
         // If asked to return the wrapper we'll return a strong reference,
         // otherwise we'll just return its JSObject in d (which should be
         // rooted in that case).
         if (dest)
             strongWrapper = wrapper;
@@ -980,17 +979,17 @@ XPCConvert::JSObject2NativeInterface(voi
         if (!inner) {
             if (pErr)
                 *pErr = NS_ERROR_XPC_SECURITY_MANAGER_VETO;
             return false;
         }
 
         // Is this really a native xpcom object with a wrapper?
         XPCWrappedNative* wrappedNative = nullptr;
-        if (IS_WN_WRAPPER(inner))
+        if (IS_WN_REFLECTOR(inner))
             wrappedNative = XPCWrappedNative::Get(inner);
         if (wrappedNative) {
             iface = wrappedNative->GetIdentityObject();
             return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
         }
         // else...
 
         // Deal with slim wrappers here.
@@ -1111,18 +1110,18 @@ XPCConvert::JSValToXPCException(jsval sA
             NS_ERROR("when is an object not an object?");
             return NS_ERROR_FAILURE;
         }
 
         // is this really a native xpcom object with a wrapper?
         JSObject *unwrapped = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
         if (!unwrapped)
             return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
-        XPCWrappedNative* wrapper = IS_WN_WRAPPER(unwrapped) ? XPCWrappedNative::Get(unwrapped)
-                                                             : nullptr;
+        XPCWrappedNative* wrapper = IS_WN_REFLECTOR(unwrapped) ? XPCWrappedNative::Get(unwrapped)
+                                                               : nullptr;
         if (wrapper) {
             nsISupports* supports = wrapper->GetIdentityObject();
             nsCOMPtr<nsIException> iface = do_QueryInterface(supports);
             if (iface) {
                 // just pass through the exception (with extra ref and all)
                 nsIException* temp = iface;
                 NS_ADDREF(temp);
                 *exceptn = temp;
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -471,17 +471,17 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNa
  *
  * This static method handles both complexities, returning either an XPCWN, a
  * DOM object, or null. The object may well be cross-compartment from |cx|.
  */
 static JSObject *
 FindObjectForHasInstance(JSContext *cx, HandleObject objArg)
 {
     RootedObject obj(cx, objArg), proto(cx);
-    while (obj && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && !IsDOMObject(obj)) {
+    while (obj && !IS_WN_REFLECTOR(obj) && !IsDOMObject(obj)) {
         if (js::IsWrapper(obj)) {
             obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
             continue;
         }
         if (!js::GetObjectProto(cx, obj, &proto))
             return nullptr;
         obj = proto;
     }
@@ -519,17 +519,17 @@ nsJSIID::HasInstance(nsIXPConnectWrapped
             if (!identity)
                 return NS_OK;
             nsCOMPtr<nsISupports> supp;
             identity->QueryInterface(*iid, getter_AddRefs(supp));
             *bp = supp;
             return NS_OK;
         }
 
-        MOZ_ASSERT(IS_WN_WRAPPER(obj));
+        MOZ_ASSERT(IS_WN_REFLECTOR(obj));
         XPCWrappedNative* other_wrapper = XPCWrappedNative::Get(obj);
         if (!other_wrapper)
             return NS_OK;
 
         // We'll trust the interface set of the wrapper if this is known
         // to be an interface that the objects *expects* to be able to
         // handle.
         if (other_wrapper->HasInterfaceNoQI(*iid)) {
@@ -836,17 +836,17 @@ nsJSCID::HasInstance(nsIXPConnectWrapped
         // we have a JSObject
         RootedObject obj(cx, &val.toObject());
 
         NS_ASSERTION(obj, "when is an object not an object?");
 
         // is this really a native xpcom object with a wrapper?
         nsIClassInfo* ci = nullptr;
         obj = FindObjectForHasInstance(cx, obj);
-        if (!obj || !IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
+        if (!obj || !IS_WN_REFLECTOR(obj))
             return rv;
         if (XPCWrappedNative* other_wrapper = XPCWrappedNative::Get(obj))
             ci = other_wrapper->GetClassInfo();
 
         // We consider CID equality to be the thing that matters here.
         // This is perhaps debatable.
         if (ci) {
             nsID cid;
@@ -888,17 +888,17 @@ const nsID*
 xpc_JSObjectToID(JSContext *cx, JSObject* obj)
 {
     if (!cx || !obj)
         return nullptr;
 
     // NOTE: this call does NOT addref
     XPCWrappedNative* wrapper = nullptr;
     obj = js::CheckedUnwrap(obj);
-    if (obj && IS_WN_WRAPPER(obj))
+    if (obj && IS_WN_REFLECTOR(obj))
         wrapper = XPCWrappedNative::Get(obj);
     if (wrapper &&
         (wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSID))  ||
          wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSIID)) ||
          wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSCID)))) {
         return ((nsIJSID*)wrapper->GetIdentityObject())->GetID();
     }
     return nullptr;
@@ -906,17 +906,17 @@ xpc_JSObjectToID(JSContext *cx, JSObject
 
 JSBool
 xpc_JSObjectIsID(JSContext *cx, JSObject* obj)
 {
     NS_ASSERTION(cx && obj, "bad param");
     // NOTE: this call does NOT addref
     XPCWrappedNative* wrapper = nullptr;
     obj = js::CheckedUnwrap(obj);
-    if (obj && IS_WN_WRAPPER(obj))
+    if (obj && IS_WN_REFLECTOR(obj))
         wrapper = XPCWrappedNative::Get(obj);
     return wrapper &&
            (wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSID))  ||
             wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSIID)) ||
             wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSCID)));
 }
 
 
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2532,17 +2532,17 @@ PreserveWrapper(JSContext *cx, JSObject 
     MOZ_ASSERT(js::GetObjectClass(objArg)->ext.isWrappedNative ||
                mozilla::dom::IsDOMObject(objArg));
 
     RootedObject obj(cx, objArg);
     XPCCallContext ccx(NATIVE_CALLER, cx);
     if (!ccx.IsValid())
         return false;
 
-    if (!IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
+    if (!IS_WN_REFLECTOR(obj))
         return mozilla::dom::TryPreserveWrapper(obj);
 
     nsISupports *supports = XPCWrappedNative::Get(obj)->Native();
 
     // For pre-Paris DOM bindings objects, we only support Node.
     if (nsCOMPtr<nsINode> node = do_QueryInterface(supports)) {
         nsContentUtils::PreserveWrapper(supports, node);
         return true;
--- a/js/xpconnect/src/XPCQuickStubs.cpp
+++ b/js/xpconnect/src/XPCQuickStubs.cpp
@@ -64,17 +64,17 @@ LookupInterfaceOrAncestor(uint32_t table
         }
     }
     return entry;
 }
 
 static MOZ_ALWAYS_INLINE bool
 HasBitInInterfacesBitmap(JSObject *obj, uint32_t interfaceBit)
 {
-    NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(obj)), "Not a wrapper?");
+    NS_ASSERTION(IS_WN_REFLECTOR(obj), "Not a wrapper?");
 
     XPCWrappedNativeJSClass *clasp =
       (XPCWrappedNativeJSClass*)js::GetObjectClass(obj);
     return (clasp->interfacesBitmap & (1 << interfaceBit)) != 0;
 }
 
 static void
 PointerFinalize(JSFreeOp *fop, JSObject *obj)
@@ -173,17 +173,17 @@ static void
 GetMemberInfo(JSObject *obj, jsid memberId, const char **ifaceName)
 {
     *ifaceName = "Unknown";
 
     // Don't try to generate a useful name if there are security wrappers,
     // because it isn't worth the risk of something going wrong just to generate
     // an error message. Instead, only handle the simple case where we have the
     // reflector in hand.
-    if (IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
+    if (IS_WN_REFLECTOR(obj)) {
         XPCWrappedNative *wrapper =
             static_cast<XPCWrappedNative *>(js::GetObjectPrivate(obj));
         XPCWrappedNativeProto *proto = wrapper->GetProto();
         if (proto) {
             XPCNativeSet *set = proto->GetSet();
             if (set) {
                 XPCNativeMember *member;
                 XPCNativeInterface *iface;
@@ -556,17 +556,17 @@ getWrapper(JSContext *cx,
     js::Class* clasp = js::GetObjectClass(obj);
     if (clasp == &XPC_WN_Tearoff_JSClass) {
         *tearoff = (XPCWrappedNativeTearOff*) js::GetObjectPrivate(obj);
         obj = js::GetObjectParent(obj);
     }
 
     // If we've got a WN, store things the way callers expect. Otherwise, leave
     // things null and return.
-    if (IS_WRAPPER_CLASS(clasp))
+    if (IS_WN_CLASS(clasp))
         *wrapper = XPCWrappedNative::Get(obj);
 
     return NS_OK;
 }
 
 nsresult
 castNative(JSContext *cx,
            XPCWrappedNative *wrapper,
@@ -609,17 +609,17 @@ castNativeFromWrapper(JSContext *cx,
                       nsISupports **pRef,
                       jsval *pVal,
                       nsresult *rv)
 {
     XPCWrappedNative *wrapper;
     XPCWrappedNativeTearOff *tearoff;
     JSObject *cur;
 
-    if (IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
+    if (IS_WN_REFLECTOR(obj)) {
         cur = obj;
         wrapper = (XPCWrappedNative*)xpc_GetJSPrivate(obj);
         tearoff = nullptr;
     } else {
         *rv = getWrapper(cx, obj, &wrapper, &cur, &tearoff);
         if (NS_FAILED(*rv))
             return nullptr;
     }
--- a/js/xpconnect/src/XPCVariant.cpp
+++ b/js/xpconnect/src/XPCVariant.cpp
@@ -40,17 +40,17 @@ XPCVariant::XPCVariant(JSContext* cx, js
         // be a problem anymore because SetParentToWindow will do the right
         // thing, but I'm saving the cleanup here for another day. Blake thinks
         // that we should just not store the WN if we're creating a variant for
         // an outer window.
         JSObject *obj = JS_ObjectToInnerObject(cx, JSVAL_TO_OBJECT(mJSVal));
         mJSVal = OBJECT_TO_JSVAL(obj);
 
         JSObject *unwrapped = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
-        mReturnRawObject = !(unwrapped && IS_WN_WRAPPER(unwrapped));
+        mReturnRawObject = !(unwrapped && IS_WN_REFLECTOR(unwrapped));
     } else
         mReturnRawObject = false;
 }
 
 XPCTraceableVariant::~XPCTraceableVariant()
 {
     jsval val = GetJSValPreserveColor();
 
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -694,18 +694,17 @@ nsXPCWrappedJSClass::DelegatedQueryInter
         nsCOMPtr<nsIPrincipal> objPrin;
         nsresult rv = secMan->GetObjectPrincipal(ccx, selfObj,
                                                  getter_AddRefs(objPrin));
         if (NS_FAILED(rv))
             return rv;
 
         bool isSystem;
         rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
-        if ((NS_FAILED(rv) || !isSystem) &&
-            !IS_WRAPPER_CLASS(js::GetObjectClass(selfObj))) {
+        if ((NS_FAILED(rv) || !isSystem) && !IS_WN_REFLECTOR(selfObj)) {
             // A content object.
             nsRefPtr<SameOriginCheckedComponent> checked =
                 new SameOriginCheckedComponent(self);
             if (!checked)
                 return NS_ERROR_OUT_OF_MEMORY;
             *aInstancePtr = checked.forget().get();
             return NS_OK;
         }
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -31,17 +31,17 @@ using namespace xpc;
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace JS;
 
 bool
 xpc_OkToHandOutWrapper(nsWrapperCache *cache)
 {
     NS_ABORT_IF_FALSE(cache->GetWrapper(), "Must have wrapper");
-    NS_ABORT_IF_FALSE(IS_WN_WRAPPER(cache->GetWrapper()),
+    NS_ABORT_IF_FALSE(IS_WN_REFLECTOR(cache->GetWrapper()),
                       "Must have XPCWrappedNative wrapper");
     return
         !static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cache->GetWrapper()))->
             NeedsSOW();
 }
 
 /***************************************************************************/
 
@@ -1353,20 +1353,18 @@ XPCWrappedNative::ReparentWrapperIfFound
         AutoMarkingWrappedNativeProtoPtr oldProto(cx);
         AutoMarkingWrappedNativeProtoPtr newProto(cx);
 
         // Cross-scope means cross-compartment.
         MOZ_ASSERT(js::GetObjectCompartment(aOldScope->GetGlobalJSObject()) !=
                    js::GetObjectCompartment(aNewScope->GetGlobalJSObject()));
         NS_ASSERTION(aNewParent, "won't be able to find the new parent");
 
-        if (wrapper->HasProto())
+        if (wrapper->HasProto()) {
             oldProto = wrapper->GetProto();
-
-        if (oldProto) {
             XPCNativeScriptableInfo *info = oldProto->GetScriptableInfo();
             XPCNativeScriptableCreateInfo ci(*info);
             newProto =
                 XPCWrappedNativeProto::GetNewOrUsed(aNewScope,
                                                     oldProto->GetClassInfo(),
                                                     &ci);
             if (!newProto) {
                 return NS_ERROR_FAILURE;
@@ -1504,20 +1502,18 @@ XPCWrappedNative::ReparentWrapperIfFound
     }
 
     // Now we can just fix up the parent and return the wrapper
 
     if (aNewParent) {
         if (!JS_SetParent(cx, flat, aNewParent))
             MOZ_CRASH();
 
-        JSObject *nw;
-        if (wrapper &&
-            (nw = wrapper->GetWrapper()) &&
-            !JS_SetParent(cx, nw, JS_GetGlobalForObject(cx, aNewParent))) {
+        JSObject *nw = wrapper->GetWrapper();
+        if (nw && !JS_SetParent(cx, nw, JS_GetGlobalForObject(cx, aNewParent))) {
             MOZ_CRASH();
         }
     }
 
     return NS_OK;
 }
 
 // Orphans are sad little things - If only we could treat them better. :-(
@@ -1555,17 +1551,17 @@ RescueOrphans(HandleObject obj)
     RootedObject parentObj(cx, js::GetObjectParent(obj));
     if (!parentObj)
         return NS_OK; // Global object. We're done.
     parentObj = js::UncheckedUnwrap(parentObj, /* stopAtOuter = */ false);
 
     // PreCreate may touch dead compartments.
     js::AutoMaybeTouchDeadZones agc(parentObj);
 
-    bool isWN = IS_WRAPPER_CLASS(js::GetObjectClass(obj));
+    bool isWN = IS_WN_REFLECTOR(obj);
 
     // There's one little nasty twist here. For reasons described in bug 752764,
     // we nuke SOW-ed objects after transplanting them. This means that nodes
     // parented to an element (such as XUL elements), can end up with a nuked proxy
     // in the parent chain, depending on the order of fixup. Because the proxy is
     // nuked, we can't follow it anywhere. But we _can_ find the new wrapper for
     // the underlying native parent.
     if (MOZ_UNLIKELY(JS_IsDeadWrapper(parentObj))) {
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -605,17 +605,17 @@ XPC_WN_NoHelper_Finalize(js::FreeOp *fop
 
 static void
 MarkWrappedNative(JSTracer *trc, JSObject *obj)
 {
     js::Class* clazz = js::GetObjectClass(obj);
     if (clazz->flags & JSCLASS_DOM_GLOBAL) {
         mozilla::dom::TraceProtoAndIfaceCache(trc, obj);
     }
-    MOZ_ASSERT(IS_WRAPPER_CLASS(clazz));
+    MOZ_ASSERT(IS_WN_CLASS(clazz));
 
     XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);
     if (wrapper && wrapper->IsValid())
         wrapper->TraceInside(trc);
 }
 
 static void
 XPC_WN_NoHelper_Trace(JSTracer *trc, JSObject *obj)
@@ -790,17 +790,17 @@ XPC_WN_MaybeResolvingDeletePropertyStub(
 
 // macro fun!
 #define PRE_HELPER_STUB                                                       \
     JSObject *unwrapped = js::CheckedUnwrap(obj, false);                      \
     if (!unwrapped) {                                                         \
         JS_ReportError(cx, "Permission denied to operate on object.");        \
         return false;                                                         \
     }                                                                         \
-    if (!IS_WRAPPER_CLASS(js::GetObjectClass(unwrapped))) {                   \
+    if (!IS_WN_REFLECTOR(unwrapped)) {                                        \
         return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);                    \
     }                                                                         \
     XPCWrappedNative *wrapper = XPCWrappedNative::Get(unwrapped);             \
     THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);                             \
     bool retval = true;                                                       \
     nsresult rv = wrapper->GetScriptableCallback()->
 
 #define POST_HELPER_STUB                                                      \
@@ -1033,17 +1033,17 @@ XPC_WN_Helper_NewResolve(JSContext *cx, 
             do shared enumerate - don't use this JSOp thing at all
 */
 
 JSBool
 XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
                       JSMutableHandleValue statep, MutableHandleId idp)
 {
     js::Class *clazz = js::GetObjectClass(obj);
-    if (!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base) {
+    if (!IS_WN_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base) {
         // obj must be a prototype object or a wrapper w/o a
         // helper. Short circuit this call to the default
         // implementation.
 
         return JS_EnumerateState(cx, obj, enum_op, statep, idp);
     }
 
     XPCCallContext ccx(JS_CALLER, cx, obj);
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -1217,17 +1217,17 @@ nsXPConnect::GetWrappedNativeOfJSObject(
                                         nsIXPConnectWrappedNative **_retval)
 {
     NS_ASSERTION(aJSContext, "bad param");
     NS_ASSERTION(aJSObjArg, "bad param");
     NS_ASSERTION(_retval, "bad param");
 
     RootedObject aJSObj(aJSContext, aJSObjArg);
     aJSObj = js::CheckedUnwrap(aJSObj, /* stopAtOuter = */ false);
-    if (aJSObj && IS_WN_WRAPPER(aJSObj)) {
+    if (aJSObj && IS_WN_REFLECTOR(aJSObj)) {
         NS_IF_ADDREF(*_retval = XPCWrappedNative::Get(aJSObj));
         return NS_OK;
     }
 
     // else...
     *_retval = nullptr;
     return NS_ERROR_FAILURE;
 }
@@ -1240,17 +1240,17 @@ nsXPConnect::GetNativeOfWrapper(JSContex
     NS_ASSERTION(aJSContext, "bad param");
     NS_ASSERTION(aJSObj, "bad param");
 
     aJSObj = js::CheckedUnwrap(aJSObj, /* stopAtOuter = */ false);
     if (!aJSObj) {
         JS_ReportError(aJSContext, "Permission denied to get native of security wrapper");
         return nullptr;
     }
-    if (IS_WRAPPER_CLASS(js::GetObjectClass(aJSObj))) {
+    if (IS_WN_REFLECTOR(aJSObj)) {
         if (XPCWrappedNative *wn = XPCWrappedNative::Get(aJSObj))
             return wn->Native();
         return nullptr;
     }
 
     nsCOMPtr<nsISupports> canonical =
         do_QueryInterface(mozilla::dom::UnwrapDOMObjectToISupports(aJSObj));
     return canonical;
@@ -1913,38 +1913,35 @@ IsJSContextOnStack(JSContext *aCx)
   return XPCJSRuntime::Get()->GetJSContextStack()->HasJSContext(aCx);
 }
 
 } // namespace xpc
 
 nsIPrincipal*
 nsXPConnect::GetPrincipal(JSObject* obj, bool allowShortCircuit) const
 {
-    NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(obj)),
-                 "What kind of wrapper is this?");
+    NS_ASSERTION(IS_WN_REFLECTOR(obj), "What kind of wrapper is this?");
 
-    if (IS_WN_WRAPPER_OBJECT(obj)) {
-        XPCWrappedNative *xpcWrapper =
-            (XPCWrappedNative *)xpc_GetJSPrivate(obj);
-        if (xpcWrapper) {
-            if (allowShortCircuit) {
-                nsIPrincipal *result = xpcWrapper->GetObjectPrincipal();
-                if (result) {
-                    return result;
-                }
+    XPCWrappedNative *xpcWrapper =
+        (XPCWrappedNative *)xpc_GetJSPrivate(obj);
+    if (xpcWrapper) {
+        if (allowShortCircuit) {
+            nsIPrincipal *result = xpcWrapper->GetObjectPrincipal();
+            if (result) {
+                return result;
             }
+        }
 
-            // If not, check if it points to an nsIScriptObjectPrincipal
-            nsCOMPtr<nsIScriptObjectPrincipal> objPrin =
-                do_QueryInterface(xpcWrapper->Native());
-            if (objPrin) {
-                nsIPrincipal *result = objPrin->GetPrincipal();
-                if (result) {
-                    return result;
-                }
+        // If not, check if it points to an nsIScriptObjectPrincipal
+        nsCOMPtr<nsIScriptObjectPrincipal> objPrin =
+            do_QueryInterface(xpcWrapper->Native());
+        if (objPrin) {
+            nsIPrincipal *result = objPrin->GetPrincipal();
+            if (result) {
+                return result;
             }
         }
     }
 
     return nullptr;
 }
 
 NS_IMETHODIMP
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -37,20 +37,16 @@
  * for C++ objects with the given nsIClassInfo.
  *
  * Each XPCWrappedNativeProto has a pointer to its XPCWrappedNativeScope. If an
  * XPCWrappedNative wraps a C++ object with class info, then it points to its
  * XPCWrappedNativeProto. Otherwise it points to its XPCWrappedNativeScope. (The
  * pointers are smooshed together in a tagged union.) Either way it can reach
  * its scope.
  *
- * In the case of slim wrappers (where there is no XPCWrappedNative), the
- * flattened JS object has a pointer to the XPCWrappedNativeProto stored in a
- * reserved slot.
- *
  * An XPCWrappedNativeProto keeps track of the set of interfaces implemented by
  * the C++ object in an XPCNativeSet. (The list of interfaces is obtained by
  * calling a method on the nsIClassInfo.) An XPCNativeSet is a collection of
  * XPCNativeInterfaces. Each interface stores the list of members, which can be
  * methods, constants, getters, or setters.
  *
  * An XPCWrappedNative also points to an XPCNativeSet. Initially this starts out
  * the same as the XPCWrappedNativeProto's set. If there is no proto, it starts
@@ -282,23 +278,23 @@ extern const char XPC_XPCONNECT_CONTRACT
                        JSCLASS_HAS_RESERVED_SLOTS(1))
 
 // WRAPPER_MULTISLOT is defined in xpcpublic.h
 
 #define INVALID_OBJECT ((JSObject *)1)
 
 inline void SetWNExpandoChain(JSObject *obj, JSObject *chain)
 {
-    MOZ_ASSERT(IS_WN_WRAPPER(obj));
+    MOZ_ASSERT(IS_WN_REFLECTOR(obj));
     JS_SetReservedSlot(obj, WRAPPER_MULTISLOT, JS::ObjectOrNullValue(chain));
 }
 
 inline JSObject* GetWNExpandoChain(JSObject *obj)
 {
-    MOZ_ASSERT(IS_WN_WRAPPER(obj));
+    MOZ_ASSERT(IS_WN_REFLECTOR(obj));
     return JS_GetReservedSlot(obj, WRAPPER_MULTISLOT).toObjectOrNull();
 }
 
 /***************************************************************************/
 // Auto locking support class...
 
 // We PROMISE to never screw this up.
 #ifdef _MSC_VER
@@ -1932,23 +1928,20 @@ struct XPCWrappedNativeJSClass
 class XPCNativeScriptableShared
 {
 public:
     const XPCNativeScriptableFlags& GetFlags() const {return mFlags;}
     uint32_t                        GetInterfacesBitmap() const
         {return mJSClass.interfacesBitmap;}
     JSClass*                        GetJSClass()
         {return Jsvalify(&mJSClass.base);}
-    JSClass*                        GetSlimJSClass()
-        {if (mCanBeSlim) return GetJSClass(); return nullptr;}
 
     XPCNativeScriptableShared(uint32_t aFlags, char* aName,
                               uint32_t interfacesBitmap)
-        : mFlags(aFlags),
-          mCanBeSlim(false)
+        : mFlags(aFlags)
         {memset(&mJSClass, 0, sizeof(mJSClass));
          mJSClass.base.name = aName;  // take ownership
          mJSClass.interfacesBitmap = interfacesBitmap;
          MOZ_COUNT_CTOR(XPCNativeScriptableShared);}
 
     ~XPCNativeScriptableShared()
         {if (mJSClass.base.name)nsMemory::Free((void*)mJSClass.base.name);
          MOZ_COUNT_DTOR(XPCNativeScriptableShared);}
@@ -1961,17 +1954,16 @@ public:
 
     void Mark()       {mFlags.Mark();}
     void Unmark()     {mFlags.Unmark();}
     JSBool IsMarked() const {return mFlags.IsMarked();}
 
 private:
     XPCNativeScriptableFlags mFlags;
     XPCWrappedNativeJSClass  mJSClass;
-    JSBool                   mCanBeSlim;
 };
 
 /***************************************************************************/
 // XPCNativeScriptableInfo is used to hold the nsIXPCScriptable state for a
 // given class or instance.
 
 class XPCNativeScriptableInfo
 {
@@ -1986,19 +1978,16 @@ public:
     GetFlags() const      {return mShared->GetFlags();}
 
     uint32_t
     GetInterfacesBitmap() const {return mShared->GetInterfacesBitmap();}
 
     JSClass*
     GetJSClass()          {return mShared->GetJSClass();}
 
-    JSClass*
-    GetSlimJSClass()      {return mShared->GetSlimJSClass();}
-
     XPCNativeScriptableShared*
     GetScriptableShared() {return mShared;}
 
     void
     SetCallback(nsIXPCScriptable* s) {mCallback = s;}
     void
     SetCallback(already_AddRefed<nsIXPCScriptable> s) {mCallback = s;}
 
@@ -2393,17 +2382,17 @@ public:
 
     XPCNativeSet*
     GetSet() const {XPCAutoLock al(GetLock()); return mSet;}
 
     void
     SetSet(XPCNativeSet* set) {XPCAutoLock al(GetLock()); mSet = set;}
 
     static XPCWrappedNative* Get(JSObject *obj) {
-        MOZ_ASSERT(IS_WN_WRAPPER(obj));
+        MOZ_ASSERT(IS_WN_REFLECTOR(obj));
         return (XPCWrappedNative*)js::GetObjectPrivate(obj);
     }
 
 private:
     inline void
     ExpireWrapper()
         {mMaybeScope = (XPCWrappedNativeScope*)
                        (XPC_SCOPE_WORD(mMaybeScope) | XPC_WRAPPER_EXPIRED);}
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -77,55 +77,33 @@ void
 TraceXPCGlobal(JSTracer *trc, JSObject *obj);
 
 // XXX These should be moved into XPCJSRuntime!
 NS_EXPORT_(bool)
 xpc_LocalizeRuntime(JSRuntime *rt);
 NS_EXPORT_(void)
 xpc_DelocalizeRuntime(JSRuntime *rt);
 
-static inline bool IS_WRAPPER_CLASS(js::Class* clazz)
+// If IS_WN_CLASS for the JSClass of an object is true, the object is a
+// wrappednative wrapper, holding the XPCWrappedNative in its private slot.
+
+static inline bool IS_WN_CLASS(js::Class* clazz)
 {
     return clazz->ext.isWrappedNative;
 }
 
-// If IS_WRAPPER_CLASS for the JSClass of an object is true, the object can be
-// a slim wrapper, holding a native in its private slot, or a wrappednative
-// wrapper, holding the XPCWrappedNative in its private slot. A slim wrapper
-// also holds a pointer to its XPCWrappedNativeProto in a reserved slot, we can
-// check that slot for a private value (i.e. a double) to distinguish between
-// the two. This allows us to store a JSObject in that slot for non-slim wrappers
-// while still being able to distinguish the two cases.
-
 // NB: This slot isn't actually reserved for us on globals, because SpiderMonkey
 // uses the first N slots on globals internally. The fact that we use it for
 // wrapped global objects is totally broken. But due to a happy coincidence, the
 // JS engine never uses that slot. This still needs fixing though. See bug 760095.
 #define WRAPPER_MULTISLOT 0
 
-static inline bool IS_WN_WRAPPER_OBJECT(JSObject *obj)
-{
-    MOZ_ASSERT(IS_WRAPPER_CLASS(js::GetObjectClass(obj)));
-    return !js::GetReservedSlot(obj, WRAPPER_MULTISLOT).isDouble();
-}
-static inline bool IS_SLIM_WRAPPER_OBJECT(JSObject *obj)
+static inline bool IS_WN_REFLECTOR(JSObject *obj)
 {
-    return !IS_WN_WRAPPER_OBJECT(obj);
-}
-
-// Use these functions if IS_WRAPPER_CLASS(GetObjectClass(obj)) might be false.
-// Avoid calling them if IS_WRAPPER_CLASS(GetObjectClass(obj)) can only be
-// true, as we'd do a redundant call to IS_WRAPPER_CLASS.
-static inline bool IS_WN_WRAPPER(JSObject *obj)
-{
-    return IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_WN_WRAPPER_OBJECT(obj);
-}
-static inline bool IS_SLIM_WRAPPER(JSObject *obj)
-{
-    return IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_SLIM_WRAPPER_OBJECT(obj);
+    return IS_WN_CLASS(js::GetObjectClass(obj));
 }
 
 extern bool
 xpc_OkToHandOutWrapper(nsWrapperCache *cache);
 
 inline JSObject*
 xpc_FastGetCachedWrapper(nsWrapperCache *cache, JSObject *scope, jsval *vp)
 {
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -174,18 +174,18 @@ IsPermitted(const char *name, JSFlatStri
 static bool
 IsFrameId(JSContext *cx, JSObject *objArg, jsid idArg)
 {
     RootedObject obj(cx, objArg);
     RootedId id(cx, idArg);
 
     obj = JS_ObjectToInnerObject(cx, obj);
     MOZ_ASSERT(!js::IsWrapper(obj));
-    XPCWrappedNative *wn = IS_WN_WRAPPER(obj) ? XPCWrappedNative::Get(obj)
-                                              : nullptr;
+    XPCWrappedNative *wn = IS_WN_REFLECTOR(obj) ? XPCWrappedNative::Get(obj)
+                                                : nullptr;
     if (!wn) {
         return false;
     }
 
     nsCOMPtr<nsIDOMWindow> domwin(do_QueryWrappedNative(wn));
     if (!domwin) {
         return false;
     }
@@ -267,17 +267,17 @@ AccessCheck::isCrossOriginAccessPermitte
 
 bool
 AccessCheck::needsSystemOnlyWrapper(JSObject *obj)
 {
     JSObject* wrapper = obj;
     if (dom::GetSameCompartmentWrapperForDOMBinding(wrapper))
         return wrapper != obj;
 
-    if (!IS_WN_WRAPPER(obj))
+    if (!IS_WN_REFLECTOR(obj))
         return false;
 
     XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(js::GetObjectPrivate(obj));
     return wn->NeedsSOW();
 }
 
 enum Access { READ = (1<<0), WRITE = (1<<1), NO_ACCESS = 0 };
 
--- a/js/xpconnect/wrappers/WrapperFactory.cpp
+++ b/js/xpconnect/wrappers/WrapperFactory.cpp
@@ -191,17 +191,17 @@ WrapperFactory::PrepareForWrapping(JSCon
         }
     }
 
     // Now, our object is ready to be wrapped, but several objects (notably
     // nsJSIIDs) have a wrapper per scope. If we are about to wrap one of
     // those objects in a security wrapper, then we need to hand back the
     // wrapper for the new scope instead. Also, global objects don't move
     // between scopes so for those we also want to return the wrapper. So...
-    if (!IS_WN_WRAPPER(obj) || !js::GetObjectParent(obj))
+    if (!IS_WN_REFLECTOR(obj) || !js::GetObjectParent(obj))
         return DoubleWrap(cx, obj, flags);
 
     XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(xpc_GetJSPrivate(obj));
 
     JSAutoCompartment ac(cx, obj);
     XPCCallContext ccx(JS_CALLER, cx, obj);
     RootedObject wrapScope(cx, scope);
 
@@ -290,17 +290,17 @@ WrapperFactory::PrepareForWrapping(JSCon
     RootedValue v(cx);
     nsresult rv =
         nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, wrapScope, wn->Native(), nullptr,
                                                     &NS_GET_IID(nsISupports), false,
                                                     v.address(), getter_AddRefs(holder));
     NS_ENSURE_SUCCESS(rv, nullptr);
 
     obj = JSVAL_TO_OBJECT(v);
-    NS_ASSERTION(IS_WN_WRAPPER(obj), "bad object");
+    NS_ASSERTION(IS_WN_REFLECTOR(obj), "bad object");
 
     // Because the underlying native didn't have a PreCreate hook, we had
     // to a new (or possibly pre-existing) XPCWN in our compartment.
     // This could be a problem for chrome code that passes XPCOM objects
     // across compartments, because the effects of QI would disappear across
     // compartments.
     //
     // So whenever we pull an XPCWN across compartments in this manner, we
@@ -512,17 +512,17 @@ WrapperFactory::WrapForSameCompartment(J
     NS_ENSURE_TRUE(obj, nullptr);
 
     if (dom::GetSameCompartmentWrapperForDOMBinding(*obj.address())) {
         return obj;
     }
 
     MOZ_ASSERT(!dom::IsDOMObject(obj));
 
-    if (!IS_WN_WRAPPER(obj))
+    if (!IS_WN_REFLECTOR(obj))
         return obj;
 
     // Extract the WN. It should exist.
     XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(xpc_GetJSPrivate(obj));
     MOZ_ASSERT(wn, "Trying to wrap a dead WN!");
 
     // The WN knows what to do.
     RootedObject wrapper(cx, wn->GetSameCompartmentSecurityWrapper(cx));
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -56,17 +56,17 @@ using namespace XrayUtils;
 XrayType
 GetXrayType(JSObject *obj)
 {
     obj = js::UncheckedUnwrap(obj, /* stopAtOuter = */ false);
     if (mozilla::dom::UseDOMXray(obj))
         return XrayForDOMObject;
 
     js::Class* clasp = js::GetObjectClass(obj);
-    if (IS_WRAPPER_CLASS(clasp) || clasp->ext.innerObject)
+    if (IS_WN_CLASS(clasp) || clasp->ext.innerObject)
         return XrayForWrappedNative;
 
     return NotXray;
 }
 
 ResolvingId::ResolvingId(JSContext *cx, HandleObject wrapper, HandleId id)
   : mId(id),
     mHolder(cx, getHolderObject(wrapper)),
@@ -504,17 +504,17 @@ static JSObject *
 GetHolder(JSObject *obj)
 {
     return &js::GetProxyExtra(obj, 0).toObject();
 }
 
 static XPCWrappedNative *
 GetWrappedNative(JSObject *obj)
 {
-    MOZ_ASSERT(IS_WN_WRAPPER_OBJECT(obj));
+    MOZ_ASSERT(IS_WN_REFLECTOR(obj));
     return static_cast<XPCWrappedNative *>(js::GetObjectPrivate(obj));
 }
 
 JSObject*
 XrayTraits::getHolder(JSObject *wrapper)
 {
     MOZ_ASSERT(WrapperFactory::IsXrayWrapper(wrapper));
     js::Value v = js::GetProxyExtra(wrapper, 0);