diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f2c9af49ee7..6f167ea9ac6 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -5119,9 +5119,9 @@ nsGlobalWindow::Print() printSettingsService->GetNewPrintSettings(getter_AddRefs(printSettings)); } - EnterModalState(); + nsCOMPtr callerWin = EnterModalState(); webBrowserPrint->Print(printSettings, nsnull); - LeaveModalState(nsnull); + LeaveModalState(callerWin); PRBool savePrintSettings = nsContentUtils::GetBoolPref("print.save_print_settings", PR_FALSE); @@ -6480,8 +6480,6 @@ nsGlobalWindow::LeaveModalState(nsIDOMWindow *aCallerWin) } } - JSContext *cx = nsContentUtils::GetCurrentJSContext(); - if (aCallerWin) { nsCOMPtr sgo(do_QueryInterface(aCallerWin)); nsIScriptContext *scx = sgo->GetContext(); @@ -6833,7 +6831,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs, options.AppendLiteral(",scrollbars=1,centerscreen=1,resizable=0"); - EnterModalState(); + nsCOMPtr callerWin = EnterModalState(); nsresult rv = OpenInternal(aURI, EmptyString(), options, PR_FALSE, // aDialog PR_TRUE, // aContentModal @@ -6843,7 +6841,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs, GetPrincipal(), // aCalleePrincipal nsnull, // aJSCallerContext getter_AddRefs(dlgWin)); - LeaveModalState(nsnull); + LeaveModalState(callerWin); NS_ENSURE_SUCCESS(rv, rv); diff --git a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp index e3d88fe6436..59176a47d79 100644 --- a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp +++ b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp @@ -56,7 +56,7 @@ nsAutoWindowStateHelper::nsAutoWindowStateHelper(nsIDOMWindow *aWindow) nsCOMPtr window(do_QueryInterface(aWindow)); if (window) { - window->EnterModalState(); + mCallerWindow = window->EnterModalState(); } } @@ -65,7 +65,7 @@ nsAutoWindowStateHelper::~nsAutoWindowStateHelper() nsCOMPtr window(do_QueryInterface(mWindow)); if (window) { - window->LeaveModalState(nsnull); + window->LeaveModalState(mCallerWindow); } if (mDefaultEnabled) { diff --git a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.h b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.h index 27ed72b9967..13916bf5ba1 100644 --- a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.h +++ b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.h @@ -62,6 +62,7 @@ protected: PRBool DispatchCustomEvent(const char *aEventName); nsIDOMWindow *mWindow; + nsCOMPtr mCallerWindow; PRBool mDefaultEnabled; };