mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1447924 - part 1: Rename nsTransactionManager to mozilla::TransactionManager r=m_kato
We should rename nsTransactionManager to mozilla::TransactionManager before adding new non-virtual methods. MozReview-Commit-ID: JsivNVfDhex --HG-- rename : editor/txmgr/nsTransactionManager.cpp => editor/txmgr/TransactionManager.cpp rename : editor/txmgr/nsTransactionManager.h => editor/txmgr/TransactionManager.h rename : editor/txmgr/nsTransactionManagerFactory.cpp => editor/txmgr/TransactionManagerFactory.cpp extra : rebase_source : ff5bf76fec8be8f6a1202c17d488cf6c607d8f03
This commit is contained in:
parent
e9d257856b
commit
c525b695b9
@ -48,6 +48,7 @@
|
|||||||
#include "mozilla/TextInputListener.h" // for TextInputListener
|
#include "mozilla/TextInputListener.h" // for TextInputListener
|
||||||
#include "mozilla/TextServicesDocument.h" // for TextServicesDocument
|
#include "mozilla/TextServicesDocument.h" // for TextServicesDocument
|
||||||
#include "mozilla/TextEvents.h"
|
#include "mozilla/TextEvents.h"
|
||||||
|
#include "mozilla/TransactionManager.h" // for TransactionManager
|
||||||
#include "mozilla/dom/CharacterData.h" // for CharacterData
|
#include "mozilla/dom/CharacterData.h" // for CharacterData
|
||||||
#include "mozilla/dom/Element.h" // for Element, nsINode::AsElement
|
#include "mozilla/dom/Element.h" // for Element, nsINode::AsElement
|
||||||
#include "mozilla/dom/HTMLBodyElement.h"
|
#include "mozilla/dom/HTMLBodyElement.h"
|
||||||
@ -108,7 +109,6 @@
|
|||||||
#include "nsStyleStructFwd.h" // for nsIFrame::StyleUIReset, etc.
|
#include "nsStyleStructFwd.h" // for nsIFrame::StyleUIReset, etc.
|
||||||
#include "nsTextNode.h" // for nsTextNode
|
#include "nsTextNode.h" // for nsTextNode
|
||||||
#include "nsThreadUtils.h" // for nsRunnable
|
#include "nsThreadUtils.h" // for nsRunnable
|
||||||
#include "nsTransactionManager.h" // for nsTransactionManager
|
|
||||||
#include "prtime.h" // for PR_Now
|
#include "prtime.h" // for PR_Now
|
||||||
|
|
||||||
class nsIOutputStream;
|
class nsIOutputStream;
|
||||||
@ -180,7 +180,7 @@ EditorBase::~EditorBase()
|
|||||||
}
|
}
|
||||||
// If this editor is still hiding the caret, we need to restore it.
|
// If this editor is still hiding the caret, we need to restore it.
|
||||||
HideCaret(false);
|
HideCaret(false);
|
||||||
mTxnMgr = nullptr;
|
mTransactionManager = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(EditorBase)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(EditorBase)
|
||||||
@ -193,7 +193,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(EditorBase)
|
|||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInlineSpellChecker)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInlineSpellChecker)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextServicesDocument)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextServicesDocument)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextInputListener)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextInputListener)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTxnMgr)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTransactionManager)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mActionListeners)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mActionListeners)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEditorObservers)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEditorObservers)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocStateListeners)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocStateListeners)
|
||||||
@ -223,7 +223,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(EditorBase)
|
|||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInlineSpellChecker)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInlineSpellChecker)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextServicesDocument)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextServicesDocument)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextInputListener)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextInputListener)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTxnMgr)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransactionManager)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mActionListeners)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mActionListeners)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEditorObservers)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEditorObservers)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocStateListeners)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocStateListeners)
|
||||||
@ -525,9 +525,9 @@ EditorBase::PreDestroy(bool aDestroyingFrames)
|
|||||||
|
|
||||||
// Transaction may grab this instance. Therefore, they should be released
|
// Transaction may grab this instance. Therefore, they should be released
|
||||||
// here for stopping the circular reference with this instance.
|
// here for stopping the circular reference with this instance.
|
||||||
if (mTxnMgr) {
|
if (mTransactionManager) {
|
||||||
mTxnMgr->Clear();
|
mTransactionManager->Clear();
|
||||||
mTxnMgr = nullptr;
|
mTransactionManager = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDidPreDestroy = true;
|
mDidPreDestroy = true;
|
||||||
@ -746,8 +746,9 @@ EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn)
|
|||||||
// We will recurse, but will not hit this case in the nested call
|
// We will recurse, but will not hit this case in the nested call
|
||||||
DoTransaction(mPlaceholderTransaction);
|
DoTransaction(mPlaceholderTransaction);
|
||||||
|
|
||||||
if (mTxnMgr) {
|
if (mTransactionManager) {
|
||||||
nsCOMPtr<nsITransaction> topTransaction = mTxnMgr->PeekUndoStack();
|
nsCOMPtr<nsITransaction> topTransaction =
|
||||||
|
mTransactionManager->PeekUndoStack();
|
||||||
nsCOMPtr<nsIAbsorbingTransaction> topAbsorbingTransaction =
|
nsCOMPtr<nsIAbsorbingTransaction> topAbsorbingTransaction =
|
||||||
do_QueryInterface(topTransaction);
|
do_QueryInterface(topTransaction);
|
||||||
if (topAbsorbingTransaction) {
|
if (topAbsorbingTransaction) {
|
||||||
@ -791,9 +792,9 @@ EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn)
|
|||||||
SelectionBatcher selectionBatcher(selection);
|
SelectionBatcher selectionBatcher(selection);
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (mTxnMgr) {
|
if (mTransactionManager) {
|
||||||
RefPtr<nsTransactionManager> txnMgr = mTxnMgr;
|
RefPtr<TransactionManager> transactionManager(mTransactionManager);
|
||||||
rv = txnMgr->DoTransaction(aTxn);
|
rv = transactionManager->DoTransaction(aTxn);
|
||||||
} else {
|
} else {
|
||||||
rv = aTxn->DoTransaction();
|
rv = aTxn->DoTransaction();
|
||||||
}
|
}
|
||||||
@ -811,14 +812,14 @@ NS_IMETHODIMP
|
|||||||
EditorBase::EnableUndo(bool aEnable)
|
EditorBase::EnableUndo(bool aEnable)
|
||||||
{
|
{
|
||||||
if (aEnable) {
|
if (aEnable) {
|
||||||
if (!mTxnMgr) {
|
if (!mTransactionManager) {
|
||||||
mTxnMgr = new nsTransactionManager();
|
mTransactionManager = new TransactionManager();
|
||||||
}
|
}
|
||||||
mTxnMgr->SetMaxTransactionCount(-1);
|
mTransactionManager->SetMaxTransactionCount(-1);
|
||||||
} else if (mTxnMgr) {
|
} else if (mTransactionManager) {
|
||||||
// disable the transaction manager if it is enabled
|
// disable the transaction manager if it is enabled
|
||||||
mTxnMgr->Clear();
|
mTransactionManager->Clear();
|
||||||
mTxnMgr->SetMaxTransactionCount(0);
|
mTransactionManager->SetMaxTransactionCount(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -834,11 +835,12 @@ EditorBase::GetNumberOfUndoItems(int32_t* aNumItems)
|
|||||||
int32_t
|
int32_t
|
||||||
EditorBase::NumberOfUndoItems() const
|
EditorBase::NumberOfUndoItems() const
|
||||||
{
|
{
|
||||||
if (!mTxnMgr) {
|
if (!mTransactionManager) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t numItems = 0;
|
int32_t numItems = 0;
|
||||||
if (NS_WARN_IF(NS_FAILED(mTxnMgr->GetNumberOfUndoItems(&numItems)))) {
|
nsresult rv = mTransactionManager->GetNumberOfUndoItems(&numItems);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return numItems;
|
return numItems;
|
||||||
@ -854,11 +856,12 @@ EditorBase::GetNumberOfRedoItems(int32_t* aNumItems)
|
|||||||
int32_t
|
int32_t
|
||||||
EditorBase::NumberOfRedoItems() const
|
EditorBase::NumberOfRedoItems() const
|
||||||
{
|
{
|
||||||
if (!mTxnMgr) {
|
if (!mTransactionManager) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t numItems = 0;
|
int32_t numItems = 0;
|
||||||
if (NS_WARN_IF(NS_FAILED(mTxnMgr->GetNumberOfRedoItems(&numItems)))) {
|
nsresult rv = mTransactionManager->GetNumberOfRedoItems(&numItems);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return numItems;
|
return numItems;
|
||||||
@ -882,7 +885,7 @@ EditorBase::GetTransactionManager(nsITransactionManager** aTxnManager)
|
|||||||
already_AddRefed<nsITransactionManager>
|
already_AddRefed<nsITransactionManager>
|
||||||
EditorBase::GetTransactionManager() const
|
EditorBase::GetTransactionManager() const
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsITransactionManager> transactionManager = mTxnMgr.get();
|
nsCOMPtr<nsITransactionManager> transactionManager(mTransactionManager);
|
||||||
return transactionManager.forget();
|
return transactionManager.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,19 +894,19 @@ EditorBase::Undo(uint32_t aCount)
|
|||||||
{
|
{
|
||||||
ForceCompositionEnd();
|
ForceCompositionEnd();
|
||||||
|
|
||||||
bool hasTxnMgr, hasTransaction = false;
|
bool hasTransactionManager, hasTransaction = false;
|
||||||
CanUndo(&hasTxnMgr, &hasTransaction);
|
CanUndo(&hasTransactionManager, &hasTransaction);
|
||||||
NS_ENSURE_TRUE(hasTransaction, NS_OK);
|
NS_ENSURE_TRUE(hasTransaction, NS_OK);
|
||||||
|
|
||||||
AutoRules beginRulesSniffing(this, EditAction::undo, nsIEditor::eNone);
|
AutoRules beginRulesSniffing(this, EditAction::undo, nsIEditor::eNone);
|
||||||
|
|
||||||
if (!mTxnMgr) {
|
if (!mTransactionManager) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<nsTransactionManager> txnMgr = mTxnMgr;
|
RefPtr<TransactionManager> transactionManager(mTransactionManager);
|
||||||
for (uint32_t i = 0; i < aCount; ++i) {
|
for (uint32_t i = 0; i < aCount; ++i) {
|
||||||
nsresult rv = txnMgr->UndoTransaction();
|
nsresult rv = transactionManager->UndoTransaction();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
DoAfterUndoTransaction();
|
DoAfterUndoTransaction();
|
||||||
@ -917,10 +920,10 @@ EditorBase::CanUndo(bool* aIsEnabled,
|
|||||||
bool* aCanUndo)
|
bool* aCanUndo)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aIsEnabled && aCanUndo, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(aIsEnabled && aCanUndo, NS_ERROR_NULL_POINTER);
|
||||||
*aIsEnabled = !!mTxnMgr;
|
*aIsEnabled = !!mTransactionManager;
|
||||||
if (*aIsEnabled) {
|
if (*aIsEnabled) {
|
||||||
int32_t numTxns = 0;
|
int32_t numTxns = 0;
|
||||||
mTxnMgr->GetNumberOfUndoItems(&numTxns);
|
mTransactionManager->GetNumberOfUndoItems(&numTxns);
|
||||||
*aCanUndo = !!numTxns;
|
*aCanUndo = !!numTxns;
|
||||||
} else {
|
} else {
|
||||||
*aCanUndo = false;
|
*aCanUndo = false;
|
||||||
@ -931,19 +934,19 @@ EditorBase::CanUndo(bool* aIsEnabled,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
EditorBase::Redo(uint32_t aCount)
|
EditorBase::Redo(uint32_t aCount)
|
||||||
{
|
{
|
||||||
bool hasTxnMgr, hasTransaction = false;
|
bool hasTransactionManager, hasTransaction = false;
|
||||||
CanRedo(&hasTxnMgr, &hasTransaction);
|
CanRedo(&hasTransactionManager, &hasTransaction);
|
||||||
NS_ENSURE_TRUE(hasTransaction, NS_OK);
|
NS_ENSURE_TRUE(hasTransaction, NS_OK);
|
||||||
|
|
||||||
AutoRules beginRulesSniffing(this, EditAction::redo, nsIEditor::eNone);
|
AutoRules beginRulesSniffing(this, EditAction::redo, nsIEditor::eNone);
|
||||||
|
|
||||||
if (!mTxnMgr) {
|
if (!mTransactionManager) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<nsTransactionManager> txnMgr = mTxnMgr;
|
RefPtr<TransactionManager> transactionManager(mTransactionManager);
|
||||||
for (uint32_t i = 0; i < aCount; ++i) {
|
for (uint32_t i = 0; i < aCount; ++i) {
|
||||||
nsresult rv = txnMgr->RedoTransaction();
|
nsresult rv = transactionManager->RedoTransaction();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
DoAfterRedoTransaction();
|
DoAfterRedoTransaction();
|
||||||
@ -957,10 +960,10 @@ EditorBase::CanRedo(bool* aIsEnabled, bool* aCanRedo)
|
|||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aIsEnabled && aCanRedo, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(aIsEnabled && aCanRedo, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
*aIsEnabled = !!mTxnMgr;
|
*aIsEnabled = !!mTransactionManager;
|
||||||
if (*aIsEnabled) {
|
if (*aIsEnabled) {
|
||||||
int32_t numTxns = 0;
|
int32_t numTxns = 0;
|
||||||
mTxnMgr->GetNumberOfRedoItems(&numTxns);
|
mTransactionManager->GetNumberOfRedoItems(&numTxns);
|
||||||
*aCanRedo = !!numTxns;
|
*aCanRedo = !!numTxns;
|
||||||
} else {
|
} else {
|
||||||
*aCanRedo = false;
|
*aCanRedo = false;
|
||||||
@ -973,9 +976,9 @@ EditorBase::BeginTransaction()
|
|||||||
{
|
{
|
||||||
BeginUpdateViewBatch();
|
BeginUpdateViewBatch();
|
||||||
|
|
||||||
if (mTxnMgr) {
|
if (mTransactionManager) {
|
||||||
RefPtr<nsTransactionManager> txnMgr = mTxnMgr;
|
RefPtr<TransactionManager> transactionManager(mTransactionManager);
|
||||||
txnMgr->BeginBatch(nullptr);
|
transactionManager->BeginBatch(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -984,9 +987,9 @@ EditorBase::BeginTransaction()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
EditorBase::EndTransaction()
|
EditorBase::EndTransaction()
|
||||||
{
|
{
|
||||||
if (mTxnMgr) {
|
if (mTransactionManager) {
|
||||||
RefPtr<nsTransactionManager> txnMgr = mTxnMgr;
|
RefPtr<TransactionManager> transactionManager(mTransactionManager);
|
||||||
txnMgr->EndBatch(false);
|
transactionManager->EndBatch(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndUpdateViewBatch();
|
EndUpdateViewBatch();
|
||||||
@ -2471,8 +2474,8 @@ EditorBase::EndIMEComposition()
|
|||||||
|
|
||||||
// commit the IME transaction..we can get at it via the transaction mgr.
|
// commit the IME transaction..we can get at it via the transaction mgr.
|
||||||
// Note that this means IME won't work without an undo stack!
|
// Note that this means IME won't work without an undo stack!
|
||||||
if (mTxnMgr) {
|
if (mTransactionManager) {
|
||||||
nsCOMPtr<nsITransaction> txn = mTxnMgr->PeekUndoStack();
|
nsCOMPtr<nsITransaction> txn = mTransactionManager->PeekUndoStack();
|
||||||
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
|
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
|
||||||
if (plcTxn) {
|
if (plcTxn) {
|
||||||
DebugOnly<nsresult> rv = plcTxn->Commit();
|
DebugOnly<nsresult> rv = plcTxn->Commit();
|
||||||
|
@ -51,7 +51,6 @@ class nsISupports;
|
|||||||
class nsITransaction;
|
class nsITransaction;
|
||||||
class nsIWidget;
|
class nsIWidget;
|
||||||
class nsRange;
|
class nsRange;
|
||||||
class nsTransactionManager;
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
class AddStyleSheetTransaction;
|
class AddStyleSheetTransaction;
|
||||||
@ -80,6 +79,7 @@ class TextComposition;
|
|||||||
class TextEditor;
|
class TextEditor;
|
||||||
class TextInputListener;
|
class TextInputListener;
|
||||||
class TextServicesDocument;
|
class TextServicesDocument;
|
||||||
|
class TransactionManager;
|
||||||
enum class EditAction : int32_t;
|
enum class EditAction : int32_t;
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
@ -1513,7 +1513,7 @@ protected:
|
|||||||
// Reference to text services document for mInlineSpellChecker.
|
// Reference to text services document for mInlineSpellChecker.
|
||||||
RefPtr<TextServicesDocument> mTextServicesDocument;
|
RefPtr<TextServicesDocument> mTextServicesDocument;
|
||||||
|
|
||||||
RefPtr<nsTransactionManager> mTxnMgr;
|
RefPtr<TransactionManager> mTransactionManager;
|
||||||
// Cached root node.
|
// Cached root node.
|
||||||
nsCOMPtr<Element> mRootElement;
|
nsCOMPtr<Element> mRootElement;
|
||||||
// The form field as an event receiver.
|
// The form field as an event receiver.
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "mozilla/TransactionManager.h"
|
||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
#include "mozilla/mozalloc.h"
|
#include "mozilla/mozalloc.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
@ -14,10 +16,11 @@
|
|||||||
#include "nsITransactionListener.h"
|
#include "nsITransactionListener.h"
|
||||||
#include "nsIWeakReference.h"
|
#include "nsIWeakReference.h"
|
||||||
#include "nsTransactionItem.h"
|
#include "nsTransactionItem.h"
|
||||||
#include "nsTransactionManager.h"
|
|
||||||
#include "nsTransactionStack.h"
|
#include "nsTransactionStack.h"
|
||||||
|
|
||||||
nsTransactionManager::nsTransactionManager(int32_t aMaxTransactionCount)
|
namespace mozilla {
|
||||||
|
|
||||||
|
TransactionManager::TransactionManager(int32_t aMaxTransactionCount)
|
||||||
: mMaxTransactionCount(aMaxTransactionCount)
|
: mMaxTransactionCount(aMaxTransactionCount)
|
||||||
, mDoStack(nsTransactionStack::FOR_UNDO)
|
, mDoStack(nsTransactionStack::FOR_UNDO)
|
||||||
, mUndoStack(nsTransactionStack::FOR_UNDO)
|
, mUndoStack(nsTransactionStack::FOR_UNDO)
|
||||||
@ -25,37 +28,33 @@ nsTransactionManager::nsTransactionManager(int32_t aMaxTransactionCount)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
nsTransactionManager::~nsTransactionManager()
|
NS_IMPL_CYCLE_COLLECTION_CLASS(TransactionManager)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsTransactionManager)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(TransactionManager)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTransactionManager)
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mListeners)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mListeners)
|
||||||
tmp->mDoStack.DoUnlink();
|
tmp->mDoStack.DoUnlink();
|
||||||
tmp->mUndoStack.DoUnlink();
|
tmp->mUndoStack.DoUnlink();
|
||||||
tmp->mRedoStack.DoUnlink();
|
tmp->mRedoStack.DoUnlink();
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsTransactionManager)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TransactionManager)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListeners)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListeners)
|
||||||
tmp->mDoStack.DoTraverse(cb);
|
tmp->mDoStack.DoTraverse(cb);
|
||||||
tmp->mUndoStack.DoTraverse(cb);
|
tmp->mUndoStack.DoTraverse(cb);
|
||||||
tmp->mRedoStack.DoTraverse(cb);
|
tmp->mRedoStack.DoTraverse(cb);
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTransactionManager)
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TransactionManager)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsITransactionManager)
|
NS_INTERFACE_MAP_ENTRY(nsITransactionManager)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITransactionManager)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITransactionManager)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTransactionManager)
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(TransactionManager)
|
||||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTransactionManager)
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(TransactionManager)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::DoTransaction(nsITransaction *aTransaction)
|
TransactionManager::DoTransaction(nsITransaction* aTransaction)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aTransaction, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(aTransaction, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ nsTransactionManager::DoTransaction(nsITransaction *aTransaction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::UndoTransaction()
|
TransactionManager::UndoTransaction()
|
||||||
{
|
{
|
||||||
// It is illegal to call UndoTransaction() while the transaction manager is
|
// It is illegal to call UndoTransaction() while the transaction manager is
|
||||||
// executing a transaction's DoTransaction() method! If this happens,
|
// executing a transaction's DoTransaction() method! If this happens,
|
||||||
@ -132,7 +131,7 @@ nsTransactionManager::UndoTransaction()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::RedoTransaction()
|
TransactionManager::RedoTransaction()
|
||||||
{
|
{
|
||||||
// It is illegal to call RedoTransaction() while the transaction manager is
|
// It is illegal to call RedoTransaction() while the transaction manager is
|
||||||
// executing a transaction's DoTransaction() method! If this happens,
|
// executing a transaction's DoTransaction() method! If this happens,
|
||||||
@ -176,7 +175,7 @@ nsTransactionManager::RedoTransaction()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::Clear()
|
TransactionManager::Clear()
|
||||||
{
|
{
|
||||||
nsresult rv = ClearRedoStack();
|
nsresult rv = ClearRedoStack();
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@ -186,7 +185,7 @@ nsTransactionManager::Clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::BeginBatch(nsISupports* aData)
|
TransactionManager::BeginBatch(nsISupports* aData)
|
||||||
{
|
{
|
||||||
// We can batch independent transactions together by simply pushing
|
// We can batch independent transactions together by simply pushing
|
||||||
// a dummy transaction item on the do stack. This dummy transaction item
|
// a dummy transaction item on the do stack. This dummy transaction item
|
||||||
@ -214,7 +213,7 @@ nsTransactionManager::BeginBatch(nsISupports* aData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::EndBatch(bool aAllowEmpty)
|
TransactionManager::EndBatch(bool aAllowEmpty)
|
||||||
{
|
{
|
||||||
// XXX: Need to add some mechanism to detect the case where the transaction
|
// XXX: Need to add some mechanism to detect the case where the transaction
|
||||||
// at the top of the do stack isn't the dummy transaction, so we can
|
// at the top of the do stack isn't the dummy transaction, so we can
|
||||||
@ -256,21 +255,21 @@ nsTransactionManager::EndBatch(bool aAllowEmpty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::GetNumberOfUndoItems(int32_t *aNumItems)
|
TransactionManager::GetNumberOfUndoItems(int32_t* aNumItems)
|
||||||
{
|
{
|
||||||
*aNumItems = mUndoStack.GetSize();
|
*aNumItems = mUndoStack.GetSize();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::GetNumberOfRedoItems(int32_t *aNumItems)
|
TransactionManager::GetNumberOfRedoItems(int32_t* aNumItems)
|
||||||
{
|
{
|
||||||
*aNumItems = mRedoStack.GetSize();
|
*aNumItems = mRedoStack.GetSize();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::GetMaxTransactionCount(int32_t *aMaxCount)
|
TransactionManager::GetMaxTransactionCount(int32_t* aMaxCount)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aMaxCount, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(aMaxCount, NS_ERROR_NULL_POINTER);
|
||||||
*aMaxCount = mMaxTransactionCount;
|
*aMaxCount = mMaxTransactionCount;
|
||||||
@ -278,7 +277,7 @@ nsTransactionManager::GetMaxTransactionCount(int32_t *aMaxCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::SetMaxTransactionCount(int32_t aMaxCount)
|
TransactionManager::SetMaxTransactionCount(int32_t aMaxCount)
|
||||||
{
|
{
|
||||||
// It is illegal to call SetMaxTransactionCount() while the transaction
|
// It is illegal to call SetMaxTransactionCount() while the transaction
|
||||||
// manager is executing a transaction's DoTransaction() method because
|
// manager is executing a transaction's DoTransaction() method because
|
||||||
@ -332,7 +331,7 @@ nsTransactionManager::SetMaxTransactionCount(int32_t aMaxCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::PeekUndoStack(nsITransaction **aTransaction)
|
TransactionManager::PeekUndoStack(nsITransaction** aTransaction)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aTransaction);
|
MOZ_ASSERT(aTransaction);
|
||||||
*aTransaction = PeekUndoStack().take();
|
*aTransaction = PeekUndoStack().take();
|
||||||
@ -340,7 +339,7 @@ nsTransactionManager::PeekUndoStack(nsITransaction **aTransaction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsITransaction>
|
already_AddRefed<nsITransaction>
|
||||||
nsTransactionManager::PeekUndoStack()
|
TransactionManager::PeekUndoStack()
|
||||||
{
|
{
|
||||||
RefPtr<nsTransactionItem> tx = mUndoStack.Peek();
|
RefPtr<nsTransactionItem> tx = mUndoStack.Peek();
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
@ -350,7 +349,7 @@ nsTransactionManager::PeekUndoStack()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::PeekRedoStack(nsITransaction** aTransaction)
|
TransactionManager::PeekRedoStack(nsITransaction** aTransaction)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aTransaction);
|
MOZ_ASSERT(aTransaction);
|
||||||
*aTransaction = PeekRedoStack().take();
|
*aTransaction = PeekRedoStack().take();
|
||||||
@ -358,7 +357,7 @@ nsTransactionManager::PeekRedoStack(nsITransaction** aTransaction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsITransaction>
|
already_AddRefed<nsITransaction>
|
||||||
nsTransactionManager::PeekRedoStack()
|
TransactionManager::PeekRedoStack()
|
||||||
{
|
{
|
||||||
RefPtr<nsTransactionItem> tx = mRedoStack.Peek();
|
RefPtr<nsTransactionItem> tx = mRedoStack.Peek();
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
@ -368,7 +367,7 @@ nsTransactionManager::PeekRedoStack()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::BatchTopUndo()
|
TransactionManager::BatchTopUndo()
|
||||||
{
|
{
|
||||||
if (mUndoStack.GetSize() < 2) {
|
if (mUndoStack.GetSize() < 2) {
|
||||||
// Not enough transactions to merge into one batch.
|
// Not enough transactions to merge into one batch.
|
||||||
@ -396,7 +395,7 @@ nsTransactionManager::BatchTopUndo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::RemoveTopUndo()
|
TransactionManager::RemoveTopUndo()
|
||||||
{
|
{
|
||||||
if (mUndoStack.IsEmpty()) {
|
if (mUndoStack.IsEmpty()) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -407,35 +406,36 @@ nsTransactionManager::RemoveTopUndo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::AddListener(nsITransactionListener *aListener)
|
TransactionManager::AddListener(nsITransactionListener* aListener)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
|
||||||
return mListeners.AppendObject(aListener) ? NS_OK : NS_ERROR_FAILURE;
|
return mListeners.AppendObject(aListener) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::RemoveListener(nsITransactionListener *aListener)
|
TransactionManager::RemoveListener(nsITransactionListener* aListener)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
|
||||||
return mListeners.RemoveObject(aListener) ? NS_OK : NS_ERROR_FAILURE;
|
return mListeners.RemoveObject(aListener) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::ClearUndoStack()
|
TransactionManager::ClearUndoStack()
|
||||||
{
|
{
|
||||||
mUndoStack.Clear();
|
mUndoStack.Clear();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransactionManager::ClearRedoStack()
|
TransactionManager::ClearRedoStack()
|
||||||
{
|
{
|
||||||
mRedoStack.Clear();
|
mRedoStack.Clear();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::WillDoNotify(nsITransaction *aTransaction, bool *aInterrupt)
|
TransactionManager::WillDoNotify(nsITransaction* aTransaction,
|
||||||
|
bool* aInterrupt)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -450,7 +450,8 @@ nsTransactionManager::WillDoNotify(nsITransaction *aTransaction, bool *aInterrup
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::DidDoNotify(nsITransaction *aTransaction, nsresult aDoResult)
|
TransactionManager::DidDoNotify(nsITransaction* aTransaction,
|
||||||
|
nsresult aDoResult)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -465,7 +466,8 @@ nsTransactionManager::DidDoNotify(nsITransaction *aTransaction, nsresult aDoResu
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::WillUndoNotify(nsITransaction *aTransaction, bool *aInterrupt)
|
TransactionManager::WillUndoNotify(nsITransaction* aTransaction,
|
||||||
|
bool* aInterrupt)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -480,7 +482,8 @@ nsTransactionManager::WillUndoNotify(nsITransaction *aTransaction, bool *aInterr
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult)
|
TransactionManager::DidUndoNotify(nsITransaction* aTransaction,
|
||||||
|
nsresult aUndoResult)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -495,7 +498,8 @@ nsTransactionManager::DidUndoNotify(nsITransaction *aTransaction, nsresult aUndo
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::WillRedoNotify(nsITransaction *aTransaction, bool *aInterrupt)
|
TransactionManager::WillRedoNotify(nsITransaction* aTransaction,
|
||||||
|
bool* aInterrupt)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -510,7 +514,8 @@ nsTransactionManager::WillRedoNotify(nsITransaction *aTransaction, bool *aInterr
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::DidRedoNotify(nsITransaction *aTransaction, nsresult aRedoResult)
|
TransactionManager::DidRedoNotify(nsITransaction* aTransaction,
|
||||||
|
nsresult aRedoResult)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -525,7 +530,7 @@ nsTransactionManager::DidRedoNotify(nsITransaction *aTransaction, nsresult aRedo
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::WillBeginBatchNotify(bool *aInterrupt)
|
TransactionManager::WillBeginBatchNotify(bool* aInterrupt)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -540,7 +545,7 @@ nsTransactionManager::WillBeginBatchNotify(bool *aInterrupt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::DidBeginBatchNotify(nsresult aResult)
|
TransactionManager::DidBeginBatchNotify(nsresult aResult)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -555,7 +560,7 @@ nsTransactionManager::DidBeginBatchNotify(nsresult aResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::WillEndBatchNotify(bool *aInterrupt)
|
TransactionManager::WillEndBatchNotify(bool* aInterrupt)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -570,7 +575,7 @@ nsTransactionManager::WillEndBatchNotify(bool *aInterrupt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::DidEndBatchNotify(nsresult aResult)
|
TransactionManager::DidEndBatchNotify(nsresult aResult)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -585,7 +590,9 @@ nsTransactionManager::DidEndBatchNotify(nsresult aResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::WillMergeNotify(nsITransaction *aTop, nsITransaction *aTransaction, bool *aInterrupt)
|
TransactionManager::WillMergeNotify(nsITransaction* aTop,
|
||||||
|
nsITransaction* aTransaction,
|
||||||
|
bool* aInterrupt)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -600,10 +607,10 @@ nsTransactionManager::WillMergeNotify(nsITransaction *aTop, nsITransaction *aTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::DidMergeNotify(nsITransaction *aTop,
|
TransactionManager::DidMergeNotify(nsITransaction* aTop,
|
||||||
nsITransaction *aTransaction,
|
nsITransaction* aTransaction,
|
||||||
bool aDidMerge,
|
bool aDidMerge,
|
||||||
nsresult aMergeResult)
|
nsresult aMergeResult)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
for (int32_t i = 0, lcount = mListeners.Count(); i < lcount; i++) {
|
||||||
nsITransactionListener* listener = mListeners[i];
|
nsITransactionListener* listener = mListeners[i];
|
||||||
@ -619,8 +626,8 @@ nsTransactionManager::DidMergeNotify(nsITransaction *aTop,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::BeginTransaction(nsITransaction *aTransaction,
|
TransactionManager::BeginTransaction(nsITransaction* aTransaction,
|
||||||
nsISupports *aData)
|
nsISupports* aData)
|
||||||
{
|
{
|
||||||
// XXX: POSSIBLE OPTIMIZATION
|
// XXX: POSSIBLE OPTIMIZATION
|
||||||
// We could use a factory that pre-allocates/recycles transaction items.
|
// We could use a factory that pre-allocates/recycles transaction items.
|
||||||
@ -645,7 +652,7 @@ nsTransactionManager::BeginTransaction(nsITransaction *aTransaction,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::EndTransaction(bool aAllowEmpty)
|
TransactionManager::EndTransaction(bool aAllowEmpty)
|
||||||
{
|
{
|
||||||
RefPtr<nsTransactionItem> tx = mDoStack.Pop();
|
RefPtr<nsTransactionItem> tx = mDoStack.Pop();
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
@ -728,3 +735,5 @@ nsTransactionManager::EndTransaction(bool aAllowEmpty)
|
|||||||
mUndoStack.Push(tx.forget());
|
mUndoStack.Push(tx.forget());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace mozilla
|
73
editor/txmgr/TransactionManager.h
Normal file
73
editor/txmgr/TransactionManager.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* -*- 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 mozilla_TransactionManager_h
|
||||||
|
#define mozilla_TransactionManager_h
|
||||||
|
|
||||||
|
#include "nsCOMArray.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsCycleCollectionParticipant.h"
|
||||||
|
#include "nsTransactionStack.h"
|
||||||
|
#include "nsISupportsImpl.h"
|
||||||
|
#include "nsITransactionManager.h"
|
||||||
|
#include "nsTransactionStack.h"
|
||||||
|
#include "nsWeakReference.h"
|
||||||
|
#include "nscore.h"
|
||||||
|
|
||||||
|
class nsITransaction;
|
||||||
|
class nsITransactionListener;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
class TransactionManager final : public nsITransactionManager
|
||||||
|
, public nsSupportsWeakReference
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit TransactionManager(int32_t aMaxTransactionCount = -1);
|
||||||
|
|
||||||
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||||
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(TransactionManager,
|
||||||
|
nsITransactionManager)
|
||||||
|
|
||||||
|
NS_DECL_NSITRANSACTIONMANAGER
|
||||||
|
|
||||||
|
already_AddRefed<nsITransaction> PeekUndoStack();
|
||||||
|
already_AddRefed<nsITransaction> PeekRedoStack();
|
||||||
|
|
||||||
|
nsresult WillDoNotify(nsITransaction* aTransaction, bool* aInterrupt);
|
||||||
|
nsresult DidDoNotify(nsITransaction* aTransaction, nsresult aExecuteResult);
|
||||||
|
nsresult WillUndoNotify(nsITransaction* aTransaction, bool* aInterrupt);
|
||||||
|
nsresult DidUndoNotify(nsITransaction* aTransaction, nsresult aUndoResult);
|
||||||
|
nsresult WillRedoNotify(nsITransaction* aTransaction, bool *aInterrupt);
|
||||||
|
nsresult DidRedoNotify(nsITransaction* aTransaction, nsresult aRedoResult);
|
||||||
|
nsresult WillBeginBatchNotify(bool* aInterrupt);
|
||||||
|
nsresult DidBeginBatchNotify(nsresult aResult);
|
||||||
|
nsresult WillEndBatchNotify(bool* aInterrupt);
|
||||||
|
nsresult DidEndBatchNotify(nsresult aResult);
|
||||||
|
nsresult WillMergeNotify(nsITransaction* aTop,
|
||||||
|
nsITransaction* aTransaction,
|
||||||
|
bool* aInterrupt);
|
||||||
|
nsresult DidMergeNotify(nsITransaction* aTop,
|
||||||
|
nsITransaction* aTransaction,
|
||||||
|
bool aDidMerge,
|
||||||
|
nsresult aMergeResult);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual ~TransactionManager() = default;
|
||||||
|
|
||||||
|
nsresult BeginTransaction(nsITransaction* aTransaction,
|
||||||
|
nsISupports* aData);
|
||||||
|
nsresult EndTransaction(bool aAllowEmpty);
|
||||||
|
|
||||||
|
int32_t mMaxTransactionCount;
|
||||||
|
nsTransactionStack mDoStack;
|
||||||
|
nsTransactionStack mUndoStack;
|
||||||
|
nsTransactionStack mRedoStack;
|
||||||
|
nsCOMArray<nsITransactionListener> mListeners;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // #ifndef mozilla_TransactionManager_h
|
@ -7,32 +7,35 @@
|
|||||||
|
|
||||||
#include "mozilla/Module.h"
|
#include "mozilla/Module.h"
|
||||||
#include "mozilla/ModuleUtils.h"
|
#include "mozilla/ModuleUtils.h"
|
||||||
|
#include "mozilla/TransactionManager.h"
|
||||||
#include "nsID.h"
|
#include "nsID.h"
|
||||||
#include "nsITransactionManager.h"
|
#include "nsITransactionManager.h"
|
||||||
#include "nsTransactionManager.h"
|
|
||||||
#include "nsTransactionManagerCID.h"
|
using mozilla::TransactionManager;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Define the contructor function for the objects
|
// Define the contructor function for the objects
|
||||||
//
|
//
|
||||||
// NOTE: This creates an instance of objects by using the default constructor
|
// NOTE: This creates an instance of objects by using the default constructor
|
||||||
//
|
//
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransactionManager)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(TransactionManager)
|
||||||
NS_DEFINE_NAMED_CID(NS_TRANSACTIONMANAGER_CID);
|
NS_DEFINE_NAMED_CID(NS_TRANSACTIONMANAGER_CID);
|
||||||
|
|
||||||
static const mozilla::Module::CIDEntry kTxMgrCIDs[] = {
|
static const mozilla::Module::CIDEntry kTxMgrCIDs[] = {
|
||||||
{ &kNS_TRANSACTIONMANAGER_CID, false, nullptr, nsTransactionManagerConstructor },
|
{ &kNS_TRANSACTIONMANAGER_CID, false, nullptr,
|
||||||
{ nullptr }
|
TransactionManagerConstructor },
|
||||||
|
{ nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const mozilla::Module::ContractIDEntry kTxMgrContracts[] = {
|
static const mozilla::Module::ContractIDEntry kTxMgrContracts[] = {
|
||||||
{ NS_TRANSACTIONMANAGER_CONTRACTID, &kNS_TRANSACTIONMANAGER_CID },
|
{ NS_TRANSACTIONMANAGER_CONTRACTID, &kNS_TRANSACTIONMANAGER_CID },
|
||||||
{ nullptr }
|
{ nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const mozilla::Module kTxMgrModule = {
|
static const mozilla::Module kTxMgrModule = {
|
||||||
mozilla::Module::kVersion,
|
mozilla::Module::kVersion,
|
||||||
kTxMgrCIDs,
|
kTxMgrCIDs,
|
||||||
kTxMgrContracts
|
kTxMgrContracts
|
||||||
};
|
};
|
||||||
|
|
||||||
NSMODULE_DEFN(nsTransactionManagerModule) = &kTxMgrModule;
|
NSMODULE_DEFN(nsTransactionManagerModule) = &kTxMgrModule;
|
@ -18,11 +18,15 @@ EXPORTS += [
|
|||||||
'nsTransactionManagerCID.h',
|
'nsTransactionManagerCID.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
EXPORTS.mozilla += [
|
||||||
|
'TransactionManager.h',
|
||||||
|
]
|
||||||
|
|
||||||
UNIFIED_SOURCES += [
|
UNIFIED_SOURCES += [
|
||||||
'nsTransactionItem.cpp',
|
'nsTransactionItem.cpp',
|
||||||
'nsTransactionManager.cpp',
|
|
||||||
'nsTransactionManagerFactory.cpp',
|
|
||||||
'nsTransactionStack.cpp',
|
'nsTransactionStack.cpp',
|
||||||
|
'TransactionManager.cpp',
|
||||||
|
'TransactionManagerFactory.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
FINAL_LIBRARY = 'xul'
|
FINAL_LIBRARY = 'xul'
|
||||||
|
@ -7,12 +7,6 @@
|
|||||||
#include "nsITransaction.idl"
|
#include "nsITransaction.idl"
|
||||||
#include "nsITransactionListener.idl"
|
#include "nsITransactionListener.idl"
|
||||||
|
|
||||||
%{ C++
|
|
||||||
|
|
||||||
#define NS_TRANSACTIONMANAGER_CONTRACTID "@mozilla.org/transactionmanager;1"
|
|
||||||
|
|
||||||
%} C++
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The nsITransactionManager interface.
|
* The nsITransactionManager interface.
|
||||||
* <P>
|
* <P>
|
||||||
@ -151,3 +145,13 @@ interface nsITransactionManager : nsISupports
|
|||||||
void RemoveListener(in nsITransactionListener aListener);
|
void RemoveListener(in nsITransactionListener aListener);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
%{ C++
|
||||||
|
|
||||||
|
#define NS_TRANSACTIONMANAGER_CONTRACTID "@mozilla.org/transactionmanager;1"
|
||||||
|
|
||||||
|
// 9C8F9601-801A-11d2-98BA-00805F297D89
|
||||||
|
#define NS_TRANSACTIONMANAGER_CID \
|
||||||
|
{ 0x9c8f9601, 0x801a, 0x11d2, \
|
||||||
|
{ 0x98, 0xba, 0x0, 0x80, 0x5f, 0x29, 0x7d, 0x89 } }
|
||||||
|
|
||||||
|
%} C++
|
||||||
|
@ -3,16 +3,19 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "nsTransactionItem.h"
|
||||||
|
|
||||||
#include "mozilla/mozalloc.h"
|
#include "mozilla/mozalloc.h"
|
||||||
|
#include "mozilla/TransactionManager.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsDebug.h"
|
#include "nsDebug.h"
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
#include "nsISupportsImpl.h"
|
#include "nsISupportsImpl.h"
|
||||||
#include "nsITransaction.h"
|
#include "nsITransaction.h"
|
||||||
#include "nsTransactionItem.h"
|
|
||||||
#include "nsTransactionManager.h"
|
|
||||||
#include "nsTransactionStack.h"
|
#include "nsTransactionStack.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
nsTransactionItem::nsTransactionItem(nsITransaction *aTransaction)
|
nsTransactionItem::nsTransactionItem(nsITransaction *aTransaction)
|
||||||
: mTransaction(aTransaction), mUndoStack(0), mRedoStack(0)
|
: mTransaction(aTransaction), mUndoStack(0), mRedoStack(0)
|
||||||
{
|
{
|
||||||
@ -159,11 +162,11 @@ nsTransactionItem::DoTransaction()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr)
|
nsTransactionItem::UndoTransaction(TransactionManager* aTransactionManager)
|
||||||
{
|
{
|
||||||
nsresult rv = UndoChildren(aTxMgr);
|
nsresult rv = UndoChildren(aTransactionManager);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
RecoverFromUndoError(aTxMgr);
|
RecoverFromUndoError(aTransactionManager);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +176,7 @@ nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr)
|
|||||||
|
|
||||||
rv = mTransaction->UndoTransaction();
|
rv = mTransaction->UndoTransaction();
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
RecoverFromUndoError(aTxMgr);
|
RecoverFromUndoError(aTransactionManager);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +184,7 @@ nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
nsTransactionItem::UndoChildren(TransactionManager* aTransactionManager)
|
||||||
{
|
{
|
||||||
if (mUndoStack) {
|
if (mUndoStack) {
|
||||||
if (!mRedoStack && mUndoStack) {
|
if (!mRedoStack && mUndoStack) {
|
||||||
@ -200,7 +203,7 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
|||||||
|
|
||||||
nsCOMPtr<nsITransaction> t = item->GetTransaction();
|
nsCOMPtr<nsITransaction> t = item->GetTransaction();
|
||||||
bool doInterrupt = false;
|
bool doInterrupt = false;
|
||||||
rv = aTxMgr->WillUndoNotify(t, &doInterrupt);
|
rv = aTransactionManager->WillUndoNotify(t, &doInterrupt);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -208,13 +211,13 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = item->UndoTransaction(aTxMgr);
|
rv = item->UndoTransaction(aTransactionManager);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
item = mUndoStack->Pop();
|
item = mUndoStack->Pop();
|
||||||
mRedoStack->Push(item.forget());
|
mRedoStack->Push(item.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv2 = aTxMgr->DidUndoNotify(t, rv);
|
nsresult rv2 = aTransactionManager->DidUndoNotify(t, rv);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = rv2;
|
rv = rv2;
|
||||||
}
|
}
|
||||||
@ -229,7 +232,7 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
|
nsTransactionItem::RedoTransaction(TransactionManager* aTransactionManager)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsITransaction> transaction(mTransaction);
|
nsCOMPtr<nsITransaction> transaction(mTransaction);
|
||||||
if (transaction) {
|
if (transaction) {
|
||||||
@ -237,9 +240,9 @@ nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = RedoChildren(aTxMgr);
|
nsresult rv = RedoChildren(aTransactionManager);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
RecoverFromRedoError(aTxMgr);
|
RecoverFromRedoError(aTransactionManager);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +250,7 @@ nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr)
|
nsTransactionItem::RedoChildren(TransactionManager* aTransactionManager)
|
||||||
{
|
{
|
||||||
if (!mRedoStack) {
|
if (!mRedoStack) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -265,7 +268,7 @@ nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr)
|
|||||||
|
|
||||||
nsCOMPtr<nsITransaction> t = item->GetTransaction();
|
nsCOMPtr<nsITransaction> t = item->GetTransaction();
|
||||||
bool doInterrupt = false;
|
bool doInterrupt = false;
|
||||||
rv = aTxMgr->WillRedoNotify(t, &doInterrupt);
|
rv = aTransactionManager->WillRedoNotify(t, &doInterrupt);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -273,14 +276,14 @@ nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = item->RedoTransaction(aTxMgr);
|
rv = item->RedoTransaction(aTransactionManager);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
item = mRedoStack->Pop();
|
item = mRedoStack->Pop();
|
||||||
mUndoStack->Push(item.forget());
|
mUndoStack->Push(item.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Shouldn't this DidRedoNotify()? (bug 1311626)
|
// XXX Shouldn't this DidRedoNotify()? (bug 1311626)
|
||||||
nsresult rv2 = aTxMgr->DidUndoNotify(t, rv);
|
nsresult rv2 = aTransactionManager->DidUndoNotify(t, rv);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = rv2;
|
rv = rv2;
|
||||||
}
|
}
|
||||||
@ -320,22 +323,22 @@ nsTransactionItem::GetNumberOfRedoItems(int32_t *aNumItems)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionItem::RecoverFromUndoError(nsTransactionManager *aTxMgr)
|
nsTransactionItem::RecoverFromUndoError(TransactionManager* aTransactionManager)
|
||||||
{
|
{
|
||||||
// If this method gets called, we never got to the point where we
|
// If this method gets called, we never got to the point where we
|
||||||
// successfully called UndoTransaction() for the transaction item itself.
|
// successfully called UndoTransaction() for the transaction item itself.
|
||||||
// Just redo any children that successfully called undo!
|
// Just redo any children that successfully called undo!
|
||||||
return RedoChildren(aTxMgr);
|
return RedoChildren(aTransactionManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr)
|
nsTransactionItem::RecoverFromRedoError(TransactionManager* aTransactionManager)
|
||||||
{
|
{
|
||||||
// If this method gets called, we already successfully called
|
// If this method gets called, we already successfully called
|
||||||
// RedoTransaction() for the transaction item itself. Undo all
|
// RedoTransaction() for the transaction item itself. Undo all
|
||||||
// the children that successfully called RedoTransaction(),
|
// the children that successfully called RedoTransaction(),
|
||||||
// then undo the transaction item itself.
|
// then undo the transaction item itself.
|
||||||
nsresult rv = UndoChildren(aTxMgr);
|
nsresult rv = UndoChildren(aTransactionManager);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,12 @@
|
|||||||
#include "nscore.h"
|
#include "nscore.h"
|
||||||
|
|
||||||
class nsITransaction;
|
class nsITransaction;
|
||||||
class nsTransactionManager;
|
|
||||||
class nsTransactionStack;
|
class nsTransactionStack;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
class TransactionManager;
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
class nsTransactionItem final
|
class nsTransactionItem final
|
||||||
{
|
{
|
||||||
nsCOMArray<nsISupports> mData;
|
nsCOMArray<nsISupports> mData;
|
||||||
@ -24,22 +27,21 @@ class nsTransactionItem final
|
|||||||
nsTransactionStack *mRedoStack;
|
nsTransactionStack *mRedoStack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit nsTransactionItem(nsITransaction* aTransaction);
|
||||||
explicit nsTransactionItem(nsITransaction *aTransaction);
|
|
||||||
NS_METHOD_(MozExternalRefCountType) AddRef();
|
NS_METHOD_(MozExternalRefCountType) AddRef();
|
||||||
NS_METHOD_(MozExternalRefCountType) Release();
|
NS_METHOD_(MozExternalRefCountType) Release();
|
||||||
|
|
||||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsTransactionItem)
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsTransactionItem)
|
||||||
|
|
||||||
virtual nsresult AddChild(nsTransactionItem *aTransactionItem);
|
nsresult AddChild(nsTransactionItem* aTransactionItem);
|
||||||
already_AddRefed<nsITransaction> GetTransaction();
|
already_AddRefed<nsITransaction> GetTransaction();
|
||||||
virtual nsresult GetIsBatch(bool *aIsBatch);
|
nsresult GetIsBatch(bool *aIsBatch);
|
||||||
virtual nsresult GetNumberOfChildren(int32_t *aNumChildren);
|
nsresult GetNumberOfChildren(int32_t *aNumChildren);
|
||||||
virtual nsresult GetChild(int32_t aIndex, nsTransactionItem **aChild);
|
nsresult GetChild(int32_t aIndex, nsTransactionItem** aChild);
|
||||||
|
|
||||||
virtual nsresult DoTransaction(void);
|
nsresult DoTransaction();
|
||||||
virtual nsresult UndoTransaction(nsTransactionManager *aTxMgr);
|
nsresult UndoTransaction(mozilla::TransactionManager* aTransactionManager);
|
||||||
virtual nsresult RedoTransaction(nsTransactionManager *aTxMgr);
|
nsresult RedoTransaction(mozilla::TransactionManager* aTransactionManager);
|
||||||
|
|
||||||
nsCOMArray<nsISupports>& GetData()
|
nsCOMArray<nsISupports>& GetData()
|
||||||
{
|
{
|
||||||
@ -47,19 +49,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
nsresult UndoChildren(mozilla::TransactionManager* aTransactionManager);
|
||||||
|
nsresult RedoChildren(mozilla::TransactionManager* aTransactionManager);
|
||||||
|
|
||||||
virtual nsresult UndoChildren(nsTransactionManager *aTxMgr);
|
nsresult
|
||||||
virtual nsresult RedoChildren(nsTransactionManager *aTxMgr);
|
RecoverFromUndoError(mozilla::TransactionManager* aTransactionManager);
|
||||||
|
nsresult
|
||||||
|
RecoverFromRedoError(mozilla::TransactionManager* aTransactionManager);
|
||||||
|
|
||||||
virtual nsresult RecoverFromUndoError(nsTransactionManager *aTxMgr);
|
nsresult GetNumberOfUndoItems(int32_t* aNumItems);
|
||||||
virtual nsresult RecoverFromRedoError(nsTransactionManager *aTxMgr);
|
nsresult GetNumberOfRedoItems(int32_t* aNumItems);
|
||||||
|
|
||||||
virtual nsresult GetNumberOfUndoItems(int32_t *aNumItems);
|
|
||||||
virtual nsresult GetNumberOfRedoItems(int32_t *aNumItems);
|
|
||||||
|
|
||||||
void CleanUp();
|
void CleanUp();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsTransactionItem();
|
~nsTransactionItem();
|
||||||
|
|
||||||
nsCycleCollectingAutoRefCnt mRefCnt;
|
nsCycleCollectingAutoRefCnt mRefCnt;
|
||||||
NS_DECL_OWNINGTHREAD
|
NS_DECL_OWNINGTHREAD
|
||||||
|
@ -1,83 +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 nsTransactionManager_h__
|
|
||||||
#define nsTransactionManager_h__
|
|
||||||
|
|
||||||
#include "nsCOMArray.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsCycleCollectionParticipant.h"
|
|
||||||
#include "nsTransactionStack.h"
|
|
||||||
#include "nsISupportsImpl.h"
|
|
||||||
#include "nsITransactionManager.h"
|
|
||||||
#include "nsTransactionStack.h"
|
|
||||||
#include "nsWeakReference.h"
|
|
||||||
#include "nscore.h"
|
|
||||||
|
|
||||||
class nsITransaction;
|
|
||||||
class nsITransactionListener;
|
|
||||||
|
|
||||||
/** implementation of a transaction manager object.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class nsTransactionManager final : public nsITransactionManager
|
|
||||||
, public nsSupportsWeakReference
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
int32_t mMaxTransactionCount;
|
|
||||||
nsTransactionStack mDoStack;
|
|
||||||
nsTransactionStack mUndoStack;
|
|
||||||
nsTransactionStack mRedoStack;
|
|
||||||
nsCOMArray<nsITransactionListener> mListeners;
|
|
||||||
|
|
||||||
/** The default destructor.
|
|
||||||
*/
|
|
||||||
virtual ~nsTransactionManager();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/** The default constructor.
|
|
||||||
*/
|
|
||||||
explicit nsTransactionManager(int32_t aMaxTransactionCount=-1);
|
|
||||||
|
|
||||||
/* Macro for AddRef(), Release(), and QueryInterface() */
|
|
||||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
||||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTransactionManager,
|
|
||||||
nsITransactionManager)
|
|
||||||
|
|
||||||
/* nsITransactionManager method implementations. */
|
|
||||||
NS_DECL_NSITRANSACTIONMANAGER
|
|
||||||
|
|
||||||
already_AddRefed<nsITransaction> PeekUndoStack();
|
|
||||||
already_AddRefed<nsITransaction> PeekRedoStack();
|
|
||||||
|
|
||||||
virtual nsresult WillDoNotify(nsITransaction *aTransaction, bool *aInterrupt);
|
|
||||||
virtual nsresult DidDoNotify(nsITransaction *aTransaction, nsresult aExecuteResult);
|
|
||||||
virtual nsresult WillUndoNotify(nsITransaction *aTransaction, bool *aInterrupt);
|
|
||||||
virtual nsresult DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult);
|
|
||||||
virtual nsresult WillRedoNotify(nsITransaction *aTransaction, bool *aInterrupt);
|
|
||||||
virtual nsresult DidRedoNotify(nsITransaction *aTransaction, nsresult aRedoResult);
|
|
||||||
virtual nsresult WillBeginBatchNotify(bool *aInterrupt);
|
|
||||||
virtual nsresult DidBeginBatchNotify(nsresult aResult);
|
|
||||||
virtual nsresult WillEndBatchNotify(bool *aInterrupt);
|
|
||||||
virtual nsresult DidEndBatchNotify(nsresult aResult);
|
|
||||||
virtual nsresult WillMergeNotify(nsITransaction *aTop,
|
|
||||||
nsITransaction *aTransaction,
|
|
||||||
bool *aInterrupt);
|
|
||||||
virtual nsresult DidMergeNotify(nsITransaction *aTop,
|
|
||||||
nsITransaction *aTransaction,
|
|
||||||
bool aDidMerge,
|
|
||||||
nsresult aMergeResult);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/* nsTransactionManager specific private methods. */
|
|
||||||
virtual nsresult BeginTransaction(nsITransaction *aTransaction,
|
|
||||||
nsISupports *aData);
|
|
||||||
virtual nsresult EndTransaction(bool aAllowEmpty);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // nsTransactionManager_h__
|
|
@ -3,12 +3,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef nsTransactionManagerCID_h__
|
// XXX Needs to modify mailnews/base/src/nsMsgWindow.cpp before removing this
|
||||||
#define nsTransactionManagerCID_h__
|
// header file.
|
||||||
|
#include "nsITransactionManager.h"
|
||||||
|
|
||||||
#define NS_TRANSACTIONMANAGER_CID \
|
|
||||||
{ /* 9C8F9601-801A-11d2-98BA-00805F297D89 */ \
|
|
||||||
0x9c8f9601, 0x801a, 0x11d2, \
|
|
||||||
{ 0x98, 0xba, 0x0, 0x80, 0x5f, 0x29, 0x7d, 0x89 } }
|
|
||||||
|
|
||||||
#endif /* nsTransactionManagerCID_h__ */
|
|
||||||
|
Loading…
Reference in New Issue
Block a user