зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1413013 - Remove unused nsITransactionList. r=masayuki
--HG-- extra : rebase_source : de3c858298d63d5658f38fc135ab1f2955dc834a
This commit is contained in:
Родитель
4371a10ca6
Коммит
f19a57edb0
|
@ -8,7 +8,6 @@ TEST_DIRS += ['tests']
|
|||
|
||||
XPIDL_SOURCES += [
|
||||
'nsITransaction.idl',
|
||||
'nsITransactionList.idl',
|
||||
'nsITransactionListener.idl',
|
||||
'nsITransactionManager.idl',
|
||||
]
|
||||
|
@ -21,7 +20,6 @@ EXPORTS += [
|
|||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsTransactionItem.cpp',
|
||||
'nsTransactionList.cpp',
|
||||
'nsTransactionManager.cpp',
|
||||
'nsTransactionManagerFactory.cpp',
|
||||
'nsTransactionStack.cpp',
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsITransaction;
|
||||
|
||||
/*
|
||||
* The nsITransactionList interface.
|
||||
* <P>
|
||||
* The implementation for this interface is provided by the Transaction Manager.
|
||||
* This interface provides a mechanism for accessing the transactions on the
|
||||
* Undo or Redo stacks as well as any auto-aggregated children that a
|
||||
* transaction may have.
|
||||
*/
|
||||
[scriptable, uuid(d007ceff-c978-486a-b697-384ca01997be)]
|
||||
|
||||
interface nsITransactionList : nsISupports
|
||||
{
|
||||
/**
|
||||
* The number of transactions contained in this list.
|
||||
*/
|
||||
readonly attribute long numItems;
|
||||
|
||||
/**
|
||||
* itemIsBatch() returns true if the item at aIndex is a batch. Note that
|
||||
* currently there is no requirement for a TransactionManager implementation
|
||||
* to associate a toplevel nsITransaction with a batch so it is possible for
|
||||
* itemIsBatch() to return true and getItem() to return null. However, you
|
||||
* can still access the transactions contained in the batch with a call to
|
||||
* getChildListForItem().
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
boolean itemIsBatch(in long aIndex);
|
||||
|
||||
/**
|
||||
* getItem() returns the transaction at the given index in the list. Note that
|
||||
* a null can be returned here if the item is a batch. The transaction
|
||||
* returned is AddRef'd so it is up to the caller to Release the transaction
|
||||
* when it is done.
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
nsITransaction getItem(in long aIndex);
|
||||
|
||||
/**
|
||||
* getData() returns the data (of type nsISupports array) associated with
|
||||
* the transaction list.
|
||||
*/
|
||||
void getData(in long aIndex, [optional] out unsigned long aLength,
|
||||
[array, size_is(aLength), retval] out nsISupports aData);
|
||||
|
||||
/**
|
||||
* getNumChildrenForItem() returns the number of child (auto-aggreated)
|
||||
* transactions the item at aIndex has.
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
long getNumChildrenForItem(in long aIndex);
|
||||
|
||||
/**
|
||||
* getChildListForItem() returns the list of children associated with the
|
||||
* item at aIndex. Implementations may return null if there are no children,
|
||||
* or an empty list. The list returned is AddRef'd so it is up to the caller
|
||||
* to Release the transaction when it is done.
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
nsITransactionList getChildListForItem(in long aIndex);
|
||||
};
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsITransaction.idl"
|
||||
#include "nsITransactionList.idl"
|
||||
#include "nsITransactionListener.idl"
|
||||
|
||||
%{ C++
|
||||
|
@ -68,7 +67,7 @@ interface nsITransactionManager : nsISupports
|
|||
* application to execute and group together several independent transactions
|
||||
* so they can be undone with a single call to undoTransaction().
|
||||
* @param aData An arbitrary nsISupports object that is associated with the
|
||||
* batch. Can be retrieved from nsITransactionList.
|
||||
* batch. Can be retrieved from the undo or redo stacks.
|
||||
*/
|
||||
void beginBatch(in nsISupports aData);
|
||||
|
||||
|
@ -134,20 +133,6 @@ interface nsITransactionManager : nsISupports
|
|||
*/
|
||||
nsITransaction peekRedoStack();
|
||||
|
||||
/**
|
||||
* Returns the list of transactions on the undo stack. Note that the
|
||||
* transaction at the top of the undo stack will actually be at the
|
||||
* index 'n-1' in the list, where 'n' is the number of items in the list.
|
||||
*/
|
||||
nsITransactionList getUndoList();
|
||||
|
||||
/**
|
||||
* Returns the list of transactions on the redo stack. Note that the
|
||||
* transaction at the top of the redo stack will actually be at the
|
||||
* index 'n-1' in the list, where 'n' is the number of items in the list.
|
||||
*/
|
||||
nsITransactionList getRedoList();
|
||||
|
||||
/**
|
||||
* Adds a listener to the transaction manager's notification list. Listeners
|
||||
* are notified whenever a transaction is done, undone, or redone.
|
||||
|
|
|
@ -1,174 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsError.h"
|
||||
#include "nsID.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsTransactionItem.h"
|
||||
#include "nsTransactionList.h"
|
||||
#include "nsTransactionStack.h"
|
||||
#include "nscore.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTransactionList, nsITransactionList)
|
||||
|
||||
nsTransactionList::nsTransactionList(nsITransactionManager *aTxnMgr, nsTransactionStack *aTxnStack)
|
||||
: mTxnStack(aTxnStack)
|
||||
, mTxnItem(nullptr)
|
||||
{
|
||||
if (aTxnMgr)
|
||||
mTxnMgr = do_GetWeakReference(aTxnMgr);
|
||||
}
|
||||
|
||||
nsTransactionList::nsTransactionList(nsITransactionManager *aTxnMgr, nsTransactionItem *aTxnItem)
|
||||
: mTxnStack(0)
|
||||
, mTxnItem(aTxnItem)
|
||||
{
|
||||
if (aTxnMgr)
|
||||
mTxnMgr = do_GetWeakReference(aTxnMgr);
|
||||
}
|
||||
|
||||
nsTransactionList::~nsTransactionList()
|
||||
{
|
||||
mTxnStack = 0;
|
||||
mTxnItem = nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransactionList::GetNumItems(int32_t *aNumItems)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNumItems, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aNumItems = 0;
|
||||
|
||||
nsCOMPtr<nsITransactionManager> txMgr = do_QueryReferent(mTxnMgr);
|
||||
NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE);
|
||||
|
||||
if (mTxnStack) {
|
||||
*aNumItems = mTxnStack->GetSize();
|
||||
} else if (mTxnItem) {
|
||||
return mTxnItem->GetNumberOfChildren(aNumItems);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransactionList::ItemIsBatch(int32_t aIndex, bool *aIsBatch)
|
||||
{
|
||||
NS_ENSURE_TRUE(aIsBatch, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aIsBatch = false;
|
||||
|
||||
nsCOMPtr<nsITransactionManager> txMgr = do_QueryReferent(mTxnMgr);
|
||||
NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<nsTransactionItem> item;
|
||||
if (mTxnStack) {
|
||||
item = mTxnStack->GetItem(aIndex);
|
||||
} else if (mTxnItem) {
|
||||
nsresult rv = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
return item->GetIsBatch(aIsBatch);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransactionList::GetData(int32_t aIndex,
|
||||
uint32_t *aLength,
|
||||
nsISupports ***aData)
|
||||
{
|
||||
nsCOMPtr<nsITransactionManager> txMgr = do_QueryReferent(mTxnMgr);
|
||||
NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<nsTransactionItem> item;
|
||||
if (mTxnStack) {
|
||||
item = mTxnStack->GetItem(aIndex);
|
||||
} else if (mTxnItem) {
|
||||
nsresult rv = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMArray<nsISupports>& data = item->GetData();
|
||||
nsISupports** ret = static_cast<nsISupports**>(moz_xmalloc(data.Count() *
|
||||
sizeof(nsISupports*)));
|
||||
|
||||
for (int32_t i = 0; i < data.Count(); i++) {
|
||||
NS_ADDREF(ret[i] = data[i]);
|
||||
}
|
||||
*aLength = data.Count();
|
||||
*aData = ret;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransactionList::GetItem(int32_t aIndex, nsITransaction **aItem)
|
||||
{
|
||||
NS_ENSURE_TRUE(aItem, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aItem = 0;
|
||||
|
||||
nsCOMPtr<nsITransactionManager> txMgr = do_QueryReferent(mTxnMgr);
|
||||
NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<nsTransactionItem> item;
|
||||
if (mTxnStack) {
|
||||
item = mTxnStack->GetItem(aIndex);
|
||||
} else if (mTxnItem) {
|
||||
nsresult rv = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
*aItem = item->GetTransaction().take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransactionList::GetNumChildrenForItem(int32_t aIndex, int32_t *aNumChildren)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNumChildren, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aNumChildren = 0;
|
||||
|
||||
nsCOMPtr<nsITransactionManager> txMgr = do_QueryReferent(mTxnMgr);
|
||||
NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<nsTransactionItem> item;
|
||||
if (mTxnStack) {
|
||||
item = mTxnStack->GetItem(aIndex);
|
||||
} else if (mTxnItem) {
|
||||
nsresult rv = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
return item->GetNumberOfChildren(aNumChildren);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransactionList::GetChildListForItem(int32_t aIndex, nsITransactionList **aTxnList)
|
||||
{
|
||||
NS_ENSURE_TRUE(aTxnList, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aTxnList = 0;
|
||||
|
||||
nsCOMPtr<nsITransactionManager> txMgr = do_QueryReferent(mTxnMgr);
|
||||
NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<nsTransactionItem> item;
|
||||
if (mTxnStack) {
|
||||
item = mTxnStack->GetItem(aIndex);
|
||||
} else if (mTxnItem) {
|
||||
nsresult rv = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
*aTxnList = (nsITransactionList *)new nsTransactionList(txMgr, item);
|
||||
NS_ENSURE_TRUE(*aTxnList, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aTxnList);
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef nsTransactionList_h__
|
||||
#define nsTransactionList_h__
|
||||
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsITransactionList.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
|
||||
class nsITransaction;
|
||||
class nsITransactionManager;
|
||||
class nsTransactionItem;
|
||||
class nsTransactionStack;
|
||||
|
||||
/** implementation of a transaction list object.
|
||||
*
|
||||
*/
|
||||
class nsTransactionList : public nsITransactionList
|
||||
{
|
||||
private:
|
||||
|
||||
nsWeakPtr mTxnMgr;
|
||||
nsTransactionStack *mTxnStack;
|
||||
RefPtr<nsTransactionItem> mTxnItem;
|
||||
|
||||
protected:
|
||||
virtual ~nsTransactionList();
|
||||
|
||||
public:
|
||||
|
||||
nsTransactionList(nsITransactionManager *aTxnMgr, nsTransactionStack *aTxnStack);
|
||||
nsTransactionList(nsITransactionManager *aTxnMgr, nsTransactionItem *aTxnItem);
|
||||
|
||||
/* Macro for AddRef(), Release(), and QueryInterface() */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* nsITransactionManager method implementations. */
|
||||
NS_DECL_NSITRANSACTIONLIST
|
||||
|
||||
/* nsTransactionList specific methods. */
|
||||
};
|
||||
|
||||
#endif // nsTransactionList_h__
|
|
@ -11,11 +11,9 @@
|
|||
#include "nsISupportsBase.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsITransaction.h"
|
||||
#include "nsITransactionList.h"
|
||||
#include "nsITransactionListener.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsTransactionItem.h"
|
||||
#include "nsTransactionList.h"
|
||||
#include "nsTransactionManager.h"
|
||||
#include "nsTransactionStack.h"
|
||||
|
||||
|
@ -369,26 +367,6 @@ nsTransactionManager::PeekRedoStack()
|
|||
return tx->GetTransaction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::GetUndoList(nsITransactionList **aTransactionList)
|
||||
{
|
||||
NS_ENSURE_TRUE(aTransactionList, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mUndoStack);
|
||||
NS_IF_ADDREF(*aTransactionList);
|
||||
return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::GetRedoList(nsITransactionList **aTransactionList)
|
||||
{
|
||||
NS_ENSURE_TRUE(aTransactionList, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mRedoStack);
|
||||
NS_IF_ADDREF(*aTransactionList);
|
||||
return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionManager::BatchTopUndo()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче