From f19a57edb05b78c6fb4d7c3084f4e36831ec03ac Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 30 Oct 2017 20:35:00 +0000 Subject: [PATCH] Bug 1413013 - Remove unused nsITransactionList. r=masayuki --HG-- extra : rebase_source : de3c858298d63d5658f38fc135ab1f2955dc834a --- editor/txmgr/moz.build | 2 - editor/txmgr/nsITransactionList.idl | 70 ---------- editor/txmgr/nsITransactionManager.idl | 17 +-- editor/txmgr/nsTransactionList.cpp | 174 ------------------------- editor/txmgr/nsTransactionList.h | 46 ------- editor/txmgr/nsTransactionManager.cpp | 22 ---- 6 files changed, 1 insertion(+), 330 deletions(-) delete mode 100644 editor/txmgr/nsITransactionList.idl delete mode 100644 editor/txmgr/nsTransactionList.cpp delete mode 100644 editor/txmgr/nsTransactionList.h diff --git a/editor/txmgr/moz.build b/editor/txmgr/moz.build index 3c7f3b55a89a..38f54f9681d8 100644 --- a/editor/txmgr/moz.build +++ b/editor/txmgr/moz.build @@ -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', diff --git a/editor/txmgr/nsITransactionList.idl b/editor/txmgr/nsITransactionList.idl deleted file mode 100644 index de6d191de0b4..000000000000 --- a/editor/txmgr/nsITransactionList.idl +++ /dev/null @@ -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. - *

- * 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); -}; - diff --git a/editor/txmgr/nsITransactionManager.idl b/editor/txmgr/nsITransactionManager.idl index 0587d5ca1d58..e2e3b0a509e7 100644 --- a/editor/txmgr/nsITransactionManager.idl +++ b/editor/txmgr/nsITransactionManager.idl @@ -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. diff --git a/editor/txmgr/nsTransactionList.cpp b/editor/txmgr/nsTransactionList.cpp deleted file mode 100644 index 756edfd49749..000000000000 --- a/editor/txmgr/nsTransactionList.cpp +++ /dev/null @@ -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 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 txMgr = do_QueryReferent(mTxnMgr); - NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - - RefPtr 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 txMgr = do_QueryReferent(mTxnMgr); - NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - - RefPtr item; - if (mTxnStack) { - item = mTxnStack->GetItem(aIndex); - } else if (mTxnItem) { - nsresult rv = mTxnItem->GetChild(aIndex, getter_AddRefs(item)); - NS_ENSURE_SUCCESS(rv, rv); - } - - nsCOMArray& data = item->GetData(); - nsISupports** ret = static_cast(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 txMgr = do_QueryReferent(mTxnMgr); - NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - - RefPtr 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 txMgr = do_QueryReferent(mTxnMgr); - NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - - RefPtr 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 txMgr = do_QueryReferent(mTxnMgr); - NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); - - RefPtr 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; -} diff --git a/editor/txmgr/nsTransactionList.h b/editor/txmgr/nsTransactionList.h deleted file mode 100644 index e3dde1255bf0..000000000000 --- a/editor/txmgr/nsTransactionList.h +++ /dev/null @@ -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 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__ diff --git a/editor/txmgr/nsTransactionManager.cpp b/editor/txmgr/nsTransactionManager.cpp index 10f9c3d0643d..1d11cc688c59 100644 --- a/editor/txmgr/nsTransactionManager.cpp +++ b/editor/txmgr/nsTransactionManager.cpp @@ -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() {