Revert nsIGlobalHistory2 to what it was on the 1.8 branch. Move the new stuff

to nsIGlobalHistory3.  Bug 328928, r=brettw and smfr, sr=darin
This commit is contained in:
bzbarsky@mit.edu
2006-03-03 03:34:48 +00:00
parent 758700f50b
commit a66006818c
10 changed files with 117 additions and 72 deletions

View File

@@ -2583,7 +2583,7 @@ nsNavHistory::SetURIGeckoFlags(nsIURI* aURI, PRUint32 aFlags)
// nsIGlobalHistory3 *********************************************************** // nsIGlobalHistory3 ***********************************************************
// nsNavHistory::AddToplevelRedirect // nsNavHistory::AddDocumentRedirect
// //
// This adds a redirect mapping from the destination of the redirect to the // This adds a redirect mapping from the destination of the redirect to the
// source, time, and type. This mapping is used by GetRedirectFor when we // source, time, and type. This mapping is used by GetRedirectFor when we
@@ -2600,8 +2600,10 @@ PLDHashOperator PR_CALLBACK nsNavHistory::ExpireNonrecentRedirects(
return PL_DHASH_NEXT; return PL_DHASH_NEXT;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsNavHistory::AddToplevelRedirect(nsIChannel *aOldChannel, nsNavHistory::AddDocumentRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel, PRInt32 aFlags) nsIChannel *aNewChannel,
PRInt32 aFlags,
PRBool aTopLevel)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIURI> oldURI, newURI; nsCOMPtr<nsIURI> oldURI, newURI;
@@ -3180,7 +3182,7 @@ nsNavHistory::ExpireNonrecentEvents(RecentEventHash* hashTable)
// //
// HOW REDIRECT TRACKING WORKS // HOW REDIRECT TRACKING WORKS
// --------------------------- // ---------------------------
// When we get an AddToplevelRedirect message, we store the redirect in // When we get an AddDocumentRedirect message, we store the redirect in
// our mRecentRedirects which maps the destination URI to a source,time pair. // our mRecentRedirects which maps the destination URI to a source,time pair.
// When we get a new URI, we see if there were any redirects to this page // When we get a new URI, we see if there were any redirects to this page
// in the hash table. If found, we know that the page came through the given // in the hash table. If found, we know that the page came through the given
@@ -3188,8 +3190,8 @@ nsNavHistory::ExpireNonrecentEvents(RecentEventHash* hashTable)
// //
// Example: Page S redirects throught R1, then R2, to give page D. Page S // Example: Page S redirects throught R1, then R2, to give page D. Page S
// will have been already added to history. // will have been already added to history.
// - AddToplevelRedirect(R1, R2) // - AddDocumentRedirect(R1, R2)
// - AddToplevelRedirect(R2, D) // - AddDocumentRedirect(R2, D)
// - AddURI(uri=D, referrer=S) // - AddURI(uri=D, referrer=S)
// //
// When we get the AddURI(D), we see the hash table has a value for D from R2. // When we get the AddURI(D), we see the hash table has a value for D from R2.
@@ -3200,8 +3202,8 @@ nsNavHistory::ExpireNonrecentEvents(RecentEventHash* hashTable)
// Alternatively, the user could have typed or followed a bookmark from S. // Alternatively, the user could have typed or followed a bookmark from S.
// In this case, with two redirects we'll get: // In this case, with two redirects we'll get:
// - MarkPageAsTyped(S) // - MarkPageAsTyped(S)
// - AddToplevelRedirect(S, R) // - AddDocumentRedirect(S, R)
// - AddToplevelRedirect(R, D) // - AddDocumentRedirect(R, D)
// - AddURI(uri=D, referrer=null) // - AddURI(uri=D, referrer=null)
// We need to be careful to add a visit to S in this case with an incoming // We need to be careful to add a visit to S in this case with an incoming
// transition of typed and an outgoing transition of redirect. // transition of typed and an outgoing transition of redirect.

View File

@@ -4683,14 +4683,18 @@ nsDocShell::OnRedirectStateChange(nsIChannel* aOldChannel,
return; // not a toplevel document return; // not a toplevel document
nsCOMPtr<nsIGlobalHistory3> history3(do_QueryInterface(mGlobalHistory)); nsCOMPtr<nsIGlobalHistory3> history3(do_QueryInterface(mGlobalHistory));
nsresult result = NS_ERROR_NOT_IMPLEMENTED;
if (history3) { if (history3) {
// notify global history of this redirect // notify global history of this redirect
history3->AddToplevelRedirect(aOldChannel, aNewChannel, result = history3->AddDocumentRedirect(aOldChannel, aNewChannel,
aRedirectFlags); aRedirectFlags, !IsFrame());
} else { }
// when there is no GlobalHistory3, we fall back to GlobalHistory2.
// Just notify that the redirecting page was a redirect so it will if (result == NS_ERROR_NOT_IMPLEMENTED) {
// be link colored but not visible. // when there is no GlobalHistory3, or it doesn't implement
// AddToplevelRedirect, we fall back to GlobalHistory2. Just notify
// that the redirecting page was a redirect so it will be link colored
// but not visible.
nsCOMPtr<nsIURI> oldURI; nsCOMPtr<nsIURI> oldURI;
aOldChannel->GetURI(getter_AddRefs(oldURI)); aOldChannel->GetURI(getter_AddRefs(oldURI));
if (! oldURI) if (! oldURI)

View File

@@ -197,15 +197,3 @@ nsGlobalHistoryAdapter::SetPageTitle(nsIURI* aURI, const nsAString& aTitle)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP
nsGlobalHistoryAdapter::SetURIGeckoFlags(nsIURI *aURI, PRUint32 aFlags)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsGlobalHistoryAdapter::GetURIGeckoFlags(nsIURI *aURI, PRUint32* aFlags)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -51,12 +51,9 @@ interface nsIURI;
// the nsIURI is the subject // the nsIURI is the subject
#define NS_LINK_VISITED_EVENT_TOPIC "link-visited" #define NS_LINK_VISITED_EVENT_TOPIC "link-visited"
// This is NOT part of the interface! It could change.
#define NS_GECKO_FLAG_NEEDS_VERTICAL_SCROLLBAR (1 << 0)
%} %}
[scriptable, uuid(fbcfa5ca-5d05-4726-b325-d0e6563a1715)] [scriptable, uuid(cf777d42-1270-4b34-be7b-2931c93feda5)]
interface nsIGlobalHistory2 : nsISupports interface nsIGlobalHistory2 : nsISupports
{ {
/** /**
@@ -92,17 +89,4 @@ interface nsIGlobalHistory2 : nsISupports
* @param aTitle the page title * @param aTitle the page title
*/ */
void setPageTitle(in nsIURI aURI, in AString aTitle); void setPageTitle(in nsIURI aURI, in AString aTitle);
/**
* Get the Gecko flags for this URI. These flags are used by Gecko as hints
* to optimize page loading. Not all histories have them; this need not be
* supported (just return NS_ERROR_NOT_IMPLEMENTED. These flags are opaque
* and should not be interpreted by the history engine.
*/
unsigned long getURIGeckoFlags(in nsIURI aURI);
/**
* Set the Gecko flags for this URI. May fail if the history entry
* doesn't have any flags or if there is no entry for the URI.
*/
void setURIGeckoFlags(in nsIURI aURI, in unsigned long aFlags);
}; };

View File

@@ -40,10 +40,17 @@
#include "nsIGlobalHistory2.idl" #include "nsIGlobalHistory2.idl"
interface nsIChannel; interface nsIChannel;
%{C++
// This is NOT part of the interface! It could change.
#define NS_GECKO_FLAG_NEEDS_VERTICAL_SCROLLBAR (1 << 0)
%}
/** /**
* Provides information about global history to gecko, extending GlobalHistory2 * Provides information about global history to gecko, extending GlobalHistory2
*/ */
[scriptable, uuid(40e9613e-1742-4b4d-a858-053e6237d04d)] [scriptable, uuid(24306852-c60e-49c3-a455-90f6747118ba)]
interface nsIGlobalHistory3 : nsIGlobalHistory2 interface nsIGlobalHistory3 : nsIGlobalHistory2
{ {
/** /**
@@ -60,12 +67,37 @@ interface nsIGlobalHistory3 : nsIGlobalHistory2
* *
* For implementors of nsIGlobalHistory3: The history implementation is * For implementors of nsIGlobalHistory3: The history implementation is
* responsible for sending NS_LINK_VISITED_EVENT_TOPIC to observers for * responsible for sending NS_LINK_VISITED_EVENT_TOPIC to observers for
* redirect pages. This will be sent by the docshell for all non-redirect * redirect pages. This notification must be sent for history consumers for
* pages (see nsDocShell::AddToGlobalHistory). * all non-redirect pages.
* *
* This function takes the same arguments as * @param aToplevel whether the URI is loaded in a top-level window. If
* nsIChannelEventSink::OnChannelRedirect * false, the load is in a subframe.
*
* The other params to this function are the same as those for
* nsIChannelEventSink::OnChannelRedirect.
*
* Note: Implementors who wish to implement this interface but rely on
* nsIGlobalHistory2.addURI for redirect processing may throw
* NS_ERROR_NOT_IMPLEMENTED from this method. If they do so, then callers
* must call nsIGlobalHistory2.addURI upon getting the
* NS_ERROR_NOT_IMPLEMENTED result.
*/ */
void addToplevelRedirect(in nsIChannel aOldChannel, in nsIChannel aNewChannel, void addDocumentRedirect(in nsIChannel aOldChannel,
in PRInt32 aFlags); in nsIChannel aNewChannel,
in PRInt32 aFlags,
in boolean aTopLevel);
/**
* Get the Gecko flags for this URI. These flags are used by Gecko as hints
* to optimize page loading. Not all histories have them; this need not be
* supported (just return NS_ERROR_NOT_IMPLEMENTED. These flags are opaque
* and should not be interpreted by the history engine.
*/
unsigned long getURIGeckoFlags(in nsIURI aURI);
/**
* Set the Gecko flags for this URI. May fail if the history entry
* doesn't have any flags or if there is no entry for the URI.
*/
void setURIGeckoFlags(in nsIURI aURI, in unsigned long aFlags);
}; };

View File

@@ -75,7 +75,7 @@
#include "nsReflowPath.h" #include "nsReflowPath.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsPresState.h" #include "nsPresState.h"
#include "nsIGlobalHistory2.h" #include "nsIGlobalHistory3.h"
#include "nsDocShellCID.h" #include "nsDocShellCID.h"
#ifdef ACCESSIBILITY #ifdef ACCESSIBILITY
#include "nsIAccessibilityService.h" #include "nsIAccessibilityService.h"
@@ -2623,7 +2623,7 @@ nsGfxScrollFrameInner::SaveVScrollbarStateToGlobalHistory()
if (!uri) if (!uri)
return; return;
nsCOMPtr<nsIGlobalHistory2> history(do_GetService(NS_GLOBALHISTORY2_CONTRACTID)); nsCOMPtr<nsIGlobalHistory3> history(do_GetService(NS_GLOBALHISTORY2_CONTRACTID));
if (!history) if (!history)
return; return;
@@ -2646,7 +2646,7 @@ nsGfxScrollFrameInner::GetVScrollbarHintFromGlobalHistory(PRBool* aVScrollbarNee
if (!uri) if (!uri)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsCOMPtr<nsIGlobalHistory2> history(do_GetService(NS_GLOBALHISTORY2_CONTRACTID)); nsCOMPtr<nsIGlobalHistory3> history(do_GetService(NS_GLOBALHISTORY2_CONTRACTID));
if (!history) if (!history)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@@ -548,14 +548,20 @@ nsGlobalHistory::~nsGlobalHistory()
// //
// nsISupports methods // nsISupports methods
NS_IMPL_ISUPPORTS7(nsGlobalHistory, NS_IMPL_ADDREF(nsGlobalHistory)
nsIGlobalHistory2, NS_IMPL_RELEASE(nsGlobalHistory)
nsIBrowserHistory,
nsIObserver, NS_INTERFACE_MAP_BEGIN(nsGlobalHistory)
nsISupportsWeakReference, NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIGlobalHistory2, nsIGlobalHistory3)
nsIRDFDataSource, NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory3)
nsIRDFRemoteDataSource, NS_INTERFACE_MAP_ENTRY(nsIBrowserHistory)
nsIAutoCompleteSearch) NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
NS_INTERFACE_MAP_ENTRY(nsIRDFRemoteDataSource)
NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteSearch)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIBrowserHistory)
NS_INTERFACE_MAP_END
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// //
@@ -1486,6 +1492,15 @@ nsGlobalHistory::MarkPageAsTyped(nsIURI *aURI)
return SetRowValue(row, kToken_TypedColumn, 1); return SetRowValue(row, kToken_TypedColumn, 1);
} }
NS_IMETHODIMP
nsGlobalHistory::AddDocumentRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel,
PRInt32 aFlags,
PRBool aTopLevel)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalHistory::SetURIGeckoFlags(nsIURI *aURI, PRUint32 aFlags) nsGlobalHistory::SetURIGeckoFlags(nsIURI *aURI, PRUint32 aFlags)
{ {

View File

@@ -42,7 +42,7 @@
#define nsglobalhistory__h____ #define nsglobalhistory__h____
#include "nsIBrowserHistory.h" #include "nsIBrowserHistory.h"
#include "nsIGlobalHistory3.h"
#include "mdb.h" #include "mdb.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
@@ -132,13 +132,15 @@ class nsGlobalHistory : nsSupportsWeakReference,
public nsIObserver, public nsIObserver,
public nsIRDFDataSource, public nsIRDFDataSource,
public nsIRDFRemoteDataSource, public nsIRDFRemoteDataSource,
public nsIAutoCompleteSearch public nsIAutoCompleteSearch,
public nsIGlobalHistory3
{ {
public: public:
// nsISupports methods // nsISupports methods
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIGLOBALHISTORY2 NS_DECL_NSIGLOBALHISTORY2
NS_DECL_NSIGLOBALHISTORY3
NS_DECL_NSIBROWSERHISTORY NS_DECL_NSIBROWSERHISTORY
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
NS_DECL_NSIRDFDATASOURCE NS_DECL_NSIRDFDATASOURCE

View File

@@ -528,14 +528,20 @@ nsGlobalHistory::~nsGlobalHistory()
// //
// nsISupports methods // nsISupports methods
NS_IMPL_ISUPPORTS7(nsGlobalHistory, NS_IMPL_ADDREF(nsGlobalHistory)
nsIGlobalHistory2, NS_IMPL_RELEASE(nsGlobalHistory)
nsIBrowserHistory,
nsIObserver, NS_INTERFACE_MAP_BEGIN(nsGlobalHistory)
nsISupportsWeakReference, NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIGlobalHistory2, nsIGlobalHistory3)
nsIRDFDataSource, NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory3)
nsIRDFRemoteDataSource, NS_INTERFACE_MAP_ENTRY(nsIBrowserHistory)
nsIAutoCompleteSession) NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
NS_INTERFACE_MAP_ENTRY(nsIRDFRemoteDataSource)
NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteSession)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIBrowserHistory)
NS_INTERFACE_MAP_END
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// //
@@ -1398,6 +1404,15 @@ nsGlobalHistory::MarkPageAsTyped(nsIURI *aURI)
return SetRowValue(row, kToken_TypedColumn, 1); return SetRowValue(row, kToken_TypedColumn, 1);
} }
NS_IMETHODIMP
nsGlobalHistory::AddDocumentRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel,
PRInt32 aFlags,
PRBool aTopLevel)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalHistory::SetURIGeckoFlags(nsIURI *aURI, PRUint32 aFlags) nsGlobalHistory::SetURIGeckoFlags(nsIURI *aURI, PRUint32 aFlags)
{ {

View File

@@ -42,6 +42,7 @@
#include "mdb.h" #include "mdb.h"
#include "nsIBrowserHistory.h" #include "nsIBrowserHistory.h"
#include "nsIGlobalHistory3.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsIRDFDataSource.h" #include "nsIRDFDataSource.h"
@@ -129,13 +130,15 @@ class nsGlobalHistory : nsSupportsWeakReference,
public nsIObserver, public nsIObserver,
public nsIRDFDataSource, public nsIRDFDataSource,
public nsIRDFRemoteDataSource, public nsIRDFRemoteDataSource,
public nsIAutoCompleteSession public nsIAutoCompleteSession,
public nsIGlobalHistory3
{ {
public: public:
// nsISupports methods // nsISupports methods
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIGLOBALHISTORY2 NS_DECL_NSIGLOBALHISTORY2
NS_DECL_NSIGLOBALHISTORY3
NS_DECL_NSIBROWSERHISTORY NS_DECL_NSIBROWSERHISTORY
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
NS_DECL_NSIRDFDATASOURCE NS_DECL_NSIRDFDATASOURCE