From c42091817b889a6f9dfc93942bfa47126bbe8340 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 27 Mar 2014 21:05:14 +0100 Subject: [PATCH] Bug 973367 - Inline nsGlobalWindow::CreateOuterObject; r=bholley --- dom/base/nsGlobalWindow.cpp | 30 ++++++++---------------------- dom/base/nsGlobalWindow.h | 2 -- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 795ac6788677..14ae422dcdf0 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2135,27 +2135,6 @@ WindowStateHolder::~WindowStateHolder() NS_IMPL_ISUPPORTS1(WindowStateHolder, WindowStateHolder) -nsresult -nsGlobalWindow::CreateOuterObject(nsGlobalWindow* aNewInner) -{ - AutoPushJSContext cx(mContext->GetNativeContext()); - - JS::Rooted global(cx, aNewInner->FastGetGlobalJSObject()); - JS::Rooted outer(cx, NewOuterWindowProxy(cx, global, IsChromeWindow())); - if (!outer) { - return NS_ERROR_FAILURE; - } - - js::SetProxyExtra(outer, 0, js::PrivateValue(ToSupports(this))); - - JSAutoCompartment ac(cx, outer); - - // Inform the nsJSContext, which is the canonical holder of the outer. - MOZ_ASSERT(IsOuterWindow()); - mContext->SetWindowProxy(outer); - return NS_OK; -} - // We need certain special behavior for remote XUL whitelisted domains, but we // don't want that behavior to take effect in automation, because we whitelist // all the mochitest domains. So we need to check a pref here. @@ -2462,7 +2441,14 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, mInnerWindow = newInnerWindow; if (!mJSObject) { - CreateOuterObject(newInnerWindow); + JS::Rooted global(cx, newInnerWindow->FastGetGlobalJSObject()); + JS::Rooted outer(cx, NewOuterWindowProxy(cx, global, thisChrome)); + NS_ENSURE_TRUE(outer, NS_ERROR_FAILURE); + + js::SetProxyExtra(outer, 0, js::PrivateValue(ToSupports(this))); + + // Inform the nsJSContext, which is the canonical holder of the outer. + mContext->SetWindowProxy(outer); mContext->DidInitializeContext(); mJSObject = mContext->GetWindowProxy(); diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 629821a3b346..806df8a6237e 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1301,8 +1301,6 @@ protected: inline int32_t DOMMinTimeoutValue() const; - nsresult CreateOuterObject(nsGlobalWindow* aNewInner); - nsresult SetOuterObject(JSContext* aCx, JS::Handle aOuterObject); nsresult CloneStorageEvent(const nsAString& aType, nsCOMPtr& aEvent);