diff --git a/mozilla/docshell/shistory/public/nsISHTransaction.idl b/mozilla/docshell/shistory/public/nsISHTransaction.idl index 46cd40426a3..6120feeedad 100644 --- a/mozilla/docshell/shistory/public/nsISHTransaction.idl +++ b/mozilla/docshell/shistory/public/nsISHTransaction.idl @@ -36,7 +36,7 @@ interface nsISHTransaction : nsISupports /** * The nsISHEntry for the current transaction */ - readonly attribute nsISHEntry sHEntry; + attribute nsISHEntry sHEntry; /** * The parent of this transaction @@ -53,6 +53,12 @@ interface nsISHTransaction : nsISupports */ readonly attribute nsISHTransaction lrvList; + /** + * Specifies if this transaction should persist. If not it will be replaced + * by new additions to the list. + */ + attribute boolean persist; + /** * Create a transaction with parent and History Entry */ diff --git a/mozilla/docshell/shistory/public/nsISHistory.idl b/mozilla/docshell/shistory/public/nsISHistory.idl index 9cba8e9bedc..1c932f587b9 100644 --- a/mozilla/docshell/shistory/public/nsISHistory.idl +++ b/mozilla/docshell/shistory/public/nsISHistory.idl @@ -38,8 +38,12 @@ interface nsISHistory: nsISupports { /** * Add a new Entry to the History List + * @param aEntry - The entry to add + * @param aPersist - If true this specifies that the entry should persist + * in the list. If false, this means that when new entries are added + * this element will not appear in the session history list. */ - void addEntry(in nsISHEntry aEntry); + void addEntry(in nsISHEntry aEntry, in boolean aPersist); /** * Get the size of the History list diff --git a/mozilla/docshell/shistory/src/nsSHTransaction.cpp b/mozilla/docshell/shistory/src/nsSHTransaction.cpp index 70da7ace4a3..b0843f4be3e 100644 --- a/mozilla/docshell/shistory/src/nsSHTransaction.cpp +++ b/mozilla/docshell/shistory/src/nsSHTransaction.cpp @@ -40,7 +40,8 @@ NS_IMPL_ISUPPORTS1(nsSHTransaction, nsISHTransaction) -nsSHTransaction::nsSHTransaction() : mParent(nsnull), mChild(nsnull),mLRVList(nsnull), mSHEntry(nsnull) +nsSHTransaction::nsSHTransaction() : mPersist(PR_TRUE), mParent(nsnull), + mChild(nsnull), mLRVList(nsnull), mSHEntry(nsnull) { NS_INIT_REFCNT(); } @@ -157,6 +158,22 @@ nsSHTransaction::GetLrvList(nsISHTransaction ** aResult) return NS_OK; } +NS_IMETHODIMP +nsSHTransaction::SetPersist(PRBool aPersist) +{ + mPersist = aPersist; + return NS_OK; +} + +NS_IMETHODIMP +nsSHTransaction::GetPersist(PRBool* aPersist) +{ + NS_ENSURE_ARG_POINTER(aPersist); + + *aPersist = mPersist; + return NS_OK; +} + NS_IMETHODIMP NS_NewSHTransaction(nsISupports* aOuter, REFNSIID aIID, void** aResult) diff --git a/mozilla/docshell/shistory/src/nsSHTransaction.h b/mozilla/docshell/shistory/src/nsSHTransaction.h index c395529cdff..6ef82cddd9c 100644 --- a/mozilla/docshell/shistory/src/nsSHTransaction.h +++ b/mozilla/docshell/shistory/src/nsSHTransaction.h @@ -43,9 +43,11 @@ private: NS_NewSHTransaction(nsISupports * aOuter, REFNSIID aIID, void** aResult); nsresult SetChild(nsISHTransaction * aChild); nsresult SetParent(nsISHTransaction * aParent); - nsresult SetSHEntry(nsISHEntry * aSHEntry); + //nsresult SetSHEntry(nsISHEntry * aSHEntry); //nsresult SetLRVList(nsISHTransaction * aLRVList); + PRBool mPersist; + /* Weak reference to parent */ nsISHTransaction * mParent; nsISHTransaction * mChild; diff --git a/mozilla/docshell/shistory/src/nsSHistory.cpp b/mozilla/docshell/shistory/src/nsSHistory.cpp index 80169af354c..6e7f53a02ae 100644 --- a/mozilla/docshell/shistory/src/nsSHistory.cpp +++ b/mozilla/docshell/shistory/src/nsSHistory.cpp @@ -57,37 +57,41 @@ nsSHistory::~nsSHistory() * increment the index to point to the new entry */ NS_IMETHODIMP -nsSHistory::AddEntry(nsISHEntry * aSHEntry) +nsSHistory::AddEntry(nsISHEntry * aSHEntry, PRBool aPersist) { - nsresult rv; + NS_ENSURE_ARG(aSHEntry); - NS_PRECONDITION(aSHEntry != nsnull, "null ptr"); - if (! aSHEntry) - return NS_ERROR_NULL_POINTER; + nsCOMPtr currentTxn; - nsCOMPtr txn; - rv = nsComponentManager::CreateInstance(NS_SHTRANSACTION_PROGID, - nsnull, - NS_GET_IID(nsISHTransaction), - getter_AddRefs(txn)); - nsCOMPtr parent; + if(mListRoot) + GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn)); + + PRBool currentPersist = PR_TRUE; + if(currentTxn) + currentTxn->GetPersist(¤tPersist); + + if(!currentPersist) + { + NS_ENSURE_SUCCESS(currentTxn->SetSHEntry(aSHEntry), + NS_ERROR_FAILURE); + return NS_OK; + } + + nsCOMPtr txn(do_CreateInstance(NS_SHTRANSACTION_PROGID)); + NS_ENSURE_TRUE(txn, NS_ERROR_FAILURE); + + // Set the ShEntry and parent for the transaction. setting the + // parent will properly set the parent child relationship + txn->SetPersist(aPersist); + NS_ENSURE_SUCCESS(txn->Create(aSHEntry, currentTxn), NS_ERROR_FAILURE); + + mLength++; + mIndex++; + // If this is the very first transaction, initialize the list + if(!mListRoot) + mListRoot = txn; + PrintHistory(); - if (NS_SUCCEEDED(rv) && txn) { - if (mListRoot) { - GetTransactionAtIndex(mIndex, getter_AddRefs(parent)); - } - // Set the ShEntry and parent for the transaction. setting the - // parent will properly set the parent child relationship - rv = txn->Create(aSHEntry, parent); - if (NS_SUCCEEDED(rv)) { - mLength++; - mIndex++; - // If this is the very first transaction, initialize the list - if (!mListRoot) - mListRoot = txn; - PrintHistory(); - } - } return NS_OK; }