From 02f69dc196acae6fcbbaa982f227a045e65f8415 Mon Sep 17 00:00:00 2001 From: "jst%mozilla.jstenback.com" Date: Tue, 6 Jul 2004 21:22:43 +0000 Subject: [PATCH] Fixing bug 248870. Make resizeTo() and resizeBy() no-ops when called on [i]frames. r+sr=peterv@propagandism.org git-svn-id: svn://10.0.0.236/branches/AVIARY_1_0_20040515_BRANCH@158806 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/base/nsGlobalWindow.cpp | 27 +++++++++---------------- mozilla/dom/src/base/nsGlobalWindow.h | 5 +++++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index cd108f7a0c7..550614d7d9b 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -417,7 +417,7 @@ GlobalWindowImpl::SetContext(nsIScriptContext* aContext) mContext = aContext; if (mContext) { - if (GetParentInternal()) { + if (IsFrame()) { // This window is a [i]frame, don't bother GC'ing when the // frame's context is destroyed since a GC will happen when the // frameset or host document is destroyed anyway. @@ -1601,21 +1601,14 @@ GlobalWindowImpl::SetInnerWidth(PRInt32 aInnerWidth) * prevent setting window.innerWidth by exiting early */ - if (!CanSetProperty("dom.disable_window_move_resize") && !IsCallerChrome()) { + if ((!CanSetProperty("dom.disable_window_move_resize") && + !IsCallerChrome()) || IsFrame()) { return NS_OK; } nsCOMPtr docShellAsItem(do_QueryInterface(mDocShell)); NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); - nsCOMPtr docShellParent; - docShellAsItem->GetSameTypeParent(getter_AddRefs(docShellParent)); - - // It's only valid to access this from a top window. Doesn't work from - // sub-frames. - if (docShellParent) - return NS_OK; // Silent failure - nsCOMPtr treeOwner; docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner)); NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE); @@ -1653,7 +1646,8 @@ GlobalWindowImpl::SetInnerHeight(PRInt32 aInnerHeight) * prevent setting window.innerHeight by exiting early */ - if (!CanSetProperty("dom.disable_window_move_resize") && !IsCallerChrome()) { + if ((!CanSetProperty("dom.disable_window_move_resize") && + !IsCallerChrome()) || IsFrame()) { return NS_OK; } @@ -2697,7 +2691,8 @@ GlobalWindowImpl::ResizeTo(PRInt32 aWidth, PRInt32 aHeight) * prevent window.resizeTo() by exiting early */ - if (!CanSetProperty("dom.disable_window_move_resize") && !IsCallerChrome()) { + if ((!CanSetProperty("dom.disable_window_move_resize") && + !IsCallerChrome()) || IsFrame()) { return NS_OK; } @@ -2722,7 +2717,8 @@ GlobalWindowImpl::ResizeBy(PRInt32 aWidthDif, PRInt32 aHeightDif) * prevent window.resizeBy() by exiting early */ - if (!CanSetProperty("dom.disable_window_move_resize") && !IsCallerChrome()) { + if ((!CanSetProperty("dom.disable_window_move_resize") && + !IsCallerChrome()) || IsFrame()) { return NS_OK; } @@ -3574,10 +3570,7 @@ nsCloseEvent::PostCloseEvent() NS_IMETHODIMP GlobalWindowImpl::Close() { - nsCOMPtr parent; - GetParent(getter_AddRefs(parent)); - - if (parent != NS_STATIC_CAST(nsIDOMWindow *, this)) { + if (IsFrame()) { // window.close() is called on a frame in a frameset, such calls // are ignored. diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h index 8546698d5eb..d831d7e736b 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.h +++ b/mozilla/dom/src/base/nsGlobalWindow.h @@ -277,6 +277,11 @@ protected: nsresult GetScrollXY(PRInt32* aScrollX, PRInt32* aScrollY); nsresult GetScrollMaxXY(PRInt32* aScrollMaxX, PRInt32* aScrollMaxY); + PRBool IsFrame() + { + return GetParentInternal() != nsnull; + } + protected: // When adding new member variables, be careful not to create cycles // through JavaScript. If there is any chance that a member variable