Fix for bug 830879 (HTML Element WebIDL bindings require classinfo). r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 10 Jan 2013 10:54:32 +0100
changeset 130532 b48d4a8141bd6a650ac32fd19aaff6dbec4df8a4
parent 130531 d9c36d39f7bcc5b33f227030486d90c26b1881ca
child 130533 94dc3dd5174a1740a50f42f7675d67ef7d80c4fc
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs830879
milestone21.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
Fix for bug 830879 (HTML Element WebIDL bindings require classinfo). r=bz.
content/base/public/nsINode.h
js/xpconnect/src/XPCQuickStubs.cpp
js/xpconnect/src/xpcObjectHelper.h
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -1488,17 +1488,20 @@ protected:
 
   void ClearSubtreeRootPointer()
   {
     mSubtreeRoot = nullptr;
   }
 
 public:
   // Optimized way to get classinfo.
-  virtual nsXPCClassInfo* GetClassInfo() = 0;
+  virtual nsXPCClassInfo* GetClassInfo()
+  {
+    return nullptr;
+  }
 
   // Makes nsINode object to keep aObject alive.
   void BindObject(nsISupports* aObject);
   // After calling UnbindObject nsINode object doesn't keep
   // aObject alive anymore.
   void UnbindObject(nsISupports* aObject);
 
   /**
--- a/js/xpconnect/src/XPCQuickStubs.cpp
+++ b/js/xpconnect/src/XPCQuickStubs.cpp
@@ -1008,9 +1008,17 @@ xpc_qsAssertContextOK(JSContext *cx)
 {
     XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack();
 
     JSContext *topJSContext = stack->Peek();
 
     // This is what we're actually trying to assert here.
     NS_ASSERTION(cx == topJSContext, "wrong context on XPCJSContextStack!");
 }
+
+void
+xpcObjectHelper::AssertGetClassInfoResult()
+{
+    MOZ_ASSERT(mXPCClassInfo ||
+               static_cast<nsINode*>(GetCanonical())->IsDOMBinding(),
+               "GetClassInfo() should only return null for new DOM bindings!");
+}
 #endif
--- a/js/xpconnect/src/xpcObjectHelper.h
+++ b/js/xpconnect/src/xpcObjectHelper.h
@@ -69,20 +69,25 @@ public:
           return mXPCClassInfo;
         if (!mClassInfo)
             mClassInfo = do_QueryInterface(mObject);
         return mClassInfo;
     }
     nsXPCClassInfo *GetXPCClassInfo()
     {
         if (!mXPCClassInfo) {
-            if (mIsNode)
-                mXPCClassInfo = static_cast<nsINode*>(GetCanonical())->GetClassInfo();
-            else
+            if (mIsNode) {
+                mXPCClassInfo =
+                    static_cast<nsINode*>(GetCanonical())->GetClassInfo();
+#ifdef DEBUG
+                AssertGetClassInfoResult();
+#endif
+            } else {
                 CallQueryInterface(mObject, getter_AddRefs(mXPCClassInfo));
+            }
         }
         return mXPCClassInfo;
     }
 
     already_AddRefed<nsXPCClassInfo> forgetXPCClassInfo()
     {
         GetXPCClassInfo();
 
@@ -124,16 +129,20 @@ protected:
     }
 
     nsCOMPtr<nsISupports>    mCanonicalStrong;
     nsISupports*             mCanonical;
 
 private:
     xpcObjectHelper(xpcObjectHelper& aOther) MOZ_DELETE;
 
+#ifdef DEBUG
+    void AssertGetClassInfoResult();
+#endif
+
     nsISupports*             mObject;
     nsWrapperCache*          mCache;
     nsCOMPtr<nsIClassInfo>   mClassInfo;
     nsRefPtr<nsXPCClassInfo> mXPCClassInfo;
     bool                     mIsNode;
 };
 
 #endif