Bug 973780 - Hook Xrays up to the new expando map. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Fri, 21 Feb 2014 11:35:48 -0800
changeset 170277 22dd1b0a3752e149fcfed0caa40ea6b39a00a410
parent 170276 fb680cb6a07e3542b4c4def563d1bac3244f0a9e
child 170278 59fcb8a3225f63ae9a93dd9ddb36b37e8b72f9b0
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbz
bugs973780
milestone30.0a1
Bug 973780 - Hook Xrays up to the new expando map. r=bz
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -164,18 +164,23 @@ public:
                                HandleObject consumer);
     JSObject* ensureExpandoObject(JSContext *cx, HandleObject wrapper,
                                   HandleObject target);
 
     JSObject* getHolder(JSObject *wrapper);
     JSObject* ensureHolder(JSContext *cx, HandleObject wrapper);
     virtual JSObject* createHolder(JSContext *cx, JSObject *wrapper) = 0;
 
-    virtual JSObject* getExpandoChain(JSObject *obj) = 0;
-    virtual void setExpandoChain(JSObject *obj, JSObject *chain) = 0;
+    JSObject* getExpandoChain(JSObject *obj) {
+      return GetObjectScope(obj)->GetExpandoChain(obj);
+    }
+
+    bool setExpandoChain(JSContext *cx, HandleObject obj, HandleObject chain) {
+      return GetObjectScope(obj)->SetExpandoChain(cx, obj, chain);
+    }
     bool cloneExpandoChain(JSContext *cx, HandleObject dst, HandleObject src);
 
 private:
     bool expandoObjectMatchesConsumer(JSContext *cx, HandleObject expandoObject,
                                       nsIPrincipal *consumerOrigin,
                                       HandleObject exclusiveGlobal);
     JSObject* getExpandoObjectInternal(JSContext *cx, HandleObject target,
                                        nsIPrincipal *origin,
@@ -216,22 +221,16 @@ public:
         return XPCWrappedNative::Get(getTargetObject(wrapper));
     }
 
     virtual void preserveWrapper(JSObject *target);
 
     typedef ResolvingId ResolvingIdImpl;
 
     virtual JSObject* createHolder(JSContext *cx, JSObject *wrapper);
-    virtual JSObject* getExpandoChain(JSObject *obj) {
-        return GetWNExpandoChain(obj);
-    }
-    virtual void setExpandoChain(JSObject *obj, JSObject *chain) {
-        SetWNExpandoChain(obj, chain);
-    }
 
     static XPCWrappedNativeXrayTraits singleton;
 };
 
 class DOMXrayTraits : public XrayTraits
 {
 public:
     static const XrayType Type = XrayForDOMObject;
@@ -258,23 +257,16 @@ public:
     }
 
     typedef ResolvingIdDummy ResolvingIdImpl;
 
     virtual void preserveWrapper(JSObject *target);
 
     virtual JSObject* createHolder(JSContext *cx, JSObject *wrapper);
 
-    virtual JSObject* getExpandoChain(JSObject *obj) {
-        return mozilla::dom::GetXrayExpandoChain(obj);
-    }
-    virtual void setExpandoChain(JSObject *obj, JSObject *chain) {
-        mozilla::dom::SetXrayExpandoChain(obj, chain);
-    }
-
     static DOMXrayTraits singleton;
 };
 
 XPCWrappedNativeXrayTraits XPCWrappedNativeXrayTraits::singleton;
 DOMXrayTraits DOMXrayTraits::singleton;
 
 XrayTraits*
 GetXrayTraits(JSObject *obj)
@@ -435,17 +427,17 @@ XrayTraits::attachExpandoObject(JSContex
     // the wrapper. This keeps our expandos alive even if the Xray wrapper gets
     // collected.
     RootedObject chain(cx, getExpandoChain(target));
     if (!chain)
         preserveWrapper(target);
 
     // Insert it at the front of the chain.
     JS_SetReservedSlot(expandoObject, JSSLOT_EXPANDO_NEXT, OBJECT_TO_JSVAL(chain));
-    setExpandoChain(target, expandoObject);
+    setExpandoChain(cx, target, expandoObject);
 
     return expandoObject;
 }
 
 JSObject *
 XrayTraits::ensureExpandoObject(JSContext *cx, HandleObject wrapper,
                                 HandleObject target)
 {