Bug 910161 - Remove nsIHistoryEntry and replace it with nsISHEntry; r=bz

This commit is contained in:
Tim Taubert 2013-08-30 06:14:59 +02:00
parent 400a08c6e2
commit 2f6dacbfd8
12 changed files with 65 additions and 135 deletions

View File

@ -263,9 +263,8 @@ MarkDocShell(nsIDocShellTreeNode* aNode, bool aCleanupJS, bool aPrepareForCC)
int32_t i, historyCount;
history->GetCount(&historyCount);
for (i = 0; i < historyCount; ++i) {
nsCOMPtr<nsIHistoryEntry> historyEntry;
history->GetEntryAtIndex(i, false, getter_AddRefs(historyEntry));
nsCOMPtr<nsISHEntry> shEntry = do_QueryInterface(historyEntry);
nsCOMPtr<nsISHEntry> shEntry;
history->GetEntryAtIndex(i, false, getter_AddRefs(shEntry));
MarkSHEntry(shEntry, aCleanupJS, aPrepareForCC);
}

View File

@ -117,7 +117,7 @@
#include "nsISHistoryInternal.h"
#include "nsIPrincipal.h"
#include "nsIFileURL.h"
#include "nsIHistoryEntry.h"
#include "nsISHEntry.h"
#include "nsISHistoryListener.h"
#include "nsIWindowWatcher.h"
#include "nsIPromptFactory.h"
@ -3783,7 +3783,7 @@ nsDocShell::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry,
* a new entry.
*/
int32_t index = -1;
nsCOMPtr<nsIHistoryEntry> currentHE;
nsCOMPtr<nsISHEntry> currentHE;
mSessionHistory->GetIndex(&index);
if (index < 0)
return NS_ERROR_FAILURE;
@ -8049,11 +8049,8 @@ nsDocShell::CreateContentViewer(const char *aContentType,
mSessionHistory->GetRequestedIndex(&idx);
if (idx == -1)
mSessionHistory->GetIndex(&idx);
nsCOMPtr<nsIHistoryEntry> entry;
mSessionHistory->GetEntryAtIndex(idx, false,
getter_AddRefs(entry));
mLSHE = do_QueryInterface(entry);
getter_AddRefs(mLSHE));
}
mLoadType = LOAD_ERROR_PAGE;
@ -9155,13 +9152,11 @@ nsDocShell::InternalLoad(nsIURI * aURI,
if (mSessionHistory) {
int32_t index = -1;
mSessionHistory->GetIndex(&index);
nsCOMPtr<nsIHistoryEntry> hEntry;
nsCOMPtr<nsISHEntry> shEntry;
mSessionHistory->GetEntryAtIndex(index, false,
getter_AddRefs(hEntry));
NS_ENSURE_TRUE(hEntry, NS_ERROR_FAILURE);
nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(hEntry));
if (shEntry)
shEntry->SetTitle(mTitle);
getter_AddRefs(shEntry));
NS_ENSURE_TRUE(shEntry, NS_ERROR_FAILURE);
shEntry->SetTitle(mTitle);
}
/* Set the title for the Global History entry for this anchor url.

View File

@ -122,7 +122,6 @@ NS_DEFINE_NAMED_CID(NS_EXTERNALSHARINGAPPSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
NS_DEFINE_NAMED_CID(NS_HISTORYENTRY_CID);
NS_DEFINE_NAMED_CID(NS_SHTRANSACTION_CID);
NS_DEFINE_NAMED_CID(NS_SHISTORY_CID);
NS_DEFINE_NAMED_CID(NS_SHISTORY_INTERNAL_CID);
@ -152,7 +151,6 @@ const mozilla::Module::CIDEntry kDocShellCIDs[] = {
{ &kNS_EXTERNALURLHANDLERSERVICE_CID, false, nullptr, nsExternalURLHandlerServiceConstructor },
#endif
{ &kNS_SHENTRY_CID, false, nullptr, nsSHEntryConstructor },
{ &kNS_HISTORYENTRY_CID, false, nullptr, nsSHEntryConstructor },
{ &kNS_SHTRANSACTION_CID, false, nullptr, nsSHTransactionConstructor },
{ &kNS_SHISTORY_CID, false, nullptr, nsSHistoryConstructor },
{ &kNS_SHISTORY_INTERNAL_CID, false, nullptr, nsSHistoryConstructor },
@ -205,7 +203,6 @@ const mozilla::Module::ContractIDEntry kDocShellContracts[] = {
{ NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID },
#endif
{ NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID },
{ NS_HISTORYENTRY_CONTRACTID, &kNS_HISTORYENTRY_CID },
{ NS_SHTRANSACTION_CONTRACTID, &kNS_SHTRANSACTION_CID },
{ NS_SHISTORY_CONTRACTID, &kNS_SHISTORY_CID },
{ NS_SHISTORY_INTERNAL_CONTRACTID, &kNS_SHISTORY_INTERNAL_CID },

View File

@ -6,7 +6,6 @@
XPIDL_SOURCES += [
'nsIBFCacheEntry.idl',
'nsIHistoryEntry.idl',
'nsISHContainer.idl',
'nsISHEntry.idl',
'nsISHTransaction.idl',

View File

@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* An interface to individual entries in session history. Each
* document or frame will have a nsIHistoryEntry associated with
* it. nsIHistoryEntry provides access to information like URI,
* title and frame traversal status for that document.
* This interface is accessible from javascript.
*/
#include "nsISupports.idl"
interface nsIURI;
[scriptable, uuid(A41661D4-1417-11D5-9882-00C04FA02F40)]
interface nsIHistoryEntry : nsISupports
{
/**
* A readonly property that returns the URI
* of the current entry. The object returned is
* of type nsIURI
*/
readonly attribute nsIURI URI;
/**
* A readonly property that returns the title
* of the current entry. The object returned
* is a encoded string
*/
readonly attribute wstring title;
/**
* A readonly property that returns a boolean
* flag which indicates if the entry was created as a
* result of a subframe navigation. This flag will be
* 'false' when a frameset page is visited for
* the first time. This flag will be 'true' for all
* history entries created as a result of a subframe
* navigation.
*/
readonly attribute boolean isSubFrame;
};
%{ C++
// {A41661D5-1417-11D5-9882-00C04FA02F40}
#define NS_HISTORYENTRY_CID \
{0xa41661d5, 0x1417, 0x11d5, {0x98, 0x82, 0x0, 0xc0, 0x4f, 0xa0, 0x2f, 0x40}}
#define NS_HISTORYENTRY_CONTRACTID \
"@mozilla.org/browser/history-entry;1"
%}

View File

@ -9,7 +9,8 @@
* hold all information required to recreate the document from history
*
*/
#include "nsIHistoryEntry.idl"
#include "nsISupports.idl"
interface nsILayoutHistoryState;
interface nsIContentViewer;
@ -29,9 +30,34 @@ class nsSHEntryShared;
[ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData);
[ptr] native nsSHEntryShared(nsSHEntryShared);
[scriptable, uuid(162EA0EB-E577-4B9A-AF9D-A94E8350B029)]
interface nsISHEntry : nsIHistoryEntry
[scriptable, uuid(c2a5827e-0fc0-11e3-bb95-59e799890b3c)]
interface nsISHEntry : nsISupports
{
/**
* A readonly property that returns the URI
* of the current entry. The object returned is
* of type nsIURI
*/
readonly attribute nsIURI URI;
/**
* A readonly property that returns the title
* of the current entry. The object returned
* is a encoded string
*/
readonly attribute wstring title;
/**
* A readonly property that returns a boolean
* flag which indicates if the entry was created as a
* result of a subframe navigation. This flag will be
* 'false' when a frameset page is visited for
* the first time. This flag will be 'true' for all
* history entries created as a result of a subframe
* navigation.
*/
readonly attribute boolean isSubFrame;
/** URI for the document */
void setURI(in nsIURI aURI);

View File

@ -5,7 +5,7 @@
#include "nsISupports.idl"
interface nsIHistoryEntry;
interface nsISHEntry;
interface nsISHistoryListener;
interface nsISimpleEnumerator;
/**
@ -27,7 +27,7 @@ interface nsISimpleEnumerator;
#define NS_SHISTORY_CONTRACTID "@mozilla.org/browser/shistory;1"
%}
[scriptable, uuid(ef2c9bcb-96b8-4095-933a-cb1c506f2c58)]
[scriptable, uuid(b4440e2e-0fc2-11e3-971f-59e799890b3c)]
interface nsISHistory: nsISupports
{
/**
@ -72,7 +72,7 @@ interface nsISHistory: nsISupports
* <code>NS_ERROR_FAILURE</code> Error in obtaining
* history entry for the given index.
*/
nsIHistoryEntry getEntryAtIndex(in long index, in boolean modifyIndex);
nsISHEntry getEntryAtIndex(in long index, in boolean modifyIndex);
/**
@ -135,11 +135,11 @@ interface nsISHistory: nsISupports
* by step #1 to obtain handle to the next object in the list.
* The object returned by this step is of type nsISupports.
* 3) Perform a QueryInterface on the object returned by step #2
* to nsIHistoryEntry.
* 4) Use nsIHistoryEntry to access properties of each history entry.
* to nsISHEntry.
* 4) Use nsISHEntry to access properties of each history entry.
*
* @see nsISimpleEnumerator
* @see nsIHistoryEntry
* @see nsISHEntry
* @see QueryInterface()
* @see do_QueryInterface()
*/

View File

@ -77,8 +77,7 @@ nsSHEntry::~nsSHEntry()
// nsSHEntry: nsISupports
//*****************************************************************************
NS_IMPL_ISUPPORTS4(nsSHEntry, nsISHContainer, nsISHEntry, nsIHistoryEntry,
nsISHEntryInternal)
NS_IMPL_ISUPPORTS3(nsSHEntry, nsISHContainer, nsISHEntry, nsISHEntryInternal)
//*****************************************************************************
// nsSHEntry: nsISHEntry

View File

@ -19,7 +19,6 @@
#include "nsISHEntry.h"
#include "nsISHContainer.h"
#include "nsIURI.h"
#include "nsIHistoryEntry.h"
class nsSHEntryShared;
@ -32,7 +31,6 @@ public:
nsSHEntry(const nsSHEntry &other);
NS_DECL_ISUPPORTS
NS_DECL_NSIHISTORYENTRY
NS_DECL_NSISHENTRY
NS_DECL_NSISHENTRYINTERNAL
NS_DECL_NSISHCONTAINER

View File

@ -427,17 +427,14 @@ nsSHistory::AddEntry(nsISHEntry * aSHEntry, bool aPersist)
NS_ENSURE_TRUE(txn, NS_ERROR_FAILURE);
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIHistoryEntry> hEntry(do_QueryInterface(aSHEntry));
if (hEntry) {
int32_t currentIndex = mIndex;
hEntry->GetURI(getter_AddRefs(uri));
NOTIFY_LISTENERS(OnHistoryNewEntry, (uri));
int32_t currentIndex = mIndex;
aSHEntry->GetURI(getter_AddRefs(uri));
NOTIFY_LISTENERS(OnHistoryNewEntry, (uri));
// If a listener has changed mIndex, we need to get currentTxn again,
// otherwise we'll be left at an inconsistent state (see bug 320742)
if (currentIndex != mIndex) {
GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
}
// If a listener has changed mIndex, we need to get currentTxn again,
// otherwise we'll be left at an inconsistent state (see bug 320742)
if (currentIndex != mIndex) {
GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
}
// Set the ShEntry and parent for the transaction. setting the
@ -489,6 +486,7 @@ nsSHistory::GetRequestedIndex(int32_t * aResult)
return NS_OK;
}
/* Get the entry at a given index */
NS_IMETHODIMP
nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex, nsISHEntry** aResult)
{
@ -510,20 +508,6 @@ nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex, nsISHEntry** aRes
return rv;
}
/* Get the entry at a given index */
NS_IMETHODIMP
nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex, nsIHistoryEntry** aResult)
{
nsresult rv;
nsCOMPtr<nsISHEntry> shEntry;
rv = GetEntryAtIndex(aIndex, aModifyIndex, getter_AddRefs(shEntry));
if (NS_SUCCEEDED(rv) && shEntry)
rv = CallQueryInterface(shEntry, aResult);
return rv;
}
/* Get the transaction at a given index */
NS_IMETHODIMP
nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult)
@ -599,11 +583,8 @@ nsSHistory::PrintHistory()
nsXPIDLString title;
entry->GetLayoutHistoryState(getter_AddRefs(layoutHistoryState));
nsCOMPtr<nsIHistoryEntry> hEntry(do_QueryInterface(entry));
if (hEntry) {
hEntry->GetURI(getter_AddRefs(uri));
hEntry->GetTitle(getter_Copies(title));
}
entry->GetURI(getter_AddRefs(uri));
entry->GetTitle(getter_Copies(title));
#if 0
nsAutoCString url;
@ -1256,7 +1237,7 @@ RemoveFromSessionHistoryContainer(nsISHContainer* aContainer,
bool RemoveChildEntries(nsISHistory* aHistory, int32_t aIndex,
nsTArray<uint64_t>& aEntryIDs)
{
nsCOMPtr<nsIHistoryEntry> rootHE;
nsCOMPtr<nsISHEntry> rootHE;
aHistory->GetEntryAtIndex(aIndex, false, getter_AddRefs(rootHE));
nsCOMPtr<nsISHContainer> root = do_QueryInterface(rootHE);
return root ? RemoveFromSessionHistoryContainer(root, aEntryIDs) : false;
@ -1304,11 +1285,9 @@ nsSHistory::RemoveDuplicate(int32_t aIndex, bool aKeepNext)
"If we're removing index 0 we must be keeping the next");
NS_ASSERTION(aIndex != mIndex, "Shouldn't remove mIndex!");
int32_t compareIndex = aKeepNext ? aIndex + 1 : aIndex - 1;
nsCOMPtr<nsIHistoryEntry> rootHE1, rootHE2;
GetEntryAtIndex(aIndex, false, getter_AddRefs(rootHE1));
GetEntryAtIndex(compareIndex, false, getter_AddRefs(rootHE2));
nsCOMPtr<nsISHEntry> root1 = do_QueryInterface(rootHE1);
nsCOMPtr<nsISHEntry> root2 = do_QueryInterface(rootHE2);
nsCOMPtr<nsISHEntry> root1, root2;
GetEntryAtIndex(aIndex, false, getter_AddRefs(root1));
GetEntryAtIndex(compareIndex, false, getter_AddRefs(root2));
if (IsSameTree(root1, root2)) {
nsCOMPtr<nsISHTransaction> txToRemove, txToKeep, txNext, txPrev;
GetTransactionAtIndex(aIndex, getter_AddRefs(txToRemove));
@ -1457,7 +1436,7 @@ nsSHistory::GetCurrentURI(nsIURI** aResultURI)
NS_ENSURE_ARG_POINTER(aResultURI);
nsresult rv;
nsCOMPtr<nsIHistoryEntry> currentEntry;
nsCOMPtr<nsISHEntry> currentEntry;
rv = GetEntryAtIndex(mIndex, false, getter_AddRefs(currentEntry));
if (NS_FAILED(rv) && !currentEntry) return rv;
rv = currentEntry->GetURI(aResultURI);
@ -1531,8 +1510,7 @@ nsSHistory::LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd)
nsCOMPtr<nsISHEntry> nextEntry;
GetEntryAtIndex(mRequestedIndex, false, getter_AddRefs(nextEntry));
nsCOMPtr<nsIHistoryEntry> nHEntry(do_QueryInterface(nextEntry));
if (!nextEntry || !prevEntry || !nHEntry) {
if (!nextEntry || !prevEntry) {
mRequestedIndex = -1;
return NS_ERROR_FAILURE;
}
@ -1548,7 +1526,7 @@ nsSHistory::LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd)
bool canNavigate = true;
// Get the uri for the entry we are about to visit
nsCOMPtr<nsIURI> nextURI;
nHEntry->GetURI(getter_AddRefs(nextURI));
nextEntry->GetURI(getter_AddRefs(nextURI));
if (aHistCmd == HIST_CMD_BACK) {
// We are going back one entry. Send GoBack notifications
@ -1753,8 +1731,7 @@ nsSHistory::InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long
loadInfo->SetSHEntry(aFrameEntry);
nsCOMPtr<nsIURI> nextURI;
nsCOMPtr<nsIHistoryEntry> hEntry(do_QueryInterface(aFrameEntry));
hEntry->GetURI(getter_AddRefs(nextURI));
aFrameEntry->GetURI(getter_AddRefs(nextURI));
// Time to initiate a document load
return aFrameDS->LoadURI(nextURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
@ -1833,7 +1810,7 @@ nsSHEnumerator::GetNext(nsISupports **aItem)
mSHistory->GetCount(&cnt);
if (mIndex < (cnt-1)) {
mIndex++;
nsCOMPtr<nsIHistoryEntry> hEntry;
nsCOMPtr<nsISHEntry> hEntry;
result = mSHistory->GetEntryAtIndex(mIndex, false, getter_AddRefs(hEntry));
if (hEntry)
result = CallQueryInterface(hEntry, aItem);

View File

@ -18,7 +18,7 @@
#include "nsIWeakReference.h"
#include "nsISimpleEnumerator.h"
#include "nsISHistoryListener.h"
#include "nsIHistoryEntry.h"
#include "nsISHEntry.h"
#include "nsTObserverArray.h"
// Needed to maintain global list of all SHistory objects
@ -57,7 +57,6 @@ protected:
friend class nsSHistoryObserver;
// Could become part of nsIWebNavigation
NS_IMETHOD GetEntryAtIndex(int32_t aIndex, bool aModifyIndex, nsISHEntry** aResult);
NS_IMETHOD GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult);
nsresult CompareFrames(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell, long aLoadType, bool * aIsFrameFound);
nsresult InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long aLoadType);

View File

@ -13,7 +13,6 @@
#include "nsPresContext.h"
#include "nsIDocShell.h"
#include "nsIWebNavigation.h"
#include "nsIHistoryEntry.h"
#include "nsIURI.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsReadableUtils.h"