From bb2ee1727c15327c59e6e7ecbe50aad7ce99dac9 Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Thu, 30 Mar 2000 02:24:17 +0000 Subject: [PATCH] OnLoadingSite now takes a nsIChannel instead of a nsIURI. This allows us to get information out of the channel we may need such as the referrer. We now make sure we set the referrer during OnLoadingSite. Fixed a bug where the nsIWebProgressListener was getting found on the treeOwner even for frames. This was causing the the treeOwner to get notified of all actions happening in the children. Now we make sure to only set the listener for the top level frame. git-svn-id: svn://10.0.0.236/trunk@64558 18797224-902f-48f8-a5cc-f745e15eee43 --- .../docshell/base/nsDSURIContentListener.cpp | 4 +-- mozilla/docshell/base/nsDocShell.cpp | 35 ++++++++++++++----- mozilla/docshell/base/nsDocShell.h | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/mozilla/docshell/base/nsDSURIContentListener.cpp b/mozilla/docshell/base/nsDSURIContentListener.cpp index 36ede9bc052..6abfd6bd35e 100644 --- a/mozilla/docshell/base/nsDSURIContentListener.cpp +++ b/mozilla/docshell/base/nsDSURIContentListener.cpp @@ -94,9 +94,7 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType, if(loadAttribs & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) mDocShell->StopCurrentLoads(); - nsCOMPtr aURI; - aOpenedChannel->GetURI(getter_AddRefs(aURI)); - mDocShell->OnLoadingSite(aURI); + mDocShell->OnLoadingSite(aOpenedChannel); NS_ENSURE_SUCCESS(mDocShell->CreateContentViewer(aContentType, aCommand, aOpenedChannel, aContentHandler), NS_ERROR_FAILURE); diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index daccd9c687e..9aa3776deee 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -45,6 +45,7 @@ // Interfaces Needed #include "nsIGlobalHistory.h" +#include "nsIHTTPChannel.h" #ifdef XXX_NS_DEBUG // XXX: we'll need a logging facility for debugging #define WEB_TRACE(_bit,_args) \ @@ -715,8 +716,14 @@ NS_IMETHODIMP nsDocShell::GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner) NS_IMETHODIMP nsDocShell::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner) { mTreeOwner = aTreeOwner; // Weak reference per API - nsCOMPtr progressListener(do_QueryInterface(aTreeOwner)); - mOwnerProgressListener = progressListener; // Weak reference per API + // Don't automatically set the progress based on the tree owner for frames + if(!IsFrame()) + { + nsCOMPtr progressListener(do_QueryInterface(aTreeOwner)); + mOwnerProgressListener = progressListener; // Weak reference per API + } + else + mOwnerProgressListener = nsnull; PRInt32 i, n = mChildren.Count(); for(i = 0; i < n; i++) @@ -2271,8 +2278,12 @@ NS_IMETHODIMP nsDocShell::ScrollIfAnchor(nsIURI* aURI, PRBool* aWasAnchor) return NS_OK; } -NS_IMETHODIMP nsDocShell::OnLoadingSite(nsIURI* aURI) +NS_IMETHODIMP nsDocShell::OnLoadingSite(nsIChannel* aChannel) { + nsCOMPtr uri; + aChannel->GetURI(getter_AddRefs(uri)); + NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE); + UpdateCurrentSessionHistory(); UpdateCurrentGlobalHistory(); @@ -2280,17 +2291,25 @@ NS_IMETHODIMP nsDocShell::OnLoadingSite(nsIURI* aURI) { PRBool shouldAdd = PR_FALSE; - ShouldAddToSessionHistory(aURI, &shouldAdd); + ShouldAddToSessionHistory(uri, &shouldAdd); if(shouldAdd) - AddToSessionHistory(aURI); + AddToSessionHistory(uri); shouldAdd = PR_FALSE; - ShouldAddToGlobalHistory(aURI, &shouldAdd); + ShouldAddToGlobalHistory(uri, &shouldAdd); if(shouldAdd) - AddToGlobalHistory(aURI); + AddToGlobalHistory(uri); + } + + SetCurrentURI(uri); + nsCOMPtr httpChannel(do_QueryInterface(aChannel)); + if(httpChannel) + { + nsCOMPtr referrer; + httpChannel->GetReferrer(getter_AddRefs(referrer)); + SetReferrerURI(referrer); } - SetCurrentURI(aURI); mInitialPageLoad = PR_FALSE; return NS_OK; } diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index e313caf835e..92954ebcc6e 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -146,7 +146,7 @@ protected: NS_IMETHOD DoURILoad(nsIURI* aURI); NS_IMETHOD StopCurrentLoads(); NS_IMETHOD ScrollIfAnchor(nsIURI* aURI, PRBool* aWasAnchor); - NS_IMETHOD OnLoadingSite(nsIURI* aURI); + NS_IMETHOD OnLoadingSite(nsIChannel* aChannel); virtual void SetCurrentURI(nsIURI* aURI); virtual void SetReferrerURI(nsIURI* aURI);