From 9ad867a793ae38b64382ab92c7d3f3278fbf3147 Mon Sep 17 00:00:00 2001 From: "radha%netscape.com" Date: Wed, 5 Mar 2003 21:37:20 +0000 Subject: [PATCH] Fix for bug # 148794. Check if the load is to a iframe and if so, do not add it to session history. git-svn-id: svn://10.0.0.236/trunk@138976 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 30 ++++++++++++++++++++++------ mozilla/docshell/base/nsDocShell.h | 1 + 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 43baad156df..7f60ed607ce 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -89,6 +89,7 @@ #include "nsIHistoryEntry.h" #include "nsISHistoryListener.h" #include "nsIDirectoryListing.h" +#include "nsIDOMHTMLIFrameElement.h" // Pull in various NS_ERROR_* definitions #include "nsIDNSService.h" @@ -4172,8 +4173,10 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest, nsCOMPtr wcwgChannel(do_QueryInterface(aRequest)); nsCOMPtr webProgress(do_QueryInterface(mLoadCookie)); - // Was the wyciwyg document loaded on this docshell? - if (wcwgChannel && !mLSHE && (mItemType == typeContent) && aProgress == webProgress.get()) { + // Was the wyciwyg document loaded on this docshell? + // if the wyciwyg content is added to a iframe, we don't + // want it to get into session history. + if (!IsIFrame() && wcwgChannel && !mLSHE && (mItemType == typeContent) && aProgress == webProgress.get()) { nsCOMPtr uri; wcwgChannel->GetURI(getter_AddRefs(uri)); @@ -5841,13 +5844,14 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, if (!rootSH) shAvailable = PR_FALSE; } // rootSH - - - // Determine if this type of load should update history. + + // Determine if this type of load should update history. + // Loads to iframes also don't get into session history. if (aLoadType == LOAD_BYPASS_HISTORY || aLoadType & LOAD_CMD_HISTORY || aLoadType == LOAD_RELOAD_NORMAL || - aLoadType == LOAD_RELOAD_CHARSET_CHANGE) + aLoadType == LOAD_RELOAD_CHARSET_CHANGE || + IsIFrame()) updateHistory = PR_FALSE; // Check if the url to be loaded is the same as the one already loaded. @@ -6731,6 +6735,20 @@ nsDocShell::IsFrame() return PR_FALSE; } +PRBool +nsDocShell::IsIFrame() +{ + nsCOMPtr frame_element; + nsCOMPtr win_private(do_GetInterface(NS_STATIC_CAST(nsIInterfaceRequestor *, this))); + if (win_private) { + win_private->GetFrameElementInternal(getter_AddRefs(frame_element)); + nsCOMPtr iframe(do_QueryInterface(frame_element)); + if (iframe) + return PR_TRUE; + } + return PR_FALSE; +} + NS_IMETHODIMP nsDocShell::GetHasFocus(PRBool *aHasFocus) { diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index e186e457af8..bb1b4302580 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -272,6 +272,7 @@ protected: nsIDocShell **aResult); PRBool IsFrame(); + PRBool IsIFrame(); // // Helper method that is called when a new document (including any