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
This commit is contained in:
@@ -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<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
||||
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> 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<nsIDocShellTreeOwner> 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<nsIDOMWindow> 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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user