Bug 765595 part 2 - De-COMtaminate nsEditor::mTxnMgr; r=ehsan

This commit is contained in:
Aryeh Gregor 2012-06-19 16:23:36 +03:00
Родитель 2f08b098d4
Коммит 538ef8bff3
10 изменённых файлов: 20 добавлений и 25 удалений

Просмотреть файл

@ -121,6 +121,7 @@ INCLUDES += \
-I$(srcdir)/../../../../dom/base \ -I$(srcdir)/../../../../dom/base \
-I$(srcdir)/../../../../editor/libeditor/base \ -I$(srcdir)/../../../../editor/libeditor/base \
-I$(srcdir)/../../../../editor/libeditor/text \ -I$(srcdir)/../../../../editor/libeditor/text \
-I$(srcdir)/../../../../editor/txmgr/src \
-I$(srcdir) \ -I$(srcdir) \
-I$(topsrcdir)/xpcom/ds \ -I$(topsrcdir)/xpcom/ds \
$(NULL) $(NULL)

Просмотреть файл

@ -58,6 +58,7 @@ include $(topsrcdir)/config/rules.mk
INCLUDES += \ INCLUDES += \
-I$(topsrcdir)/editor/libeditor/text \ -I$(topsrcdir)/editor/libeditor/text \
-I$(topsrcdir)/editor/txmgr/src \
-I$(topsrcdir)/content/base/src \ -I$(topsrcdir)/content/base/src \
-I$(topsrcdir)/content/events/src \ -I$(topsrcdir)/content/events/src \
-I$(topsrcdir)/layout/style \ -I$(topsrcdir)/layout/style \

Просмотреть файл

@ -165,7 +165,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEditor)
} }
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRootElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRootElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mInlineSpellChecker) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mInlineSpellChecker)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTxnMgr) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mTxnMgr, nsITransactionManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mIMETextRangeList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mIMETextRangeList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mIMETextNode) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mIMETextNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mActionListeners) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mActionListeners)
@ -709,26 +709,14 @@ nsEditor::DoTransaction(nsITransaction* aTxn)
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::EnableUndo(bool aEnable) nsEditor::EnableUndo(bool aEnable)
{ {
nsresult result=NS_OK; if (aEnable) {
if (!mTxnMgr) {
if (true==aEnable) mTxnMgr = new nsTransactionManager();
{
if (!mTxnMgr)
{
mTxnMgr = do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &result);
if (NS_FAILED(result) || !mTxnMgr) {
return NS_ERROR_NOT_AVAILABLE;
}
}
mTxnMgr->SetMaxTransactionCount(-1);
}
else
{ // disable the transaction manager if it is enabled
if (mTxnMgr)
{
mTxnMgr->Clear();
mTxnMgr->SetMaxTransactionCount(0);
} }
} else if (mTxnMgr) {
// disable the transaction manager if it is enabled
mTxnMgr->Clear();
mTxnMgr->SetMaxTransactionCount(0);
} }
return NS_OK; return NS_OK;
@ -765,7 +753,8 @@ nsEditor::SetTransactionManager(nsITransactionManager *aTxnManager)
{ {
NS_ENSURE_TRUE(aTxnManager, NS_ERROR_FAILURE); NS_ENSURE_TRUE(aTxnManager, NS_ERROR_FAILURE);
mTxnMgr = aTxnManager; // nsITransactionManager is builtinclass, so this is safe
mTxnMgr = static_cast<nsTransactionManager*>(aTxnManager);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -19,7 +19,7 @@
#include "mozilla/Selection.h" #include "mozilla/Selection.h"
#include "nsIDOMCharacterData.h" #include "nsIDOMCharacterData.h"
#include "nsIPrivateTextRange.h" #include "nsIPrivateTextRange.h"
#include "nsITransactionManager.h" #include "nsTransactionManager.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsCOMArray.h" #include "nsCOMArray.h"
#include "nsIEditActionListener.h" #include "nsIEditActionListener.h"
@ -821,7 +821,7 @@ protected:
nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker; nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker;
nsCOMPtr<nsITransactionManager> mTxnMgr; nsRefPtr<nsTransactionManager> mTxnMgr;
nsCOMPtr<mozilla::dom::Element> mRootElement; // cached root node nsCOMPtr<mozilla::dom::Element> mRootElement; // cached root node
nsCOMPtr<nsIPrivateTextRangeList> mIMETextRangeList; // IME special selection ranges nsCOMPtr<nsIPrivateTextRangeList> mIMETextRangeList; // IME special selection ranges
nsCOMPtr<nsIDOMCharacterData> mIMETextNode; // current IME text node nsCOMPtr<nsIDOMCharacterData> mIMETextNode; // current IME text node

Просмотреть файл

@ -55,5 +55,6 @@ include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(topsrcdir)/editor/libeditor/base \ INCLUDES += -I$(topsrcdir)/editor/libeditor/base \
-I$(topsrcdir)/editor/libeditor/text \ -I$(topsrcdir)/editor/libeditor/text \
-I$(topsrcdir)/editor/txmgr/src \
-I$(topsrcdir)/content/base/src \ -I$(topsrcdir)/content/base/src \
$(NULL) $(NULL)

Просмотреть файл

@ -34,5 +34,6 @@ include $(topsrcdir)/config/rules.mk
INCLUDES += \ INCLUDES += \
-I$(topsrcdir)/editor/libeditor/base \ -I$(topsrcdir)/editor/libeditor/base \
-I$(topsrcdir)/editor/txmgr/src \
-I$(topsrcdir)/content/base/src \ -I$(topsrcdir)/content/base/src \
$(NULL) $(NULL)

Просмотреть файл

@ -20,7 +20,7 @@
* This interface is implemented by an object that wants to * This interface is implemented by an object that wants to
* manage/track transactions. * manage/track transactions.
*/ */
[scriptable, uuid(58e330c2-7b48-11d2-98b9-00805f297d89)] [scriptable, builtinclass, uuid(58e330c2-7b48-11d2-98b9-00805f297d89)]
interface nsITransactionManager : nsISupports interface nsITransactionManager : nsISupports
{ {
/** /**

Просмотреть файл

@ -11,11 +11,11 @@
#include "nsCOMArray.h" #include "nsCOMArray.h"
#include "nsITransactionListener.h" #include "nsITransactionListener.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsTransactionStack.h"
class nsITransaction; class nsITransaction;
class nsITransactionListener; class nsITransactionListener;
class nsTransactionItem; class nsTransactionItem;
class nsTransactionStack;
/** implementation of a transaction manager object. /** implementation of a transaction manager object.
* *

Просмотреть файл

@ -251,6 +251,7 @@ LOCAL_INCLUDES += -I$(srcdir)/../base \
-I$(topsrcdir)/editor/libeditor/base \ -I$(topsrcdir)/editor/libeditor/base \
-I$(topsrcdir)/editor/libeditor/text \ -I$(topsrcdir)/editor/libeditor/text \
-I$(topsrcdir)/editor/libeditor/html \ -I$(topsrcdir)/editor/libeditor/html \
-I$(topsrcdir)/editor/txmgr/src \
-I$(topsrcdir)/editor/txtsvc/src \ -I$(topsrcdir)/editor/txtsvc/src \
-I$(topsrcdir)/editor/composer/src \ -I$(topsrcdir)/editor/composer/src \
-I$(topsrcdir)/js/xpconnect/src \ -I$(topsrcdir)/js/xpconnect/src \

Просмотреть файл

@ -61,6 +61,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../content/html/content/src \ -I$(srcdir)/../../content/html/content/src \
-I$(srcdir)/../../editor/libeditor/base \ -I$(srcdir)/../../editor/libeditor/base \
-I$(srcdir)/../../editor/libeditor/text \ -I$(srcdir)/../../editor/libeditor/text \
-I$(srcdir)/../../editor/txmgr/src \
$(NULL) $(NULL)
DEFINES += -D_IMPL_NS_LAYOUT DEFINES += -D_IMPL_NS_LAYOUT