From 3a08e97341e74a14ae96defda13f02f6c6eb2b61 Mon Sep 17 00:00:00 2001 From: Bob Owen Date: Mon, 14 Jul 2014 18:49:18 +0100 Subject: [PATCH] Bug 1037564 Part 1: Replace AutoPushJSContext in nsBindingManager::GetBindingImplementation. r=bholley --- dom/xbl/nsBindingManager.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 21c0d43d36fa..517c4847de92 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -46,10 +46,10 @@ #include "nsIScriptContext.h" #include "xpcpublic.h" #include "jswrapper.h" -#include "nsCxPusher.h" #include "nsThreadUtils.h" #include "mozilla/dom/NodeListBinding.h" +#include "mozilla/dom/ScriptSettings.h" using namespace mozilla; using namespace mozilla::dom; @@ -638,21 +638,9 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, // We have never made a wrapper for this implementation. // Create an XPC wrapper for the script object and hand it back. - - nsIDocument* doc = aContent->OwnerDoc(); - - nsCOMPtr global = - do_QueryInterface(doc->GetWindow()); - if (!global) - return NS_NOINTERFACE; - - nsIScriptContext *context = global->GetContext(); - if (!context) - return NS_NOINTERFACE; - - AutoPushJSContext cx(context->GetNativeContext()); - if (!cx) - return NS_NOINTERFACE; + AutoJSAPI jsapi; + jsapi.Init(); + JSContext* cx = jsapi.cx(); nsIXPConnect *xpConnect = nsContentUtils::XPConnect(); @@ -666,8 +654,7 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, // because they're chrome-only and no Xrays are involved. // // If there's no separate XBL scope, or if the reflector itself lives in - // the XBL scope, we'll end up with the global of the reflector, and this - // will all be a no-op. + // the XBL scope, we'll end up with the global of the reflector. JS::Rooted xblScope(cx, xpc::GetXBLScopeOrGlobal(cx, jsobj)); JSAutoCompartment ac(cx, xblScope); bool ok = JS_WrapObject(cx, &jsobj);