Bug 648801 (new DOM list bindings) - Hook up new dom bindings to the CC. r=bz/jst/mrbkap.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 24 May 2011 14:10:03 +0200
changeset 78425 41fdf93335d86e29a4639a44e2f787545951bb9f
parent 78424 f2e77f10570e92065955151b68af5d9264809796
child 78426 6bfceb8654987cde1f38c17aacaba503f5ec51f0
push id21294
push userpvanderbeken@mozilla.com
push dateMon, 10 Oct 2011 08:58:09 +0000
treeherdermozilla-central@432f3a96bc2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, jst, mrbkap
bugs648801
milestone10.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 648801 (new DOM list bindings) - Hook up new dom bindings to the CC. r=bz/jst/mrbkap.
js/src/xpconnect/src/dombindings.cpp
js/src/xpconnect/src/dombindings.h
js/src/xpconnect/src/nsXPConnect.cpp
js/src/xpconnect/src/xpcwrappednative.cpp
--- a/js/src/xpconnect/src/dombindings.cpp
+++ b/js/src/xpconnect/src/dombindings.cpp
@@ -48,17 +48,17 @@
 
 extern XPCNativeInterface* interfaces[];
 
 using namespace js;
 
 namespace xpc {
 namespace dom {
 
-int NodeListBase::NodeListFamily;
+int HandlerFamily;
 
 JSObject *
 NodeListBase::create(JSContext *cx, XPCWrappedNativeScope *scope,
                      nsINodeList *aNodeList)
 {
     return NodeList<nsINodeList>::create(cx, scope, aNodeList, aNodeList);
 }
 
--- a/js/src/xpconnect/src/dombindings.h
+++ b/js/src/xpconnect/src/dombindings.h
@@ -44,29 +44,33 @@
 #include "jsproxy.h"
 
 class nsINodeList;
 class nsIHTMLCollection;
 
 namespace xpc {
 namespace dom {
 
+extern int HandlerFamily;
+inline void* ProxyFamily() { return &HandlerFamily; }
+inline bool instanceIsDOMProxy(JSObject *obj)
+{
+    return js::IsProxy(obj) &&
+           js::GetProxyHandler(obj)->family() == ProxyFamily();
+}
+
 class NodeListBase : public js::ProxyHandler {
 public:
     NodeListBase() : js::ProxyHandler(ProxyFamily()) {}
 
-    static void* ProxyFamily() { return &NodeListFamily; }
-
     static JSObject *create(JSContext *cx, XPCWrappedNativeScope *scope,
                             nsINodeList *aNodeList);
     static JSObject *create(JSContext *cx, XPCWrappedNativeScope *scope,
                             nsIHTMLCollection *aHTMLCollection,
                             nsWrapperCache *aWrapperCache);
-private:
-    static int NodeListFamily;
 };
 
 /**
  * T must be either nsINodeList or nsIHTMLCollection.
  */
 template<class T>
 class NodeList : public NodeListBase {
     static NodeList instance;
--- a/js/src/xpconnect/src/nsXPConnect.cpp
+++ b/js/src/xpconnect/src/nsXPConnect.cpp
@@ -61,16 +61,17 @@
 
 #include "XrayWrapper.h"
 #include "WrapperFactory.h"
 #include "AccessCheck.h"
 
 #include "jsdIDebuggerService.h"
 
 #include "xpcquickstubs.h"
+#include "dombindings.h"
 
 NS_IMPL_THREADSAFE_ISUPPORTS7(nsXPConnect,
                               nsIXPConnect,
                               nsISupportsWeakReference,
                               nsIThreadObserver,
                               nsIJSRuntimeService,
                               nsIJSContextStack,
                               nsIThreadJSContextStack,
@@ -902,16 +903,23 @@ nsXPConnect::Traverse(void *p, nsCycleCo
     // XXX This test does seem fragile, we should probably whitelist classes
     //     that do hold a strong reference, but that might not be possible.
     else if(clazz->flags & JSCLASS_HAS_PRIVATE &&
             clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)
     {
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "xpc_GetJSPrivate(obj)");
         cb.NoteXPCOMChild(static_cast<nsISupports*>(xpc_GetJSPrivate(obj)));
     }
+    else if(xpc::dom::instanceIsDOMProxy(obj))
+    {
+        NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "js::GetProxyPrivate(obj)");
+        nsISupports *identity =
+            static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
+        cb.NoteXPCOMChild(identity);
+    }
 
     return NS_OK;
 }
 
 unsigned
 nsXPConnect::GetOutstandingRequests(JSContext* cx)
 {
     unsigned n = cx->outstandingRequests;
--- a/js/src/xpconnect/src/xpcwrappednative.cpp
+++ b/js/src/xpconnect/src/xpcwrappednative.cpp
@@ -61,17 +61,17 @@ xpc_OkToHandOutWrapper(nsWrapperCache *c
     NS_ABORT_IF_FALSE(cache->IsProxy() || IS_WN_WRAPPER(cache->GetWrapper()),
                       "Must have proxy or XPCWrappedNative wrapper");
     NS_ABORT_IF_FALSE(cache->IsProxy() == js::IsProxy(cache->GetWrapper()),
                       "There's serious confusion about whether this is a "
                       "proxy");
     return
         (cache->IsProxy() &&
          js::GetProxyHandler(cache->GetWrapper())->family() ==
-           xpc::dom::NodeListBase::ProxyFamily()) ||
+           xpc::dom::ProxyFamily()) ||
         (!cache->IsProxy() &&
          !static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cache->GetWrapper()))->
            NeedsSOW());
 }
 
 /***************************************************************************/
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(XPCWrappedNative)