Bug 834732 - Push a cx in AdoptNode. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Tue, 26 Feb 2013 11:04:12 -0800
changeset 123061 e065138ccd48b449a199913da58bbc9f5e8addaf
parent 123060 7b5cc572e391a1d34e0ec46520a21e1130fcb68a
child 123062 79519aeac030680d215502b12195a5fdccd840c6
push id24372
push useremorley@mozilla.com
push dateWed, 27 Feb 2013 13:22:59 +0000
treeherdermozilla-central@0a91da5f5eab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs834732
milestone22.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 834732 - Push a cx in AdoptNode. r=mrbkap
content/base/src/nsDocument.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -6169,16 +6169,17 @@ private:
  * @param aOldDocument The document to try to get a context from.
  * @param aNewDocument The document to get aNewScope from.
  * @param aCx [out] Context gotten through one of the scopes, from the stack
  *                  or the safe context.
  * @param aNewScope [out] Scope gotten from aNewDocument.
  */
 static nsresult
 GetContextAndScope(nsIDocument* aOldDocument, nsIDocument* aNewDocument,
+                   nsCxPusher& aPusher,
                    JSContext** aCx, JSObject** aNewScope)
 {
   MOZ_ASSERT(aOldDocument);
   MOZ_ASSERT(aNewDocument);
 
   *aCx = nullptr;
   *aNewScope = nullptr;
 
@@ -6211,16 +6212,19 @@ GetContextAndScope(nsIDocument* aOldDocu
           NS_WARNING("No context reachable in GetContextAndScopes()!");
 
           return NS_ERROR_NOT_AVAILABLE;
         }
       }
     }
   }
 
+  if (cx) {
+    aPusher.Push(cx);
+  }
   if (!newScope && cx) {
     JS::Value v;
     nsresult rv = nsContentUtils::WrapNative(cx, global, aNewDocument,
                                              aNewDocument, &v);
     NS_ENSURE_SUCCESS(rv, rv);
 
     newScope = JSVAL_TO_OBJECT(v);
   }
@@ -6344,18 +6348,19 @@ nsIDocument::AdoptNode(nsINode& aAdopted
     }
   }
 
   nsCOMPtr<nsIDocument> oldDocument = adoptedNode->OwnerDoc();
   bool sameDocument = oldDocument == this;
 
   JSContext *cx = nullptr;
   JSObject *newScope = nullptr;
+  nsCxPusher pusher;
   if (!sameDocument) {
-    rv = GetContextAndScope(oldDocument, this, &cx, &newScope);
+    rv = GetContextAndScope(oldDocument, this, pusher, &cx, &newScope);
     if (rv.Failed()) {
       return nullptr;
     }
   }
 
   nsCOMArray<nsINode> nodesWithProperties;
   rv = nsNodeUtils::Adopt(adoptedNode, sameDocument ? nullptr : mNodeInfoManager,
                           cx, newScope, nodesWithProperties);