Bug 924720 - Part 7: Move and rename OuterWindowProxyObject::class_. (r=bholley)
authorEric Faust <efaustbmo@gmail.com>
Wed, 29 Jan 2014 17:20:16 -0800
changeset 181929 c1bd9e2e41b25e6e8c737ea87ab3b19bd911f13f
parent 181928 d3af8463dddc2cbf7f80523975575ca91034984c
child 181930 beb52f820ac567ba0adb91c14f35429d581e64c1
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs924720
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924720 - Part 7: Move and rename OuterWindowProxyObject::class_. (r=bholley)
dom/base/nsGlobalWindow.cpp
js/src/jsapi-tests/testBug604087.cpp
js/src/jsproxy.cpp
js/src/jsproxy.h
js/src/vm/ProxyObject.cpp
js/src/vm/ProxyObject.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -673,16 +673,30 @@ protected:
   already_AddRefed<nsIDOMWindow> GetSubframeWindow(JSContext *cx,
                                                    JS::Handle<JSObject*> proxy,
                                                    JS::Handle<jsid> id);
 
   bool AppendIndexedPropertyNames(JSContext *cx, JSObject *proxy,
                                   JS::AutoIdVector &props);
 };
 
+const js::Class OuterWindowProxyClass =
+    PROXY_CLASS_WITH_EXT(
+        "Proxy",
+        0, /* additional slots */
+        0, /* additional class flags */
+        nullptr, /* call */
+        nullptr, /* construct */
+        PROXY_MAKE_EXT(
+            nullptr, /* outerObject */
+            js::proxy_innerObject,
+            nullptr, /* iteratorObject */
+            false   /* isWrappedNative */
+        ));
+
 bool
 nsOuterWindowProxy::isExtensible(JSContext *cx, JS::Handle<JSObject*> proxy,
                                  bool *extensible)
 {
   // If [[Extensible]] could be false, then navigating a window could navigate
   // to a window that's [[Extensible]] after being at one that wasn't: an
   // invariant violation.  So always report true for this.
   *extensible = true;
@@ -1019,19 +1033,23 @@ nsChromeOuterWindowProxy::className(JSCo
 
 nsChromeOuterWindowProxy
 nsChromeOuterWindowProxy::singleton;
 
 static JSObject*
 NewOuterWindowProxy(JSContext *cx, JS::Handle<JSObject*> parent, bool isChrome)
 {
   JSAutoCompartment ac(cx, parent);
+  js::WrapperOptions options;
+  options.setClass(&OuterWindowProxyClass);
+  options.setSingleton(true);
   JSObject *obj = js::Wrapper::New(cx, parent, parent,
                                    isChrome ? &nsChromeOuterWindowProxy::singleton
-                                            : &nsOuterWindowProxy::singleton);
+                                            : &nsOuterWindowProxy::singleton,
+                                   &options);
 
   NS_ASSERTION(js::GetObjectClass(obj)->ext.innerObject, "bad class");
   return obj;
 }
 
 //*****************************************************************************
 //***    nsGlobalWindow: Object Management
 //*****************************************************************************
--- a/js/src/jsapi-tests/testBug604087.cpp
+++ b/js/src/jsapi-tests/testBug604087.cpp
@@ -9,33 +9,29 @@
 
 #include "jsobj.h"
 #include "jswrapper.h"
 
 #include "jsapi-tests/tests.h"
 
 #include "vm/ProxyObject.h"
 
-struct OuterWrapper : js::Wrapper
-{
-    OuterWrapper() : Wrapper(0) {}
-
-    virtual bool isOuterWindow() {
-        return true;
-    }
-
-    virtual bool finalizeInBackground(JS::Value priv) {
-        return false;
-    }
-
-    static OuterWrapper singleton;
-};
-
-OuterWrapper
-OuterWrapper::singleton;
+const js::Class OuterWrapperClass =
+    PROXY_CLASS_WITH_EXT(
+        "Proxy",
+        0, /* additional slots */
+        0, /* additional class flags */
+        nullptr, /* call */
+        nullptr, /* construct */
+        PROXY_MAKE_EXT(
+            nullptr, /* outerObject */
+            js::proxy_innerObject,
+            nullptr, /* iteratorObject */
+            false   /* isWrappedNative */
+        ));
 
 static JSObject *
 wrap(JSContext *cx, JS::HandleObject toWrap, JS::HandleObject target)
 {
     JSAutoCompartment ac(cx, target);
     JS::RootedObject wrapper(cx, toWrap);
     if (!JS_WrapObject(cx, &wrapper))
         return nullptr;
@@ -66,17 +62,20 @@ Wrap(JSContext *cx, JS::HandleObject exi
 static const JSWrapObjectCallbacks WrapObjectCallbacks = {
     Wrap,
     SameCompartmentWrap,
     PreWrap
 };
 
 BEGIN_TEST(testBug604087)
 {
-    JS::RootedObject outerObj(cx, js::Wrapper::New(cx, global, global, &OuterWrapper::singleton));
+    js::WrapperOptions options;
+    options.setClass(&OuterWrapperClass);
+    options.setSingleton(true);
+    JS::RootedObject outerObj(cx, js::Wrapper::New(cx, global, global, &js::Wrapper::singleton, &options));
     JS::RootedObject compartment2(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
     JS::RootedObject compartment3(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
     JS::RootedObject compartment4(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
 
     JS::RootedObject c2wrapper(cx, wrap(cx, outerObj, compartment2));
     CHECK(c2wrapper);
     c2wrapper->as<js::ProxyObject>().setExtra(0, js::Int32Value(2));
 
@@ -87,17 +86,17 @@ BEGIN_TEST(testBug604087)
     JS::RootedObject c4wrapper(cx, wrap(cx, outerObj, compartment4));
     CHECK(c4wrapper);
     c4wrapper->as<js::ProxyObject>().setExtra(0, js::Int32Value(4));
     compartment4 = c4wrapper = nullptr;
 
     JS::RootedObject next(cx);
     {
         JSAutoCompartment ac(cx, compartment2);
-        next = js::Wrapper::New(cx, compartment2, compartment2, &OuterWrapper::singleton);
+        next = js::Wrapper::New(cx, compartment2, compartment2, &js::Wrapper::singleton, &options);
         CHECK(next);
     }
 
     JS_SetWrapObjectCallbacks(JS_GetRuntime(cx), &WrapObjectCallbacks);
     CHECK(JS_TransplantObject(cx, outerObj, next));
     return true;
 }
 END_TEST(testBug604087)
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -3115,32 +3115,16 @@ js::proxy_Slice(JSContext *cx, HandleObj
                     constructOp)
 
 const Class js::ProxyObject::uncallableClass_ = PROXY_CLASS(nullptr, nullptr);
 const Class js::ProxyObject::callableClass_ = PROXY_CLASS(proxy_Call, proxy_Construct);
 
 const Class* const js::CallableProxyClassPtr = &ProxyObject::callableClass_;
 const Class* const js::UncallableProxyClassPtr = &ProxyObject::uncallableClass_;
 
-const Class js::OuterWindowProxyObject::class_ =
-    PROXY_CLASS_WITH_EXT(
-        "Proxy",
-        0, /* additional slots */
-        0, /* JSClass flags */
-        nullptr, /* call */
-        nullptr, /* construct */
-        PROXY_MAKE_EXT(
-            nullptr, /* outerObject */
-            proxy_innerObject,
-            nullptr, /* IteratorObject */
-            false /* isWrappedNative */
-        ));
-
-const Class* const js::OuterWindowProxyClassPtr = &OuterWindowProxyObject::class_;
-
 JS_FRIEND_API(JSObject *)
 js::NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, JSObject *proto_,
                    JSObject *parent_, const ProxyOptions &options)
 {
     return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), parent_,
                             options);
 }
 
--- a/js/src/jsproxy.h
+++ b/js/src/jsproxy.h
@@ -332,17 +332,16 @@ class Proxy
     /* IC entry path for handling __noSuchMethod__ on access. */
     static bool callProp(JSContext *cx, HandleObject proxy, HandleObject reveiver, HandleId id,
                          MutableHandleValue vp);
 };
 
 // Use these in places where you don't want to #include vm/ProxyObject.h.
 extern JS_FRIEND_DATA(const js::Class* const) CallableProxyClassPtr;
 extern JS_FRIEND_DATA(const js::Class* const) UncallableProxyClassPtr;
-extern JS_FRIEND_DATA(const js::Class* const) OuterWindowProxyClassPtr;
 
 inline bool IsProxyClass(const Class *clasp)
 {
     return clasp->isProxy();
 }
 
 inline bool IsProxy(JSObject *obj)
 {
--- a/js/src/vm/ProxyObject.cpp
+++ b/js/src/vm/ProxyObject.cpp
@@ -32,18 +32,17 @@ ProxyObject::New(JSContext *cx, BaseProx
      * their prototype changes later.
      */
     if (proto.isObject() && !options.singleton()) {
         RootedObject protoObj(cx, proto.toObject());
         if (!JSObject::setNewTypeUnknown(cx, clasp, protoObj))
             return nullptr;
     }
 
-    NewObjectKind newKind =
-        (clasp == &OuterWindowProxyObject::class_ || options.singleton()) ? SingletonObject : GenericObject;
+    NewObjectKind newKind = options.singleton() ? SingletonObject : GenericObject;
     gc::AllocKind allocKind = gc::GetGCObjectKind(clasp);
     if (handler->finalizeInBackground(priv))
         allocKind = GetBackgroundAllocKind(allocKind);
     RootedObject obj(cx, NewObjectWithGivenProto(cx, clasp, proto, parent, allocKind, newKind));
     if (!obj)
         return nullptr;
 
     Rooted<ProxyObject*> proxy(cx, &obj->as<ProxyObject>());
--- a/js/src/vm/ProxyObject.h
+++ b/js/src/vm/ProxyObject.h
@@ -98,22 +98,16 @@ class ProxyObject : public JSObject
     static void trace(JSTracer *trc, JSObject *obj);
 
     void nuke(BaseProxyHandler *handler);
 
     static const Class callableClass_;
     static const Class uncallableClass_;
 };
 
-class OuterWindowProxyObject : public ProxyObject
-{
-  public:
-    static const Class class_;
-};
-
 } // namespace js
 
 // Note: the following |JSObject::is<T>| methods are implemented in terms of
 // the Is*Proxy() friend API functions to ensure the implementations are tied
 // together.  The exception is |JSObject::is<js::OuterWindowProxyObject>()
 // const|, which uses the standard template definition, because there is no
 // IsOuterWindowProxy() function in the friend API.