зеркало из https://github.com/mozilla/gecko-dev.git
Changed the concept of the transaction parent/ child to be previous and next. This flows better with actual relationship they hold in session history terms. The prev and next are also now not just readonly to allow properly setting up the list while avoiding nasty casts to implementation objects. Removed a bunch of dead code. Changed the module object to use generic factories and removed the hand created NS_New* functions. Changed over to interface maps in some places. The nsSHEntry obect no longer has the concept of children. There is no need since frame state will be stored in the layout history state object. This means nsSHEntry no longer implements the nsISHContainer interface.
This commit is contained in:
Родитель
e09822e492
Коммит
6c129ab6e3
|
@ -53,9 +53,6 @@ attribute nsIInputStream postData;
|
|||
/** LayoutHistoryState for scroll position and form values */
|
||||
attribute nsILayoutHistoryState layoutHistoryState;
|
||||
|
||||
/** Parent of the current entry */
|
||||
attribute nsISHEntry parent;
|
||||
|
||||
/** Additional ways to create an entry */
|
||||
void create(in nsIURI aURI, in wstring aTitle, in nsIDOMDocument aDocument,
|
||||
in nsIInputStream aInputStream, in nsILayoutHistoryState aHistoryLayoutState);
|
||||
|
|
|
@ -41,15 +41,15 @@ interface nsISHTransaction : nsISupports
|
|||
/**
|
||||
* The parent of this transaction
|
||||
*/
|
||||
readonly attribute nsISHTransaction parent;
|
||||
attribute nsISHTransaction prev;
|
||||
|
||||
/**
|
||||
* The legitimate child of this transaction
|
||||
*/
|
||||
readonly attribute nsISHTransaction child;
|
||||
attribute nsISHTransaction next;
|
||||
|
||||
/**
|
||||
* The *other* children of this transaction.
|
||||
* The other paths that have been navigated from this transaction
|
||||
*/
|
||||
readonly attribute nsISHTransaction lrvList;
|
||||
|
||||
|
@ -62,7 +62,7 @@ interface nsISHTransaction : nsISupports
|
|||
/**
|
||||
* Create a transaction with parent and History Entry
|
||||
*/
|
||||
void create(in nsISHEntry aSHEntry, in nsISHTransaction aParent);
|
||||
void create(in nsISHEntry aSHEntry, in nsISHTransaction aPrev);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -20,45 +20,9 @@
|
|||
* Radha Kulkarni <radha@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
// Local Includes
|
||||
#include "nsSHEntry.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
#ifdef XXX_NS_DEBUG // XXX: we'll need a logging facility for debugging
|
||||
#define WEB_TRACE(_bit,_args) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (WEB_LOG_TEST(gLogModule,_bit)) { \
|
||||
PR_LogPrint _args; \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
#define WEB_TRACE(_bit,_args)
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsSHEnumerator: Object Management
|
||||
//*****************************************************************************
|
||||
class nsSHEnumerator : public nsIEnumerator
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIENUMERATOR
|
||||
NS_IMETHOD CurrentItem(nsISHEntry ** aItem);
|
||||
|
||||
private:
|
||||
friend class nsSHEntry;
|
||||
|
||||
nsSHEnumerator(nsSHEntry * aEntry);
|
||||
virtual ~nsSHEnumerator();
|
||||
|
||||
PRInt32 mIndex;
|
||||
nsSHEntry * mSHEntry;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsSHEntry: Object Management
|
||||
|
@ -69,40 +33,8 @@ nsSHEntry::nsSHEntry()
|
|||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::Create(nsIURI * aURI, const PRUnichar * aTitle, nsIDOMDocument * aDOMDocument,
|
||||
nsIInputStream * aInputStream, nsILayoutHistoryState * aHistoryLayoutState)
|
||||
{
|
||||
SetURI(aURI);
|
||||
SetTitle(aTitle);
|
||||
SetDocument(aDOMDocument);
|
||||
SetPostData(aInputStream);
|
||||
SetLayoutHistoryState(aHistoryLayoutState);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsSHEntry::~nsSHEntry()
|
||||
{
|
||||
DestroyChildren();
|
||||
}
|
||||
|
||||
void
|
||||
nsSHEntry::DestroyChildren() {
|
||||
|
||||
PRInt32 i, n;
|
||||
|
||||
n = GetChildCount(&n);
|
||||
for (i = 0; i < n; i++) {
|
||||
nsISHEntry* child = (nsISHEntry *) mChildren.ElementAt(i);
|
||||
child->SetParent(nsnull); // Weak reference to parent
|
||||
delete child;
|
||||
}
|
||||
mChildren.Clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -115,11 +47,10 @@ NS_IMPL_RELEASE(nsSHEntry)
|
|||
NS_INTERFACE_MAP_BEGIN(nsSHEntry)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHEntry)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHEntry)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHContainer)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsSHEntry: nsISupports
|
||||
// nsSHEntry: nsISHEntry
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsSHEntry::GetURI(nsIURI** aURI)
|
||||
|
@ -196,218 +127,15 @@ NS_IMETHODIMP nsSHEntry::SetLayoutHistoryState(nsILayoutHistoryState* aState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSHEntry::GetParent(nsISHEntry** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = mParent;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSHEntry::SetParent(nsISHEntry* aParent)
|
||||
{
|
||||
/* parent not Addrefed on purpose to avoid cyclic reference
|
||||
* Null parent is OK
|
||||
*/
|
||||
mParent = aParent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSHEntry::GetChildCount(PRInt32* aCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCount);
|
||||
|
||||
*aCount = mChildren.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSHEntry::AddChild(nsISHEntry* aChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChild);
|
||||
|
||||
NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);
|
||||
mChildren.AppendElement((void *)aChild);
|
||||
NS_ADDREF(aChild);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSHEntry::RemoveChild(nsISHEntry * aChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChild);
|
||||
|
||||
PRBool childRemoved = mChildren.RemoveElement((void *)aChild);
|
||||
if(childRemoved)
|
||||
{
|
||||
aChild->SetParent(nsnull);
|
||||
NS_RELEASE(aChild);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSHEntry::GetChildEnumerator(nsIEnumerator** aChildEnumerator)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChildEnumerator);
|
||||
|
||||
nsresult status = NS_OK;
|
||||
|
||||
nsSHEnumerator* iterator = new nsSHEnumerator(this);
|
||||
if(iterator && !!NS_SUCCEEDED(status = CallQueryInterface(iterator, aChildEnumerator)))
|
||||
delete iterator;
|
||||
return status;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsSHEnumerator: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
nsSHEnumerator::nsSHEnumerator(nsSHEntry * aEntry):mIndex(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mSHEntry = aEntry;
|
||||
}
|
||||
|
||||
nsSHEnumerator::~nsSHEnumerator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEnumerator::Next()
|
||||
nsSHEntry::Create(nsIURI * aURI, const PRUnichar * aTitle, nsIDOMDocument * aDOMDocument,
|
||||
nsIInputStream * aInputStream, nsILayoutHistoryState * aHistoryLayoutState)
|
||||
{
|
||||
mIndex++;
|
||||
PRUint32 cnt=0;
|
||||
cnt = mSHEntry->mChildren.Count();
|
||||
if (mIndex < (PRInt32)cnt)
|
||||
SetURI(aURI);
|
||||
SetTitle(aTitle);
|
||||
SetDocument(aDOMDocument);
|
||||
SetPostData(aInputStream);
|
||||
SetLayoutHistoryState(aHistoryLayoutState);
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsSHEnumerator::Prev()
|
||||
{
|
||||
mIndex--;
|
||||
if (mIndex >= 0 )
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEnumerator::Last()
|
||||
{
|
||||
PRUint32 cnt;
|
||||
nsresult rv = mSHEntry->mChildren.Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mIndex = (PRInt32)cnt-1;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEnumerator::First()
|
||||
{
|
||||
mIndex = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEnumerator::CurrentItem(nsISupports **aItem)
|
||||
{
|
||||
if (!aItem)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
PRUint32 cnt= mSHEntry->mChildren.Count();
|
||||
if (mIndex >=0 && mIndex < (PRInt32)cnt){
|
||||
*aItem = (nsISupports *)mSHEntry->mChildren.ElementAt(mIndex);
|
||||
NS_IF_ADDREF(*aItem);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSHEnumerator, nsIEnumerator)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEnumerator::CurrentItem(nsISHEntry **aItem)
|
||||
{
|
||||
if (!aItem)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
PRUint32 cnt = mSHEntry->mChildren.Count();
|
||||
if (mIndex >=0 && mIndex < (PRInt32)cnt){
|
||||
nsCOMPtr<nsISupports> indexIsupports = (nsISHEntry *) mSHEntry->mChildren.ElementAt(mIndex);
|
||||
return indexIsupports->QueryInterface(NS_GET_IID(nsISHEntry),(void **)aItem);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEnumerator::IsDone()
|
||||
{
|
||||
PRUint32 cnt;
|
||||
cnt = mSHEntry->mChildren.Count();
|
||||
if (mIndex >= 0 && mIndex < (PRInt32)cnt ) {
|
||||
return NS_ENUMERATOR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsRangeListIterator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIEnumerator))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIEnumerator*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIBidirectionalEnumerator))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIBidirectionalEnumerator*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return mDomSelection->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////END nsSHEnumerator methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewSHEntry(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aOuter == nsnull, "no aggregation");
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsSHEntry* result = new nsSHEntry();
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
rv = result->QueryInterface(aIID, aResult);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
delete result;
|
||||
*aResult = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
|
|
@ -23,40 +23,33 @@
|
|||
#ifndef nsSHEntry_h
|
||||
#define nsSHEntry_h
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsISHContainer.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
|
||||
class nsSHEnumerator;
|
||||
class nsSHEntry : public nsISHEntry,
|
||||
public nsISHContainer
|
||||
// Interfaces needed
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
class nsSHEntry : public nsISHEntry
|
||||
{
|
||||
public:
|
||||
nsSHEntry();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHENTRY
|
||||
NS_DECL_NSISHCONTAINER
|
||||
|
||||
protected:
|
||||
void DestroyChildren();
|
||||
|
||||
private:
|
||||
virtual ~nsSHEntry();
|
||||
friend NS_IMETHODIMP
|
||||
NS_NewSHEntry(nsISupports* aOuter, REFNSIID aIID, void** aResult);
|
||||
friend class nsSHEnumerator;
|
||||
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsString mTitle;
|
||||
nsCOMPtr<nsIInputStream> mPostData;
|
||||
nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
|
||||
nsVoidArray mChildren;
|
||||
nsISHEntry * mParent; // weak reference to parent
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsSHEntry_h */
|
||||
|
|
|
@ -20,28 +20,14 @@
|
|||
* Radha Kulkarni <radha@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
// Local Includes
|
||||
#include "nsSHTransaction.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsSHTransaction: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
#ifdef XXX_NS_DEBUG // XXX: we'll need a logging facility for debugging
|
||||
#define WEB_TRACE(_bit,_args) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (WEB_LOG_TEST(gLogModule,_bit)) { \
|
||||
PR_LogPrint _args; \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
#define WEB_TRACE(_bit,_args)
|
||||
#endif
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSHTransaction, nsISHTransaction)
|
||||
|
||||
nsSHTransaction::nsSHTransaction() : mPersist(PR_TRUE), mParent(nsnull),
|
||||
mChild(nsnull), mLRVList(nsnull), mSHEntry(nsnull)
|
||||
nsSHTransaction::nsSHTransaction() : mPersist(PR_TRUE), mPrev(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -49,24 +35,32 @@ NS_INIT_REFCNT();
|
|||
|
||||
nsSHTransaction::~nsSHTransaction()
|
||||
{
|
||||
|
||||
NS_IF_RELEASE(mSHEntry);
|
||||
mParent = nsnull; //Weak reference to parent transaction
|
||||
NS_IF_RELEASE(mChild);
|
||||
NS_IF_RELEASE(mLRVList);
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsSHTransaction: nsISupports
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsSHTransaction)
|
||||
NS_IMPL_RELEASE(nsSHTransaction)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSHTransaction)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHTransaction)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsSHTransaction: nsISHTransaction
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::Create(nsISHEntry * aSHEntry, nsISHTransaction * aParent)
|
||||
nsSHTransaction::Create(nsISHEntry* aSHEntry, nsISHTransaction* aPrev)
|
||||
{
|
||||
SetSHEntry(aSHEntry);
|
||||
if (aParent) {
|
||||
// This will correctly set the parent child pointers
|
||||
((nsSHTransaction *)aParent)->SetChild(this);
|
||||
}
|
||||
else
|
||||
SetParent(nsnull);
|
||||
if(aPrev)
|
||||
aPrev->SetNext(this);
|
||||
|
||||
SetPrev(aPrev);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -75,76 +69,57 @@ nsSHTransaction::GetSHEntry(nsISHEntry ** aResult)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mSHEntry;
|
||||
NS_IF_ADDREF(mSHEntry);
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::SetSHEntry(nsISHEntry * aSHEntry)
|
||||
{
|
||||
NS_IF_RELEASE(mSHEntry);
|
||||
mSHEntry = aSHEntry;
|
||||
NS_IF_ADDREF(mSHEntry);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::GetChild(nsISHTransaction * * aResult)
|
||||
nsSHTransaction::GetNext(nsISHTransaction * * aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mChild;
|
||||
NS_IF_ADDREF(mChild);
|
||||
*aResult = mNext;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSHTransaction::SetChild(nsISHTransaction * aChild)
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::SetNext(nsISHTransaction * aNext)
|
||||
{
|
||||
if(mNext)
|
||||
{
|
||||
if (mChild) {
|
||||
// There is already a child. Move the child to the LRV list
|
||||
NS_IF_RELEASE(mLRVList);
|
||||
mLRVList = mChild;
|
||||
NS_ADDREF(mLRVList);
|
||||
//SetLRVList(mChild);
|
||||
mLRVList = mNext;
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(((nsSHTransaction *)aChild)->SetParent(this), NS_ERROR_FAILURE);
|
||||
NS_IF_RELEASE(mChild);
|
||||
mChild = aChild;
|
||||
NS_IF_ADDREF(aChild);
|
||||
NS_ENSURE_SUCCESS(aNext->SetPrev(this), NS_ERROR_FAILURE);
|
||||
|
||||
mNext = aNext;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsSHTransaction::SetParent(nsISHTransaction * aParent)
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::SetPrev(nsISHTransaction * aPrev)
|
||||
{
|
||||
/* This is weak reference to parent. Do not Addref it */
|
||||
mParent = aParent;
|
||||
mPrev = aPrev;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::SetLRVList(nsISHTransaction * aLRVList) {
|
||||
|
||||
NS_IF_RELEASE(mLRVList);
|
||||
mLRVList = aLRVList;
|
||||
NS_IF_ADDREF(mLRVList);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
nsresult
|
||||
nsSHTransaction::GetParent(nsISHTransaction ** aResult)
|
||||
nsSHTransaction::GetPrev(nsISHTransaction ** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mParent;
|
||||
*aResult = mPrev;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -154,7 +129,7 @@ nsSHTransaction::GetLrvList(nsISHTransaction ** aResult)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mLRVList;
|
||||
NS_IF_ADDREF(mLRVList);
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -173,33 +148,3 @@ nsSHTransaction::GetPersist(PRBool* aPersist)
|
|||
*aPersist = mPersist;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewSHTransaction(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aOuter == nsnull, "no aggregation");
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsSHTransaction* result = new nsSHTransaction();
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
rv = result->QueryInterface(aIID, aResult);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
delete result;
|
||||
*aResult = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
#ifndef nsSHTransaction_h
|
||||
#define nsSHTransaction_h
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// Needed interfaces
|
||||
#include "nsISHTransaction.h"
|
||||
#include "nsISHEntry.h"
|
||||
|
||||
|
@ -38,22 +42,13 @@ protected:
|
|||
virtual ~nsSHTransaction();
|
||||
|
||||
|
||||
private:
|
||||
friend NS_IMETHODIMP
|
||||
NS_NewSHTransaction(nsISupports * aOuter, REFNSIID aIID, void** aResult);
|
||||
nsresult SetChild(nsISHTransaction * aChild);
|
||||
nsresult SetParent(nsISHTransaction * aParent);
|
||||
//nsresult SetSHEntry(nsISHEntry * aSHEntry);
|
||||
//nsresult SetLRVList(nsISHTransaction * aLRVList);
|
||||
|
||||
protected:
|
||||
PRBool mPersist;
|
||||
|
||||
/* Weak reference to parent */
|
||||
nsISHTransaction * mParent;
|
||||
nsISHTransaction * mChild;
|
||||
nsISHTransaction * mLRVList;
|
||||
nsISHEntry * mSHEntry;
|
||||
|
||||
nsISHTransaction * mPrev; // Weak Reference
|
||||
nsCOMPtr<nsISHTransaction> mNext;
|
||||
nsCOMPtr<nsISHTransaction> mLRVList;
|
||||
nsCOMPtr<nsISHEntry> mSHEntry;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -21,27 +21,19 @@
|
|||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
// Local Includes
|
||||
#include "nsSHistory.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
// Helper Classes
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
|
||||
|
||||
#ifdef XXX_NS_DEBUG // XXX: we'll need a logging facility for debugging
|
||||
#define WEB_TRACE(_bit,_args) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (WEB_LOG_TEST(gLogModule,_bit)) { \
|
||||
PR_LogPrint _args; \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
#define WEB_TRACE(_bit,_args)
|
||||
#endif
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSHistory, nsISHistory)
|
||||
//*****************************************************************************
|
||||
//*** nsSHistory: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
nsSHistory::nsSHistory() : mListRoot(nsnull), mIndex(-1), mLength(0)
|
||||
{
|
||||
|
@ -51,9 +43,24 @@ NS_INIT_REFCNT();
|
|||
|
||||
nsSHistory::~nsSHistory()
|
||||
{
|
||||
//NS_IF_RELEASE(mListRoot);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsSHistory: nsISupports
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsSHistory)
|
||||
NS_IMPL_RELEASE(nsSHistory)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSHistory)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHistory)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsSHistory: nsISHistory
|
||||
//*****************************************************************************
|
||||
|
||||
/* Add an entry to the History list at mIndex and
|
||||
* increment the index to point to the new entry
|
||||
*/
|
||||
|
@ -86,8 +93,11 @@ nsSHistory::AddEntry(nsISHEntry * aSHEntry, PRBool aPersist)
|
|||
txn->SetPersist(aPersist);
|
||||
NS_ENSURE_SUCCESS(txn->Create(aSHEntry, currentTxn), NS_ERROR_FAILURE);
|
||||
|
||||
mLength++;
|
||||
mIndex++;
|
||||
// A little tricky math here... Basically when adding an object regardless of
|
||||
// what the length was before, it should always be set back to the current and
|
||||
// lop off the forward.
|
||||
mLength = (++mIndex + 1);
|
||||
|
||||
// If this is the very first transaction, initialize the list
|
||||
if(!mListRoot)
|
||||
mListRoot = txn;
|
||||
|
@ -187,7 +197,7 @@ nsSHistory::GetTransactionAtIndex(PRInt32 aIndex, nsISHTransaction ** aResult)
|
|||
|
||||
while(1) {
|
||||
nsCOMPtr<nsISHTransaction> ptr;
|
||||
rv = tempPtr->GetChild(getter_AddRefs(ptr));
|
||||
rv = tempPtr->GetNext(getter_AddRefs(ptr));
|
||||
if (NS_SUCCEEDED(rv) && ptr) {
|
||||
cnt++;
|
||||
if (cnt == aIndex) {
|
||||
|
@ -251,10 +261,10 @@ nsSHistory::PrintHistory()
|
|||
Recycle(title);
|
||||
Recycle(titleCStr);
|
||||
|
||||
nsCOMPtr<nsISHTransaction> child;
|
||||
rv = txn->GetChild(getter_AddRefs(child));
|
||||
if (NS_SUCCEEDED(rv) && child) {
|
||||
txn = child;
|
||||
nsCOMPtr<nsISHTransaction> next;
|
||||
rv = txn->GetNext(getter_AddRefs(next));
|
||||
if (NS_SUCCEEDED(rv) && next) {
|
||||
txn = next;
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
@ -277,32 +287,3 @@ nsSHistory::GetRootTransaction(nsISHTransaction ** aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_NewSHistory(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aOuter == nsnull, "no aggregation");
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsSHistory* result = new nsSHistory();
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
rv = result->QueryInterface(aIID, aResult);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
delete result;
|
||||
*aResult = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -23,28 +23,28 @@
|
|||
#ifndef nsSHistory_h
|
||||
#define nsSHistory_h
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISHistory.h"
|
||||
|
||||
class nsISHEntry;
|
||||
class nsISHTransaction;
|
||||
//Interfaces Needed
|
||||
#include "nsISHistory.h"
|
||||
#include "nsISHTransaction.h"
|
||||
|
||||
class nsSHistory: public nsISHistory
|
||||
{
|
||||
public:
|
||||
nsSHistory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHISTORY
|
||||
|
||||
nsSHistory();
|
||||
|
||||
protected:
|
||||
virtual ~nsSHistory();
|
||||
|
||||
private:
|
||||
friend NS_IMETHODIMP
|
||||
NS_NewSHistory(nsISupports * aOuter, REFNSIID aIID, void** aResult);
|
||||
NS_IMETHOD PrintHistory();
|
||||
NS_IMETHOD GetTransactionAtIndex(PRInt32 aIndex, nsISHTransaction ** aResult);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISHTransaction> mListRoot;
|
||||
PRInt32 mIndex;
|
||||
PRInt32 mLength;
|
||||
|
|
Загрузка…
Ссылка в новой задаче