From 5c7a93503f25f62d3129d39f2870bedab01c6077 Mon Sep 17 00:00:00 2001 From: "buster%netscape.com" Date: Thu, 15 Jul 1999 19:13:46 +0000 Subject: [PATCH] replaced IID's with CID's where they were appropriate, and removed lots of NS_DEFINE_IID macros in favor of GetCID() wherever I could. plus some minor bug fixes. --- editor/base/ChangeAttributeTxn.h | 4 +- editor/base/CreateElementTxn.h | 4 +- editor/base/DeleteElementTxn.h | 4 +- editor/base/DeleteRangeTxn.cpp | 11 +-- editor/base/DeleteRangeTxn.h | 4 +- editor/base/DeleteTextTxn.h | 4 +- editor/base/EditAggregateTxn.h | 4 +- editor/base/EditTable.cpp | 11 --- editor/base/EditTxn.h | 4 +- editor/base/IMECommitTxn.cpp | 4 +- editor/base/IMECommitTxn.h | 6 +- editor/base/IMETextTxn.cpp | 3 +- editor/base/IMETextTxn.h | 7 +- editor/base/InsertElementTxn.h | 4 +- editor/base/InsertTextTxn.cpp | 6 +- editor/base/InsertTextTxn.h | 8 +- editor/base/JoinElementTxn.h | 4 +- editor/base/PlaceholderTxn.h | 4 +- editor/base/SplitElementTxn.h | 4 +- editor/base/TransactionFactory.cpp | 58 ++++-------- editor/base/nsEditor.cpp | 96 +++++++++----------- editor/base/nsHTMLEditRules.cpp | 6 +- editor/base/nsHTMLEditor.cpp | 1 - editor/base/nsInsertHTMLTxn.h | 80 ---------------- editor/base/nsStyleSheetTxns.h | 9 +- editor/base/nsTextEditRules.cpp | 19 ++-- editor/libeditor/base/ChangeAttributeTxn.h | 4 +- editor/libeditor/base/CreateElementTxn.h | 4 +- editor/libeditor/base/DeleteElementTxn.h | 4 +- editor/libeditor/base/DeleteRangeTxn.cpp | 11 +-- editor/libeditor/base/DeleteRangeTxn.h | 4 +- editor/libeditor/base/DeleteTextTxn.h | 4 +- editor/libeditor/base/EditAggregateTxn.h | 4 +- editor/libeditor/base/EditTxn.h | 4 +- editor/libeditor/base/IMETextTxn.cpp | 3 +- editor/libeditor/base/IMETextTxn.h | 7 +- editor/libeditor/base/InsertElementTxn.h | 4 +- editor/libeditor/base/InsertTextTxn.cpp | 6 +- editor/libeditor/base/InsertTextTxn.h | 8 +- editor/libeditor/base/JoinElementTxn.h | 4 +- editor/libeditor/base/PlaceholderTxn.h | 4 +- editor/libeditor/base/SplitElementTxn.h | 4 +- editor/libeditor/base/TransactionFactory.cpp | 58 ++++-------- editor/libeditor/base/nsEditor.cpp | 96 +++++++++----------- editor/libeditor/base/nsStyleSheetTxns.h | 9 +- editor/libeditor/html/nsHTMLEditRules.cpp | 6 +- editor/libeditor/html/nsHTMLEditor.cpp | 1 - editor/libeditor/text/nsTextEditRules.cpp | 19 ++-- 48 files changed, 252 insertions(+), 385 deletions(-) diff --git a/editor/base/ChangeAttributeTxn.h b/editor/base/ChangeAttributeTxn.h index 3d3fb502c71..4e0880695a3 100644 --- a/editor/base/ChangeAttributeTxn.h +++ b/editor/base/ChangeAttributeTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMElement.h" #include "nsIEditor.h" -#define CHANGE_ATTRIBUTE_TXN_IID \ +#define CHANGE_ATTRIBUTE_TXN_CID \ {/* 97818860-ac48-11d2-86d8-000064657374 */ \ 0x97818860, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -37,6 +37,8 @@ class ChangeAttributeTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = CHANGE_ATTRIBUTE_TXN_CID; return iid; } + virtual ~ChangeAttributeTxn(); /** Initialize the transaction. diff --git a/editor/base/CreateElementTxn.h b/editor/base/CreateElementTxn.h index 8cebdf24fb7..743a7a8b91f 100644 --- a/editor/base/CreateElementTxn.h +++ b/editor/base/CreateElementTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define CREATE_ELEMENT_TXN_IID \ +#define CREATE_ELEMENT_TXN_CID \ {/* 7a6393c0-ac48-11d2-86d8-000064657374 */ \ 0x7a6393c0, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class CreateElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = CREATE_ELEMENT_TXN_CID; return iid; } + enum { eAppend=-1 }; /** Initialize the transaction. diff --git a/editor/base/DeleteElementTxn.h b/editor/base/DeleteElementTxn.h index 08ac5fff0dc..b7ef8665801 100644 --- a/editor/base/DeleteElementTxn.h +++ b/editor/base/DeleteElementTxn.h @@ -23,7 +23,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define DELETE_ELEMENT_TXN_IID \ +#define DELETE_ELEMENT_TXN_CID \ {/* 6fd77770-ac49-11d2-86d8-000064657374 */ \ 0x6fd77770, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -34,6 +34,8 @@ class DeleteElementTxn : public EditTxn { public: + + static const nsIID& GetCID() { static nsIID iid = DELETE_ELEMENT_TXN_CID; return iid; } /** initialize the transaction. * @param aElement the node to delete diff --git a/editor/base/DeleteRangeTxn.cpp b/editor/base/DeleteRangeTxn.cpp index 5af55dacf64..dd5ac9c09b6 100644 --- a/editor/base/DeleteRangeTxn.cpp +++ b/editor/base/DeleteRangeTxn.cpp @@ -32,9 +32,6 @@ #include "nsIDOMElement.h" #endif -static NS_DEFINE_IID(kDeleteTextTxnIID, DELETE_TEXT_TXN_IID); -static NS_DEFINE_IID(kDeleteElementTxnIID, DELETE_ELEMENT_TXN_IID); - #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; #else @@ -238,7 +235,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent if (textNode) { // if the node is a text node, then delete text content DeleteTextTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteTextTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { PRInt32 numToDel; @@ -267,7 +264,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent if ((NS_SUCCEEDED(result)) && child) { DeleteElementTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteElementTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { txn->Init(child); @@ -308,7 +305,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent, if (numToDelete) { DeleteTextTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteTextTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { txn->Init(mEditor, textNode, start, numToDelete); @@ -350,7 +347,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteNodesBetween() if ((NS_SUCCEEDED(result)) && node) { DeleteElementTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteElementTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { txn->Init(node); diff --git a/editor/base/DeleteRangeTxn.h b/editor/base/DeleteRangeTxn.h index ae46d4c05a1..9df23001fe7 100644 --- a/editor/base/DeleteRangeTxn.h +++ b/editor/base/DeleteRangeTxn.h @@ -27,7 +27,7 @@ class nsIDOMDocument; -#define DELETE_RANGE_TXN_IID \ +#define DELETE_RANGE_TXN_CID \ {/* 5ec6b260-ac49-11d2-86d8-000064657374 */ \ 0x5ec6b260, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -39,6 +39,8 @@ class DeleteRangeTxn : public EditAggregateTxn { public: + static const nsIID& GetCID() { static nsIID iid = DELETE_RANGE_TXN_CID; return iid; } + /** initialize the transaction. * @param aEditor the object providing basic editing operations * @param aRange the range to delete diff --git a/editor/base/DeleteTextTxn.h b/editor/base/DeleteTextTxn.h index 8b0d3d07f58..14ce511218c 100644 --- a/editor/base/DeleteTextTxn.h +++ b/editor/base/DeleteTextTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMCharacterData.h" #include "nsCOMPtr.h" -#define DELETE_TEXT_TXN_IID \ +#define DELETE_TEXT_TXN_CID \ {/* 4d3a2720-ac49-11d2-86d8-000064657374 */ \ 0x4d3a2720, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class DeleteTextTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = DELETE_TEXT_TXN_CID; return iid; } + /** initialize the transaction. * @param aEditor the provider of basic editing operations * @param aElement the content node to remove text from diff --git a/editor/base/EditAggregateTxn.h b/editor/base/EditAggregateTxn.h index 8a0916a9569..b7512a4edbb 100644 --- a/editor/base/EditAggregateTxn.h +++ b/editor/base/EditAggregateTxn.h @@ -23,7 +23,7 @@ #include "nsIAtom.h" #include "nsCOMPtr.h" -#define EDIT_AGGREGATE_TXN_IID \ +#define EDIT_AGGREGATE_TXN_CID \ {/* 345921a0-ac49-11d2-86d8-000064657374 */ \ 0x345921a0, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -40,7 +40,7 @@ public: NS_DECL_ISUPPORTS_INHERITED - static const nsIID& GetCID() { static nsIID cid = EDIT_AGGREGATE_TXN_IID; return cid; } + static const nsIID& GetCID() { static nsIID cid = EDIT_AGGREGATE_TXN_CID; return cid; } EditAggregateTxn(); diff --git a/editor/base/EditTable.cpp b/editor/base/EditTable.cpp index 55994b206e3..ffff91bb5d3 100644 --- a/editor/base/EditTable.cpp +++ b/editor/base/EditTable.cpp @@ -62,17 +62,6 @@ #include "nsHTMLEditor.h" static NS_DEFINE_IID(kITransactionManagerIID, NS_ITRANSACTIONMANAGER_IID); -static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID); - -static NS_DEFINE_IID(kInsertTableTxnIID, INSERT_TABLE_TXN_IID); -static NS_DEFINE_IID(kInsertTableCellTxnIID, INSERT_CELL_TXN_IID); -static NS_DEFINE_IID(kInsertTableColumnTxnIID, INSERT_COLUMN_TXN_IID); -static NS_DEFINE_IID(kInsertTableRowTxnIID, INSERT_ROW_TXN_IID); -static NS_DEFINE_IID(kDeleteTableTxnIID, DELETE_TABLE_TXN_IID); -static NS_DEFINE_IID(kDeleteTableCellTxnIID, DELETE_CELL_TXN_IID); -static NS_DEFINE_IID(kDeleteTableColumnTxnIID, DELETE_COLUMN_TXN_IID); -static NS_DEFINE_IID(kDeleteTableRowTxnIID, DELETE_ROW_TXN_IID); -static NS_DEFINE_IID(kJoinTableCellsTxnIID, JOIN_CELLS_TXN_IID); // Table Editing methods -- for testing, hooked up to Tool Menu items // Modeled after nsEditor::InsertText() diff --git a/editor/base/EditTxn.h b/editor/base/EditTxn.h index 7b298664c65..8a3bfe4446e 100644 --- a/editor/base/EditTxn.h +++ b/editor/base/EditTxn.h @@ -22,7 +22,7 @@ #include "nsITransaction.h" #include "nsCOMPtr.h" -#define EDIT_TXN_IID \ +#define EDIT_TXN_CID \ {/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \ 0xc5ea31b0, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -37,6 +37,8 @@ class EditTxn : public nsITransaction { public: + static const nsIID& GetCID() { static nsIID iid = EDIT_TXN_CID; return iid; } + NS_DECL_ISUPPORTS EditTxn(); diff --git a/editor/base/IMECommitTxn.cpp b/editor/base/IMECommitTxn.cpp index 98e69934528..b5ceaa47ac4 100644 --- a/editor/base/IMECommitTxn.cpp +++ b/editor/base/IMECommitTxn.cpp @@ -19,8 +19,6 @@ #include "IMECommitTxn.h" #include "nsEditor.h" -static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID); - nsIAtom *IMECommitTxn::gIMECommitTxnName = nsnull; nsresult IMECommitTxn::ClassInit() @@ -103,7 +101,7 @@ IMECommitTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) if (nsnull == aInstancePtr) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kIMECommitTxnIID)) { + if (aIID.Equals(IMECommitTxn::GetCID())) { *aInstancePtr = (void*)(IMECommitTxn*)this; NS_ADDREF_THIS(); return NS_OK; diff --git a/editor/base/IMECommitTxn.h b/editor/base/IMECommitTxn.h index ec82d8fcb01..8a7a86d2f18 100644 --- a/editor/base/IMECommitTxn.h +++ b/editor/base/IMECommitTxn.h @@ -24,7 +24,7 @@ #include "nsCOMPtr.h" // {9C4994A1-281C-11d3-9EA3-0060089FE59B} -#define IME_COMMIT_TXN_IID \ +#define IME_COMMIT_TXN_CID \ { 0x9c4994a1, 0x281c, 0x11d3, \ { 0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }} @@ -35,6 +35,8 @@ class IMECommitTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = IME_COMMIT_TXN_CID; return iid; } + virtual ~IMECommitTxn(); static nsIAtom *gIMECommitTxnName; @@ -66,8 +68,6 @@ public: // override QueryInterface to handle IMECommitTxn request NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - static const nsIID& GetIID() { static nsIID iid = IME_COMMIT_TXN_IID; return iid; } - /** must be called before any IMECommitTxn is instantiated */ static nsresult ClassInit(); diff --git a/editor/base/IMETextTxn.cpp b/editor/base/IMETextTxn.cpp index adfb733b7c0..905c141a15c 100644 --- a/editor/base/IMETextTxn.cpp +++ b/editor/base/IMETextTxn.cpp @@ -26,7 +26,6 @@ #include "nsIPresShell.h" #include "EditAggregateTxn.h" -static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID); static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); nsIAtom *IMETextTxn::gIMETextTxnName = nsnull; @@ -204,7 +203,7 @@ IMETextTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) if (nsnull == aInstancePtr) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kIMETextTxnIID)) { + if (aIID.Equals(IMETextTxn::GetCID())) { *aInstancePtr = (void*)(IMETextTxn*)this; NS_ADDREF_THIS(); return NS_OK; diff --git a/editor/base/IMETextTxn.h b/editor/base/IMETextTxn.h index b75865a12a9..fea487a3318 100644 --- a/editor/base/IMETextTxn.h +++ b/editor/base/IMETextTxn.h @@ -25,7 +25,7 @@ #include "nsCOMPtr.h" // {D4D25721-2813-11d3-9EA3-0060089FE59B} -#define IME_TEXT_TXN_IID \ +#define IME_TEXT_TXN_CID \ {0xd4d25721, 0x2813, 0x11d3, \ {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }} @@ -40,6 +40,8 @@ class nsIPresShell; class IMETextTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = IME_TEXT_TXN_CID; return iid; } + virtual ~IMETextTxn(); /** used to name aggregate transactions that consist only of a single IMETextTxn, @@ -84,9 +86,6 @@ public: // override QueryInterface to handle IMETextTxn request NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - static const nsIID& GetIID() { static nsIID iid = IME_TEXT_TXN_IID; return iid; } - - /** return the string data associated with this transaction */ NS_IMETHOD GetData(nsString& aResult, nsIDOMTextRangeList** aTextRangeList); diff --git a/editor/base/InsertElementTxn.h b/editor/base/InsertElementTxn.h index 3af31a5af60..6d1da7db628 100644 --- a/editor/base/InsertElementTxn.h +++ b/editor/base/InsertElementTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define INSERT_ELEMENT_TXN_IID \ +#define INSERT_ELEMENT_TXN_CID \ {/* b5762440-cbb0-11d2-86db-000064657374 */ \ 0xb5762440, 0xcbb0, 0x11d2, \ {0x86, 0xdb, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class InsertElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = INSERT_ELEMENT_TXN_CID; return iid; } + /** initialize the transaction. * @param aNode the node to insert * @param aParent the node to insert into diff --git a/editor/base/InsertTextTxn.cpp b/editor/base/InsertTextTxn.cpp index 27470efdf92..0f8b06997f6 100644 --- a/editor/base/InsertTextTxn.cpp +++ b/editor/base/InsertTextTxn.cpp @@ -23,9 +23,7 @@ #include "nsIPresShell.h" #include "EditAggregateTxn.h" -static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID); static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); -static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID); #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -117,7 +115,7 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti // if aTransaction isa InsertTextTxn, and if the selection hasn't changed, // then absorb it InsertTextTxn *otherInsTxn = nsnull; - aTransaction->QueryInterface(kInsertTextTxnIID, (void **)&otherInsTxn); + aTransaction->QueryInterface(InsertTextTxn::GetCID(), (void **)&otherInsTxn); if (otherInsTxn) { if (PR_TRUE==IsSequentialInsert(otherInsTxn)) @@ -201,7 +199,7 @@ InsertTextTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) if (nsnull == aInstancePtr) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kInsertTextTxnIID)) { + if (aIID.Equals(InsertTextTxn::GetCID())) { *aInstancePtr = (void*)(InsertTextTxn*)this; NS_ADDREF_THIS(); return NS_OK; diff --git a/editor/base/InsertTextTxn.h b/editor/base/InsertTextTxn.h index f6c74ccbbfa..e34272405f7 100644 --- a/editor/base/InsertTextTxn.h +++ b/editor/base/InsertTextTxn.h @@ -23,7 +23,7 @@ #include "nsIDOMCharacterData.h" #include "nsCOMPtr.h" -#define INSERT_TEXT_TXN_IID \ +#define INSERT_TEXT_TXN_CID \ {/* 93276f00-ab2c-11d2-8f4b-006008159b0c*/ \ 0x93276f00, 0xab2c, 0x11d2, \ {0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} } @@ -36,6 +36,9 @@ class nsIPresShell; class InsertTextTxn : public EditTxn { public: + + static const nsIID& GetCID() { static nsIID iid = INSERT_TEXT_TXN_CID; return iid; } + virtual ~InsertTextTxn(); /** used to name aggregate transactions that consist only of a single InsertTextTxn, @@ -77,9 +80,6 @@ public: // override QueryInterface to handle InsertTextTxn request NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - static const nsIID& GetIID() { static nsIID iid = INSERT_TEXT_TXN_IID; return iid; } - - /** return the string data associated with this transaction */ NS_IMETHOD GetData(nsString& aResult); diff --git a/editor/base/JoinElementTxn.h b/editor/base/JoinElementTxn.h index 644dfbc7ab5..7b951252b74 100644 --- a/editor/base/JoinElementTxn.h +++ b/editor/base/JoinElementTxn.h @@ -24,7 +24,7 @@ #include "nsCOMPtr.h" #include "nsIEditor.h" -#define JOIN_ELEMENT_TXN_IID \ +#define JOIN_ELEMENT_TXN_CID \ {/* 9bc5f9f0-ac48-11d2-86d8-000064657374 */ \ 0x9bc5f9f0, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -40,6 +40,8 @@ class JoinElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = JOIN_ELEMENT_TXN_CID; return iid; } + /** initialize the transaction * @param aEditor the provider of core editing operations * @param aLeftNode the first of two nodes to join diff --git a/editor/base/PlaceholderTxn.h b/editor/base/PlaceholderTxn.h index 6f6f39953a3..74441711026 100644 --- a/editor/base/PlaceholderTxn.h +++ b/editor/base/PlaceholderTxn.h @@ -21,7 +21,7 @@ #include "EditAggregateTxn.h" -#define PLACEHOLDER_TXN_IID \ +#define PLACEHOLDER_TXN_CID \ {/* {0CE9FB00-D9D1-11d2-86DE-000064657374} */ \ 0x0CE9FB00, 0xD9D1, 0x11d2, \ {0x86, 0xde, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class PlaceholderTxn : public EditAggregateTxn { public: + static const nsIID& GetCID() { static nsIID iid = PLACEHOLDER_TXN_CID; return iid; } + private: PlaceholderTxn(); diff --git a/editor/base/SplitElementTxn.h b/editor/base/SplitElementTxn.h index ed8b902a297..cb12f7d81af 100644 --- a/editor/base/SplitElementTxn.h +++ b/editor/base/SplitElementTxn.h @@ -24,7 +24,7 @@ #include "nsCOMPtr.h" #include "nsIEditor.h" -#define SPLIT_ELEMENT_TXN_IID \ +#define SPLIT_ELEMENT_TXN_CID \ {/* 690c6290-ac48-11d2-86d8-000064657374 */ \ 0x690c6290, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -37,6 +37,8 @@ class SplitElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = SPLIT_ELEMENT_TXN_CID; return iid; } + /** initialize the transaction. * @param aEditor the provider of core editing operations * @param aNode the node to split diff --git a/editor/base/TransactionFactory.cpp b/editor/base/TransactionFactory.cpp index 39c1a43f760..a4c87de7541 100644 --- a/editor/base/TransactionFactory.cpp +++ b/editor/base/TransactionFactory.cpp @@ -43,32 +43,6 @@ #include "IMETextTxn.h" #include "IMECommitTxn.h" -static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID); -static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID); -static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID); -static NS_DEFINE_IID(kDeleteTextTxnIID, DELETE_TEXT_TXN_IID); -static NS_DEFINE_IID(kCreateElementTxnIID, CREATE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertElementTxnIID, INSERT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertHTMLTxnIID, NS_INSERT_HTML_TXN_IID); -static NS_DEFINE_IID(kDeleteElementTxnIID, DELETE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kDeleteRangeTxnIID, DELETE_RANGE_TXN_IID); -static NS_DEFINE_IID(kChangeAttributeTxnIID,CHANGE_ATTRIBUTE_TXN_IID); -static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertTableTxnIID, INSERT_TABLE_TXN_IID); -static NS_DEFINE_IID(kInsertTableCellTxnIID, INSERT_CELL_TXN_IID); -static NS_DEFINE_IID(kInsertTableColumnTxnIID, INSERT_COLUMN_TXN_IID); -static NS_DEFINE_IID(kInsertTableRowTxnIID, INSERT_ROW_TXN_IID); -static NS_DEFINE_IID(kDeleteTableTxnIID, DELETE_TABLE_TXN_IID); -static NS_DEFINE_IID(kDeleteTableCellTxnIID, DELETE_CELL_TXN_IID); -static NS_DEFINE_IID(kDeleteTableColumnTxnIID, DELETE_COLUMN_TXN_IID); -static NS_DEFINE_IID(kDeleteTableRowTxnIID, DELETE_ROW_TXN_IID); -static NS_DEFINE_IID(kJoinTableCellsTxnIID, JOIN_CELLS_TXN_IID); -static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID); -static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID); -static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID); -static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID); - TransactionFactory::TransactionFactory() { } @@ -82,37 +56,37 @@ TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult) { nsresult result = NS_OK; *aResult = nsnull; - if (aTxnType.Equals(kInsertTextTxnIID)) + if (aTxnType.Equals(InsertTextTxn::GetCID())) *aResult = new InsertTextTxn(); - else if (aTxnType.Equals(kDeleteTextTxnIID)) + else if (aTxnType.Equals(DeleteTextTxn::GetCID())) *aResult = new DeleteTextTxn(); - else if (aTxnType.Equals(kCreateElementTxnIID)) + else if (aTxnType.Equals(CreateElementTxn::GetCID())) *aResult = new CreateElementTxn(); - else if (aTxnType.Equals(kInsertElementTxnIID)) + else if (aTxnType.Equals(InsertElementTxn::GetCID())) *aResult = new InsertElementTxn(); - else if (aTxnType.Equals(kInsertHTMLTxnIID)) + else if (aTxnType.Equals(nsInsertHTMLTxn::GetCID())) *aResult = new nsInsertHTMLTxn(); - else if (aTxnType.Equals(kDeleteElementTxnIID)) + else if (aTxnType.Equals(DeleteElementTxn::GetCID())) *aResult = new DeleteElementTxn(); - else if (aTxnType.Equals(kDeleteRangeTxnIID)) + else if (aTxnType.Equals(DeleteRangeTxn::GetCID())) *aResult = new DeleteRangeTxn(); - else if (aTxnType.Equals(kChangeAttributeTxnIID)) + else if (aTxnType.Equals(ChangeAttributeTxn::GetCID())) *aResult = new ChangeAttributeTxn(); - else if (aTxnType.Equals(kSplitElementTxnIID)) + else if (aTxnType.Equals(SplitElementTxn::GetCID())) *aResult = new SplitElementTxn(); - else if (aTxnType.Equals(kJoinElementTxnIID)) + else if (aTxnType.Equals(JoinElementTxn::GetCID())) *aResult = new JoinElementTxn(); - else if (aTxnType.Equals(kEditAggregateTxnIID)) + else if (aTxnType.Equals(EditAggregateTxn::GetCID())) *aResult = new EditAggregateTxn(); - else if (aTxnType.Equals(kIMETextTxnIID)) + else if (aTxnType.Equals(IMETextTxn::GetCID())) *aResult = new IMETextTxn(); - else if (aTxnType.Equals(kIMECommitTxnIID)) + else if (aTxnType.Equals(IMECommitTxn::GetCID())) *aResult = new IMECommitTxn(); - else if (aTxnType.Equals(kAddStyleSheetTxnIID)) + else if (aTxnType.Equals(AddStyleSheetTxn::GetCID())) *aResult = new AddStyleSheetTxn(); - else if (aTxnType.Equals(kRemoveStyleSheetTxnIID)) + else if (aTxnType.Equals(RemoveStyleSheetTxn::GetCID())) *aResult = new RemoveStyleSheetTxn(); - else if (aTxnType.Equals(kPlaceholderTxnIID)) + else if (aTxnType.Equals(PlaceholderTxn::GetCID())) *aResult = new PlaceholderTxn(); else result = NS_ERROR_NO_INTERFACE; diff --git a/editor/base/nsEditor.cpp b/editor/base/nsEditor.cpp index e52fa655276..99fba21089c 100644 --- a/editor/base/nsEditor.cpp +++ b/editor/base/nsEditor.cpp @@ -125,22 +125,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); // transaction manager static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID); -// transactions -static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID); -static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID); -static NS_DEFINE_IID(kDeleteTextTxnIID, DELETE_TEXT_TXN_IID); -static NS_DEFINE_IID(kCreateElementTxnIID, CREATE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertElementTxnIID, INSERT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kDeleteElementTxnIID, DELETE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kDeleteRangeTxnIID, DELETE_RANGE_TXN_IID); -static NS_DEFINE_IID(kChangeAttributeTxnIID,CHANGE_ATTRIBUTE_TXN_IID); -static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID); -static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID); -static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID); -static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID); - static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); @@ -701,7 +685,7 @@ nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kChangeAttributeTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aElement, aAttribute, aValue, PR_FALSE); } @@ -749,7 +733,7 @@ nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kChangeAttributeTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { nsAutoString value; @@ -1634,7 +1618,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsString& aTag, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aParent) { - result = TransactionFactory::GetNewTransaction(kCreateElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(CreateElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aTag, aParent, aPosition); } @@ -1686,7 +1670,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertElement(nsIDOMNode * aNode, nsresult result = NS_ERROR_NULL_POINTER; if (aNode && aParent && aTxn) { - result = TransactionFactory::GetNewTransaction(kInsertElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(InsertElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(aNode, aParent, aPosition, this); } @@ -1734,7 +1718,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kDeleteElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(aElement); } @@ -1748,7 +1732,7 @@ NS_IMETHODIMP nsEditor::CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, if (aAggTxn) { *aAggTxn = nsnull; - result = TransactionFactory::GetNewTransaction(kEditAggregateTxnIID, (EditTxn**)aAggTxn); + result = TransactionFactory::GetNewTransaction(EditAggregateTxn::GetCID(), (EditTxn**)aAggTxn); if (NS_FAILED(result) || !*aAggTxn) { return NS_ERROR_OUT_OF_MEMORY; @@ -1810,33 +1794,37 @@ nsEditor::InsertText(const nsString& aStringToInsert) else if (NS_ERROR_EDITOR_NO_TEXTNODE==result) { BeginTransaction(); - nsCOMPtr selection; - result = GetSelection(getter_AddRefs(selection)); - if ((NS_SUCCEEDED(result)) && selection) + result = Do(aggTxn); + if (NS_SUCCEEDED(result)) { - nsCOMPtr selectedNode; - PRInt32 offset; - result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) + nsCOMPtr selection; + result = GetSelection(getter_AddRefs(selection)); + if ((NS_SUCCEEDED(result)) && selection) { - nsCOMPtr newNode; - result = CreateNode(GetTextNodeTag(), selectedNode, offset, // offset+1, why the +1??? - getter_AddRefs(newNode)); - if (NS_SUCCEEDED(result) && newNode) + nsCOMPtr selectedNode; + PRInt32 offset; + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) { - nsCOMPtrnewTextNode; - newTextNode = do_QueryInterface(newNode); - if (newTextNode) + nsCOMPtr newNode; + result = CreateNode(GetTextNodeTag(), selectedNode, offset, + getter_AddRefs(newNode)); + if (NS_SUCCEEDED(result) && newNode) { - nsAutoString placeholderText(" "); - newTextNode->SetData(placeholderText); - selection->Collapse(newNode, 0, SELECTION_NORMAL); - selection->Extend(newNode, 1, SELECTION_NORMAL); - result = InsertText(aStringToInsert); + nsCOMPtrnewTextNode; + newTextNode = do_QueryInterface(newNode); + if (newTextNode) + { + nsAutoString placeholderText(" "); + newTextNode->SetData(placeholderText); + selection->Collapse(newNode, 0, SELECTION_NORMAL); + selection->Extend(newNode, 1, SELECTION_NORMAL); + result = InsertText(aStringToInsert); + } } } - } - } + } + } EndTransaction(); } return result; @@ -1913,7 +1901,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert, } if (NS_SUCCEEDED(result) && nodeAsText) { - result = TransactionFactory::GetNewTransaction(kInsertTextTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(InsertTextTxn::GetCID(), (EditTxn **)aTxn); if (nsnull!=*aTxn) { result = (*aTxn)->Init(nodeAsText, offset, aStringToInsert, mPresShell); } @@ -2013,7 +2001,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteText(nsIDOMCharacterData *aElement, nsresult result=NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kDeleteTextTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aElement, aOffset, aLength); } @@ -2246,7 +2234,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti return NS_OK; // allocate the out-param transaction - result = TransactionFactory::GetNewTransaction(kEditAggregateTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(EditAggregateTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(result)) { return result; } @@ -2266,7 +2254,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti if (PR_FALSE==isCollapsed) { DeleteRangeTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteRangeTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteRangeTxn::GetCID(), (EditTxn **)&txn); if ((NS_SUCCEEDED(result)) && (nsnull!=txn)) { txn->Init(this, range); @@ -2499,7 +2487,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForSplitNode(nsIDOMNode *aNode, nsresult result=NS_ERROR_NULL_POINTER; if (nsnull != aNode) { - result = TransactionFactory::GetNewTransaction(kSplitElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(SplitElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aNode, aOffset); } @@ -2551,7 +2539,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForJoinNode(nsIDOMNode *aLeftNode, nsresult result=NS_ERROR_NULL_POINTER; if ((nsnull != aLeftNode) && (nsnull != aRightNode)) { - result = TransactionFactory::GetNewTransaction(kJoinElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(JoinElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aLeftNode, aRightNode); } @@ -3561,7 +3549,7 @@ nsEditor::EndComposition(void) // // create the commit transaction..we can do it directly from the transaction mgr // - result = TransactionFactory::GetNewTransaction(kIMECommitTxnIID,(EditTxn**)&commitTxn); + result = TransactionFactory::GetNewTransaction(IMECommitTxn::GetCID(), (EditTxn**)&commitTxn); if (NS_SUCCEEDED(result) && commitTxn!=nsnull) { commitTxn->Init(); @@ -3816,7 +3804,7 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, { nsresult result; - result = TransactionFactory::GetNewTransaction(kIMETextTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(IMETextTxn::GetCID(), (EditTxn **)aTxn); if (nsnull!=*aTxn) { result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,aTextRangeList,aStringToInsert,mPresShell); } @@ -3830,7 +3818,7 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, NS_IMETHODIMP nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn) { - nsresult rv = TransactionFactory::GetNewTransaction(kAddStyleSheetTxnIID, (EditTxn **)aTxn); + nsresult rv = TransactionFactory::GetNewTransaction(AddStyleSheetTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(rv)) return rv; @@ -3845,7 +3833,7 @@ nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* NS_IMETHODIMP nsEditor::CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn) { - nsresult rv = TransactionFactory::GetNewTransaction(kRemoveStyleSheetTxnIID, (EditTxn **)aTxn); + nsresult rv = TransactionFactory::GetNewTransaction(RemoveStyleSheetTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(rv)) return rv; @@ -4244,7 +4232,7 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr enumerator; nsresult result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); - if (NS_FAILED(result) || enumerator) + if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; enumerator->First(); diff --git a/editor/base/nsHTMLEditRules.cpp b/editor/base/nsHTMLEditRules.cpp index dc9c8b67f7f..ebe2143f957 100644 --- a/editor/base/nsHTMLEditRules.cpp +++ b/editor/base/nsHTMLEditRules.cpp @@ -41,8 +41,6 @@ class nsIFrame; //const static char* kMOZEditorBogusNodeValue="TRUE"; const unsigned char nbsp = 160; -static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID); -// static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); enum @@ -430,6 +428,10 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo nsCOMPtr endNode; PRInt32 endOffset; res = mEditor->GetEndNodeAndOffset(aSelection, &endNode, &endOffset); + if (NS_FAILED(res)) + { + return res; + } if (endNode.get() != node.get()) { // block parents the same? use default deletion diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp index 79918e62c8f..aca6d3527b4 100644 --- a/editor/base/nsHTMLEditor.cpp +++ b/editor/base/nsHTMLEditor.cpp @@ -56,7 +56,6 @@ const unsigned char nbsp = 160; #include "nsJSEditorLog.h" #endif // ENABLE_JS_EDITOR_LOG -static NS_DEFINE_IID(kInsertHTMLTxnIID, NS_INSERT_HTML_TXN_IID); static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID); static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID); diff --git a/editor/base/nsInsertHTMLTxn.h b/editor/base/nsInsertHTMLTxn.h index 1ae66c89879..e69de29bb2d 100644 --- a/editor/base/nsInsertHTMLTxn.h +++ b/editor/base/nsInsertHTMLTxn.h @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -#ifndef nsInsertHTMLTxn_h__ -#define nsInsertHTMLTxn_h__ - -#include "EditTxn.h" -#include "nsIEditor.h" -#include "nsIDOMRange.h" -#include "nsCOMPtr.h" - -#define NS_INSERT_HTML_TXN_IID \ -{/* a6cf90fd-15b3-11d2-932e-00805f8add3 */ \ -0xa6cf90fc, 0x15b3, 0x11d2, \ -{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } - -/** - * A transaction that inserts a string of html source - */ -class nsInsertHTMLTxn : public EditTxn -{ -public: - - /** initialize the transaction. - * @param aSrc the source for the HTML to insert - * @param aEditor the editor in which to do the work - */ - NS_IMETHOD Init(const nsString& aSrc, - nsIEditor *aEditor); - -private: - nsInsertHTMLTxn(); - -public: - - virtual ~nsInsertHTMLTxn(); - - NS_IMETHOD Do(void); - - NS_IMETHOD Undo(void); - - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); - - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - -protected: - - /** the html to insert */ - nsString mSrc; - - /** the range representing the inserted fragment */ - nsCOMPtr mRange; - - /** the editor for this transaction */ - nsCOMPtr mEditor; - - friend class TransactionFactory; - -}; - -#endif diff --git a/editor/base/nsStyleSheetTxns.h b/editor/base/nsStyleSheetTxns.h index fd66d8f4114..e6eea9195af 100644 --- a/editor/base/nsStyleSheetTxns.h +++ b/editor/base/nsStyleSheetTxns.h @@ -24,11 +24,11 @@ #include "nsIEditor.h" #include "nsICSSStyleSheet.h" -#define ADD_STYLESHEET_TXN_IID \ +#define ADD_STYLESHEET_TXN_CID \ {/* d05e2980-2fbe-11d3-9ce4-e8393835307c */ \ 0xd05e2980, 0x2fbe, 0x11d3, { 0x9c, 0xe4, 0xe8, 0x39, 0x38, 0x35, 0x30, 0x7c } } -#define REMOVE_STYLESHEET_TXN_IID \ +#define REMOVE_STYLESHEET_TXN_CID \ {/* d05e2981-2fbe-11d3-9ce4-e8393835307c */ \ 0xd05e2981, 0x2fbe, 0x11d3, { 0x9c, 0xe4, 0xe8, 0x39, 0x38, 0x35, 0x30, 0x7c } } @@ -39,6 +39,8 @@ class AddStyleSheetTxn : public EditTxn public: + static const nsIID& GetCID() { static nsIID iid = ADD_STYLESHEET_TXN_CID; return iid; } + virtual ~AddStyleSheetTxn(); /** Initialize the transaction. @@ -80,6 +82,9 @@ class RemoveStyleSheetTxn : public EditTxn friend class TransactionFactory; public: + + static const nsIID& GetCID() { static nsIID iid = REMOVE_STYLESHEET_TXN_CID; return iid; } + virtual ~RemoveStyleSheetTxn(); /** Initialize the transaction. diff --git a/editor/base/nsTextEditRules.cpp b/editor/base/nsTextEditRules.cpp index c0d01d5195d..08fd2fbbc22 100644 --- a/editor/base/nsTextEditRules.cpp +++ b/editor/base/nsTextEditRules.cpp @@ -34,7 +34,6 @@ #include "nsLayoutCID.h" #include "nsIEditProperty.h" -static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID); static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID); @@ -233,10 +232,10 @@ nsresult nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, PRBool *aCancel, PlaceholderTxn **aTxn, - const nsString *aInString, - nsString *aOutString, - TypeInState typeInState, - PRInt32 aMaxLength) + const nsString *aInString, + nsString *aOutString, + TypeInState aTypeInState, + PRInt32 aMaxLength) { if (!aSelection || !aCancel || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;} CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -246,7 +245,7 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, nsString inString = *aInString; // we might want to mutate the input // before setting the output, do that in a local var - if (-1 != aMaxLength && (mFlags&TEXT_EDITOR_FLAG_PLAINTEXT)) + if ((-1 != aMaxLength) && (mFlags&TEXT_EDITOR_FLAG_PLAINTEXT)) { // get the current text length // get the length of inString @@ -301,9 +300,9 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, *aOutString = inString; } - if (mBogusNode || (PR_TRUE==typeInState.IsAnySet())) + if (mBogusNode || (PR_TRUE==aTypeInState.IsAnySet())) { - result = TransactionFactory::GetNewTransaction(kPlaceholderTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(PlaceholderTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(result)) { return result; } if (!*aTxn) { return NS_ERROR_NULL_POINTER; } (*aTxn)->SetName(InsertTextTxn::gInsertTextTxnName); @@ -312,9 +311,9 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, result = WillInsert(aSelection, aCancel); if (NS_SUCCEEDED(result) && (PR_FALSE==*aCancel)) { - if (PR_TRUE==typeInState.IsAnySet()) + if (PR_TRUE==aTypeInState.IsAnySet()) { // for every property that is set, insert a new inline style node - result = CreateStyleForInsertText(aSelection, typeInState); + result = CreateStyleForInsertText(aSelection, aTypeInState); } } return result; diff --git a/editor/libeditor/base/ChangeAttributeTxn.h b/editor/libeditor/base/ChangeAttributeTxn.h index 3d3fb502c71..4e0880695a3 100644 --- a/editor/libeditor/base/ChangeAttributeTxn.h +++ b/editor/libeditor/base/ChangeAttributeTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMElement.h" #include "nsIEditor.h" -#define CHANGE_ATTRIBUTE_TXN_IID \ +#define CHANGE_ATTRIBUTE_TXN_CID \ {/* 97818860-ac48-11d2-86d8-000064657374 */ \ 0x97818860, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -37,6 +37,8 @@ class ChangeAttributeTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = CHANGE_ATTRIBUTE_TXN_CID; return iid; } + virtual ~ChangeAttributeTxn(); /** Initialize the transaction. diff --git a/editor/libeditor/base/CreateElementTxn.h b/editor/libeditor/base/CreateElementTxn.h index 8cebdf24fb7..743a7a8b91f 100644 --- a/editor/libeditor/base/CreateElementTxn.h +++ b/editor/libeditor/base/CreateElementTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define CREATE_ELEMENT_TXN_IID \ +#define CREATE_ELEMENT_TXN_CID \ {/* 7a6393c0-ac48-11d2-86d8-000064657374 */ \ 0x7a6393c0, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class CreateElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = CREATE_ELEMENT_TXN_CID; return iid; } + enum { eAppend=-1 }; /** Initialize the transaction. diff --git a/editor/libeditor/base/DeleteElementTxn.h b/editor/libeditor/base/DeleteElementTxn.h index 08ac5fff0dc..b7ef8665801 100644 --- a/editor/libeditor/base/DeleteElementTxn.h +++ b/editor/libeditor/base/DeleteElementTxn.h @@ -23,7 +23,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define DELETE_ELEMENT_TXN_IID \ +#define DELETE_ELEMENT_TXN_CID \ {/* 6fd77770-ac49-11d2-86d8-000064657374 */ \ 0x6fd77770, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -34,6 +34,8 @@ class DeleteElementTxn : public EditTxn { public: + + static const nsIID& GetCID() { static nsIID iid = DELETE_ELEMENT_TXN_CID; return iid; } /** initialize the transaction. * @param aElement the node to delete diff --git a/editor/libeditor/base/DeleteRangeTxn.cpp b/editor/libeditor/base/DeleteRangeTxn.cpp index 5af55dacf64..dd5ac9c09b6 100644 --- a/editor/libeditor/base/DeleteRangeTxn.cpp +++ b/editor/libeditor/base/DeleteRangeTxn.cpp @@ -32,9 +32,6 @@ #include "nsIDOMElement.h" #endif -static NS_DEFINE_IID(kDeleteTextTxnIID, DELETE_TEXT_TXN_IID); -static NS_DEFINE_IID(kDeleteElementTxnIID, DELETE_ELEMENT_TXN_IID); - #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; #else @@ -238,7 +235,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent if (textNode) { // if the node is a text node, then delete text content DeleteTextTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteTextTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { PRInt32 numToDel; @@ -267,7 +264,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent if ((NS_SUCCEEDED(result)) && child) { DeleteElementTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteElementTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { txn->Init(child); @@ -308,7 +305,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent, if (numToDelete) { DeleteTextTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteTextTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { txn->Init(mEditor, textNode, start, numToDelete); @@ -350,7 +347,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteNodesBetween() if ((NS_SUCCEEDED(result)) && node) { DeleteElementTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteElementTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn); if (nsnull!=txn) { txn->Init(node); diff --git a/editor/libeditor/base/DeleteRangeTxn.h b/editor/libeditor/base/DeleteRangeTxn.h index ae46d4c05a1..9df23001fe7 100644 --- a/editor/libeditor/base/DeleteRangeTxn.h +++ b/editor/libeditor/base/DeleteRangeTxn.h @@ -27,7 +27,7 @@ class nsIDOMDocument; -#define DELETE_RANGE_TXN_IID \ +#define DELETE_RANGE_TXN_CID \ {/* 5ec6b260-ac49-11d2-86d8-000064657374 */ \ 0x5ec6b260, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -39,6 +39,8 @@ class DeleteRangeTxn : public EditAggregateTxn { public: + static const nsIID& GetCID() { static nsIID iid = DELETE_RANGE_TXN_CID; return iid; } + /** initialize the transaction. * @param aEditor the object providing basic editing operations * @param aRange the range to delete diff --git a/editor/libeditor/base/DeleteTextTxn.h b/editor/libeditor/base/DeleteTextTxn.h index 8b0d3d07f58..14ce511218c 100644 --- a/editor/libeditor/base/DeleteTextTxn.h +++ b/editor/libeditor/base/DeleteTextTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMCharacterData.h" #include "nsCOMPtr.h" -#define DELETE_TEXT_TXN_IID \ +#define DELETE_TEXT_TXN_CID \ {/* 4d3a2720-ac49-11d2-86d8-000064657374 */ \ 0x4d3a2720, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class DeleteTextTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = DELETE_TEXT_TXN_CID; return iid; } + /** initialize the transaction. * @param aEditor the provider of basic editing operations * @param aElement the content node to remove text from diff --git a/editor/libeditor/base/EditAggregateTxn.h b/editor/libeditor/base/EditAggregateTxn.h index 8a0916a9569..b7512a4edbb 100644 --- a/editor/libeditor/base/EditAggregateTxn.h +++ b/editor/libeditor/base/EditAggregateTxn.h @@ -23,7 +23,7 @@ #include "nsIAtom.h" #include "nsCOMPtr.h" -#define EDIT_AGGREGATE_TXN_IID \ +#define EDIT_AGGREGATE_TXN_CID \ {/* 345921a0-ac49-11d2-86d8-000064657374 */ \ 0x345921a0, 0xac49, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -40,7 +40,7 @@ public: NS_DECL_ISUPPORTS_INHERITED - static const nsIID& GetCID() { static nsIID cid = EDIT_AGGREGATE_TXN_IID; return cid; } + static const nsIID& GetCID() { static nsIID cid = EDIT_AGGREGATE_TXN_CID; return cid; } EditAggregateTxn(); diff --git a/editor/libeditor/base/EditTxn.h b/editor/libeditor/base/EditTxn.h index 7b298664c65..8a3bfe4446e 100644 --- a/editor/libeditor/base/EditTxn.h +++ b/editor/libeditor/base/EditTxn.h @@ -22,7 +22,7 @@ #include "nsITransaction.h" #include "nsCOMPtr.h" -#define EDIT_TXN_IID \ +#define EDIT_TXN_CID \ {/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \ 0xc5ea31b0, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -37,6 +37,8 @@ class EditTxn : public nsITransaction { public: + static const nsIID& GetCID() { static nsIID iid = EDIT_TXN_CID; return iid; } + NS_DECL_ISUPPORTS EditTxn(); diff --git a/editor/libeditor/base/IMETextTxn.cpp b/editor/libeditor/base/IMETextTxn.cpp index adfb733b7c0..905c141a15c 100644 --- a/editor/libeditor/base/IMETextTxn.cpp +++ b/editor/libeditor/base/IMETextTxn.cpp @@ -26,7 +26,6 @@ #include "nsIPresShell.h" #include "EditAggregateTxn.h" -static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID); static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); nsIAtom *IMETextTxn::gIMETextTxnName = nsnull; @@ -204,7 +203,7 @@ IMETextTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) if (nsnull == aInstancePtr) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kIMETextTxnIID)) { + if (aIID.Equals(IMETextTxn::GetCID())) { *aInstancePtr = (void*)(IMETextTxn*)this; NS_ADDREF_THIS(); return NS_OK; diff --git a/editor/libeditor/base/IMETextTxn.h b/editor/libeditor/base/IMETextTxn.h index b75865a12a9..fea487a3318 100644 --- a/editor/libeditor/base/IMETextTxn.h +++ b/editor/libeditor/base/IMETextTxn.h @@ -25,7 +25,7 @@ #include "nsCOMPtr.h" // {D4D25721-2813-11d3-9EA3-0060089FE59B} -#define IME_TEXT_TXN_IID \ +#define IME_TEXT_TXN_CID \ {0xd4d25721, 0x2813, 0x11d3, \ {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }} @@ -40,6 +40,8 @@ class nsIPresShell; class IMETextTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = IME_TEXT_TXN_CID; return iid; } + virtual ~IMETextTxn(); /** used to name aggregate transactions that consist only of a single IMETextTxn, @@ -84,9 +86,6 @@ public: // override QueryInterface to handle IMETextTxn request NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - static const nsIID& GetIID() { static nsIID iid = IME_TEXT_TXN_IID; return iid; } - - /** return the string data associated with this transaction */ NS_IMETHOD GetData(nsString& aResult, nsIDOMTextRangeList** aTextRangeList); diff --git a/editor/libeditor/base/InsertElementTxn.h b/editor/libeditor/base/InsertElementTxn.h index 3af31a5af60..6d1da7db628 100644 --- a/editor/libeditor/base/InsertElementTxn.h +++ b/editor/libeditor/base/InsertElementTxn.h @@ -24,7 +24,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define INSERT_ELEMENT_TXN_IID \ +#define INSERT_ELEMENT_TXN_CID \ {/* b5762440-cbb0-11d2-86db-000064657374 */ \ 0xb5762440, 0xcbb0, 0x11d2, \ {0x86, 0xdb, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class InsertElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = INSERT_ELEMENT_TXN_CID; return iid; } + /** initialize the transaction. * @param aNode the node to insert * @param aParent the node to insert into diff --git a/editor/libeditor/base/InsertTextTxn.cpp b/editor/libeditor/base/InsertTextTxn.cpp index 27470efdf92..0f8b06997f6 100644 --- a/editor/libeditor/base/InsertTextTxn.cpp +++ b/editor/libeditor/base/InsertTextTxn.cpp @@ -23,9 +23,7 @@ #include "nsIPresShell.h" #include "EditAggregateTxn.h" -static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID); static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); -static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID); #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -117,7 +115,7 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti // if aTransaction isa InsertTextTxn, and if the selection hasn't changed, // then absorb it InsertTextTxn *otherInsTxn = nsnull; - aTransaction->QueryInterface(kInsertTextTxnIID, (void **)&otherInsTxn); + aTransaction->QueryInterface(InsertTextTxn::GetCID(), (void **)&otherInsTxn); if (otherInsTxn) { if (PR_TRUE==IsSequentialInsert(otherInsTxn)) @@ -201,7 +199,7 @@ InsertTextTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) if (nsnull == aInstancePtr) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kInsertTextTxnIID)) { + if (aIID.Equals(InsertTextTxn::GetCID())) { *aInstancePtr = (void*)(InsertTextTxn*)this; NS_ADDREF_THIS(); return NS_OK; diff --git a/editor/libeditor/base/InsertTextTxn.h b/editor/libeditor/base/InsertTextTxn.h index f6c74ccbbfa..e34272405f7 100644 --- a/editor/libeditor/base/InsertTextTxn.h +++ b/editor/libeditor/base/InsertTextTxn.h @@ -23,7 +23,7 @@ #include "nsIDOMCharacterData.h" #include "nsCOMPtr.h" -#define INSERT_TEXT_TXN_IID \ +#define INSERT_TEXT_TXN_CID \ {/* 93276f00-ab2c-11d2-8f4b-006008159b0c*/ \ 0x93276f00, 0xab2c, 0x11d2, \ {0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} } @@ -36,6 +36,9 @@ class nsIPresShell; class InsertTextTxn : public EditTxn { public: + + static const nsIID& GetCID() { static nsIID iid = INSERT_TEXT_TXN_CID; return iid; } + virtual ~InsertTextTxn(); /** used to name aggregate transactions that consist only of a single InsertTextTxn, @@ -77,9 +80,6 @@ public: // override QueryInterface to handle InsertTextTxn request NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - static const nsIID& GetIID() { static nsIID iid = INSERT_TEXT_TXN_IID; return iid; } - - /** return the string data associated with this transaction */ NS_IMETHOD GetData(nsString& aResult); diff --git a/editor/libeditor/base/JoinElementTxn.h b/editor/libeditor/base/JoinElementTxn.h index 644dfbc7ab5..7b951252b74 100644 --- a/editor/libeditor/base/JoinElementTxn.h +++ b/editor/libeditor/base/JoinElementTxn.h @@ -24,7 +24,7 @@ #include "nsCOMPtr.h" #include "nsIEditor.h" -#define JOIN_ELEMENT_TXN_IID \ +#define JOIN_ELEMENT_TXN_CID \ {/* 9bc5f9f0-ac48-11d2-86d8-000064657374 */ \ 0x9bc5f9f0, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -40,6 +40,8 @@ class JoinElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = JOIN_ELEMENT_TXN_CID; return iid; } + /** initialize the transaction * @param aEditor the provider of core editing operations * @param aLeftNode the first of two nodes to join diff --git a/editor/libeditor/base/PlaceholderTxn.h b/editor/libeditor/base/PlaceholderTxn.h index 6f6f39953a3..74441711026 100644 --- a/editor/libeditor/base/PlaceholderTxn.h +++ b/editor/libeditor/base/PlaceholderTxn.h @@ -21,7 +21,7 @@ #include "EditAggregateTxn.h" -#define PLACEHOLDER_TXN_IID \ +#define PLACEHOLDER_TXN_CID \ {/* {0CE9FB00-D9D1-11d2-86DE-000064657374} */ \ 0x0CE9FB00, 0xD9D1, 0x11d2, \ {0x86, 0xde, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -36,6 +36,8 @@ class PlaceholderTxn : public EditAggregateTxn { public: + static const nsIID& GetCID() { static nsIID iid = PLACEHOLDER_TXN_CID; return iid; } + private: PlaceholderTxn(); diff --git a/editor/libeditor/base/SplitElementTxn.h b/editor/libeditor/base/SplitElementTxn.h index ed8b902a297..cb12f7d81af 100644 --- a/editor/libeditor/base/SplitElementTxn.h +++ b/editor/libeditor/base/SplitElementTxn.h @@ -24,7 +24,7 @@ #include "nsCOMPtr.h" #include "nsIEditor.h" -#define SPLIT_ELEMENT_TXN_IID \ +#define SPLIT_ELEMENT_TXN_CID \ {/* 690c6290-ac48-11d2-86d8-000064657374 */ \ 0x690c6290, 0xac48, 0x11d2, \ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } @@ -37,6 +37,8 @@ class SplitElementTxn : public EditTxn { public: + static const nsIID& GetCID() { static nsIID iid = SPLIT_ELEMENT_TXN_CID; return iid; } + /** initialize the transaction. * @param aEditor the provider of core editing operations * @param aNode the node to split diff --git a/editor/libeditor/base/TransactionFactory.cpp b/editor/libeditor/base/TransactionFactory.cpp index 39c1a43f760..a4c87de7541 100644 --- a/editor/libeditor/base/TransactionFactory.cpp +++ b/editor/libeditor/base/TransactionFactory.cpp @@ -43,32 +43,6 @@ #include "IMETextTxn.h" #include "IMECommitTxn.h" -static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID); -static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID); -static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID); -static NS_DEFINE_IID(kDeleteTextTxnIID, DELETE_TEXT_TXN_IID); -static NS_DEFINE_IID(kCreateElementTxnIID, CREATE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertElementTxnIID, INSERT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertHTMLTxnIID, NS_INSERT_HTML_TXN_IID); -static NS_DEFINE_IID(kDeleteElementTxnIID, DELETE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kDeleteRangeTxnIID, DELETE_RANGE_TXN_IID); -static NS_DEFINE_IID(kChangeAttributeTxnIID,CHANGE_ATTRIBUTE_TXN_IID); -static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertTableTxnIID, INSERT_TABLE_TXN_IID); -static NS_DEFINE_IID(kInsertTableCellTxnIID, INSERT_CELL_TXN_IID); -static NS_DEFINE_IID(kInsertTableColumnTxnIID, INSERT_COLUMN_TXN_IID); -static NS_DEFINE_IID(kInsertTableRowTxnIID, INSERT_ROW_TXN_IID); -static NS_DEFINE_IID(kDeleteTableTxnIID, DELETE_TABLE_TXN_IID); -static NS_DEFINE_IID(kDeleteTableCellTxnIID, DELETE_CELL_TXN_IID); -static NS_DEFINE_IID(kDeleteTableColumnTxnIID, DELETE_COLUMN_TXN_IID); -static NS_DEFINE_IID(kDeleteTableRowTxnIID, DELETE_ROW_TXN_IID); -static NS_DEFINE_IID(kJoinTableCellsTxnIID, JOIN_CELLS_TXN_IID); -static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID); -static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID); -static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID); -static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID); - TransactionFactory::TransactionFactory() { } @@ -82,37 +56,37 @@ TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult) { nsresult result = NS_OK; *aResult = nsnull; - if (aTxnType.Equals(kInsertTextTxnIID)) + if (aTxnType.Equals(InsertTextTxn::GetCID())) *aResult = new InsertTextTxn(); - else if (aTxnType.Equals(kDeleteTextTxnIID)) + else if (aTxnType.Equals(DeleteTextTxn::GetCID())) *aResult = new DeleteTextTxn(); - else if (aTxnType.Equals(kCreateElementTxnIID)) + else if (aTxnType.Equals(CreateElementTxn::GetCID())) *aResult = new CreateElementTxn(); - else if (aTxnType.Equals(kInsertElementTxnIID)) + else if (aTxnType.Equals(InsertElementTxn::GetCID())) *aResult = new InsertElementTxn(); - else if (aTxnType.Equals(kInsertHTMLTxnIID)) + else if (aTxnType.Equals(nsInsertHTMLTxn::GetCID())) *aResult = new nsInsertHTMLTxn(); - else if (aTxnType.Equals(kDeleteElementTxnIID)) + else if (aTxnType.Equals(DeleteElementTxn::GetCID())) *aResult = new DeleteElementTxn(); - else if (aTxnType.Equals(kDeleteRangeTxnIID)) + else if (aTxnType.Equals(DeleteRangeTxn::GetCID())) *aResult = new DeleteRangeTxn(); - else if (aTxnType.Equals(kChangeAttributeTxnIID)) + else if (aTxnType.Equals(ChangeAttributeTxn::GetCID())) *aResult = new ChangeAttributeTxn(); - else if (aTxnType.Equals(kSplitElementTxnIID)) + else if (aTxnType.Equals(SplitElementTxn::GetCID())) *aResult = new SplitElementTxn(); - else if (aTxnType.Equals(kJoinElementTxnIID)) + else if (aTxnType.Equals(JoinElementTxn::GetCID())) *aResult = new JoinElementTxn(); - else if (aTxnType.Equals(kEditAggregateTxnIID)) + else if (aTxnType.Equals(EditAggregateTxn::GetCID())) *aResult = new EditAggregateTxn(); - else if (aTxnType.Equals(kIMETextTxnIID)) + else if (aTxnType.Equals(IMETextTxn::GetCID())) *aResult = new IMETextTxn(); - else if (aTxnType.Equals(kIMECommitTxnIID)) + else if (aTxnType.Equals(IMECommitTxn::GetCID())) *aResult = new IMECommitTxn(); - else if (aTxnType.Equals(kAddStyleSheetTxnIID)) + else if (aTxnType.Equals(AddStyleSheetTxn::GetCID())) *aResult = new AddStyleSheetTxn(); - else if (aTxnType.Equals(kRemoveStyleSheetTxnIID)) + else if (aTxnType.Equals(RemoveStyleSheetTxn::GetCID())) *aResult = new RemoveStyleSheetTxn(); - else if (aTxnType.Equals(kPlaceholderTxnIID)) + else if (aTxnType.Equals(PlaceholderTxn::GetCID())) *aResult = new PlaceholderTxn(); else result = NS_ERROR_NO_INTERFACE; diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index e52fa655276..99fba21089c 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -125,22 +125,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); // transaction manager static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID); -// transactions -static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID); -static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID); -static NS_DEFINE_IID(kDeleteTextTxnIID, DELETE_TEXT_TXN_IID); -static NS_DEFINE_IID(kCreateElementTxnIID, CREATE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kInsertElementTxnIID, INSERT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kDeleteElementTxnIID, DELETE_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kDeleteRangeTxnIID, DELETE_RANGE_TXN_IID); -static NS_DEFINE_IID(kChangeAttributeTxnIID,CHANGE_ATTRIBUTE_TXN_IID); -static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); -static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID); -static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID); -static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID); -static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID); - static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); @@ -701,7 +685,7 @@ nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kChangeAttributeTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aElement, aAttribute, aValue, PR_FALSE); } @@ -749,7 +733,7 @@ nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kChangeAttributeTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { nsAutoString value; @@ -1634,7 +1618,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsString& aTag, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aParent) { - result = TransactionFactory::GetNewTransaction(kCreateElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(CreateElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aTag, aParent, aPosition); } @@ -1686,7 +1670,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertElement(nsIDOMNode * aNode, nsresult result = NS_ERROR_NULL_POINTER; if (aNode && aParent && aTxn) { - result = TransactionFactory::GetNewTransaction(kInsertElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(InsertElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(aNode, aParent, aPosition, this); } @@ -1734,7 +1718,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement, nsresult result = NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kDeleteElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(aElement); } @@ -1748,7 +1732,7 @@ NS_IMETHODIMP nsEditor::CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, if (aAggTxn) { *aAggTxn = nsnull; - result = TransactionFactory::GetNewTransaction(kEditAggregateTxnIID, (EditTxn**)aAggTxn); + result = TransactionFactory::GetNewTransaction(EditAggregateTxn::GetCID(), (EditTxn**)aAggTxn); if (NS_FAILED(result) || !*aAggTxn) { return NS_ERROR_OUT_OF_MEMORY; @@ -1810,33 +1794,37 @@ nsEditor::InsertText(const nsString& aStringToInsert) else if (NS_ERROR_EDITOR_NO_TEXTNODE==result) { BeginTransaction(); - nsCOMPtr selection; - result = GetSelection(getter_AddRefs(selection)); - if ((NS_SUCCEEDED(result)) && selection) + result = Do(aggTxn); + if (NS_SUCCEEDED(result)) { - nsCOMPtr selectedNode; - PRInt32 offset; - result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) + nsCOMPtr selection; + result = GetSelection(getter_AddRefs(selection)); + if ((NS_SUCCEEDED(result)) && selection) { - nsCOMPtr newNode; - result = CreateNode(GetTextNodeTag(), selectedNode, offset, // offset+1, why the +1??? - getter_AddRefs(newNode)); - if (NS_SUCCEEDED(result) && newNode) + nsCOMPtr selectedNode; + PRInt32 offset; + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) { - nsCOMPtrnewTextNode; - newTextNode = do_QueryInterface(newNode); - if (newTextNode) + nsCOMPtr newNode; + result = CreateNode(GetTextNodeTag(), selectedNode, offset, + getter_AddRefs(newNode)); + if (NS_SUCCEEDED(result) && newNode) { - nsAutoString placeholderText(" "); - newTextNode->SetData(placeholderText); - selection->Collapse(newNode, 0, SELECTION_NORMAL); - selection->Extend(newNode, 1, SELECTION_NORMAL); - result = InsertText(aStringToInsert); + nsCOMPtrnewTextNode; + newTextNode = do_QueryInterface(newNode); + if (newTextNode) + { + nsAutoString placeholderText(" "); + newTextNode->SetData(placeholderText); + selection->Collapse(newNode, 0, SELECTION_NORMAL); + selection->Extend(newNode, 1, SELECTION_NORMAL); + result = InsertText(aStringToInsert); + } } } - } - } + } + } EndTransaction(); } return result; @@ -1913,7 +1901,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert, } if (NS_SUCCEEDED(result) && nodeAsText) { - result = TransactionFactory::GetNewTransaction(kInsertTextTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(InsertTextTxn::GetCID(), (EditTxn **)aTxn); if (nsnull!=*aTxn) { result = (*aTxn)->Init(nodeAsText, offset, aStringToInsert, mPresShell); } @@ -2013,7 +2001,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteText(nsIDOMCharacterData *aElement, nsresult result=NS_ERROR_NULL_POINTER; if (nsnull != aElement) { - result = TransactionFactory::GetNewTransaction(kDeleteTextTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aElement, aOffset, aLength); } @@ -2246,7 +2234,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti return NS_OK; // allocate the out-param transaction - result = TransactionFactory::GetNewTransaction(kEditAggregateTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(EditAggregateTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(result)) { return result; } @@ -2266,7 +2254,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti if (PR_FALSE==isCollapsed) { DeleteRangeTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteRangeTxnIID, (EditTxn **)&txn); + result = TransactionFactory::GetNewTransaction(DeleteRangeTxn::GetCID(), (EditTxn **)&txn); if ((NS_SUCCEEDED(result)) && (nsnull!=txn)) { txn->Init(this, range); @@ -2499,7 +2487,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForSplitNode(nsIDOMNode *aNode, nsresult result=NS_ERROR_NULL_POINTER; if (nsnull != aNode) { - result = TransactionFactory::GetNewTransaction(kSplitElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(SplitElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aNode, aOffset); } @@ -2551,7 +2539,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForJoinNode(nsIDOMNode *aLeftNode, nsresult result=NS_ERROR_NULL_POINTER; if ((nsnull != aLeftNode) && (nsnull != aRightNode)) { - result = TransactionFactory::GetNewTransaction(kJoinElementTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(JoinElementTxn::GetCID(), (EditTxn **)aTxn); if (NS_SUCCEEDED(result)) { result = (*aTxn)->Init(this, aLeftNode, aRightNode); } @@ -3561,7 +3549,7 @@ nsEditor::EndComposition(void) // // create the commit transaction..we can do it directly from the transaction mgr // - result = TransactionFactory::GetNewTransaction(kIMECommitTxnIID,(EditTxn**)&commitTxn); + result = TransactionFactory::GetNewTransaction(IMECommitTxn::GetCID(), (EditTxn**)&commitTxn); if (NS_SUCCEEDED(result) && commitTxn!=nsnull) { commitTxn->Init(); @@ -3816,7 +3804,7 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, { nsresult result; - result = TransactionFactory::GetNewTransaction(kIMETextTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(IMETextTxn::GetCID(), (EditTxn **)aTxn); if (nsnull!=*aTxn) { result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,aTextRangeList,aStringToInsert,mPresShell); } @@ -3830,7 +3818,7 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, NS_IMETHODIMP nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn) { - nsresult rv = TransactionFactory::GetNewTransaction(kAddStyleSheetTxnIID, (EditTxn **)aTxn); + nsresult rv = TransactionFactory::GetNewTransaction(AddStyleSheetTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(rv)) return rv; @@ -3845,7 +3833,7 @@ nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* NS_IMETHODIMP nsEditor::CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn) { - nsresult rv = TransactionFactory::GetNewTransaction(kRemoveStyleSheetTxnIID, (EditTxn **)aTxn); + nsresult rv = TransactionFactory::GetNewTransaction(RemoveStyleSheetTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(rv)) return rv; @@ -4244,7 +4232,7 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr enumerator; nsresult result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); - if (NS_FAILED(result) || enumerator) + if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; enumerator->First(); diff --git a/editor/libeditor/base/nsStyleSheetTxns.h b/editor/libeditor/base/nsStyleSheetTxns.h index fd66d8f4114..e6eea9195af 100644 --- a/editor/libeditor/base/nsStyleSheetTxns.h +++ b/editor/libeditor/base/nsStyleSheetTxns.h @@ -24,11 +24,11 @@ #include "nsIEditor.h" #include "nsICSSStyleSheet.h" -#define ADD_STYLESHEET_TXN_IID \ +#define ADD_STYLESHEET_TXN_CID \ {/* d05e2980-2fbe-11d3-9ce4-e8393835307c */ \ 0xd05e2980, 0x2fbe, 0x11d3, { 0x9c, 0xe4, 0xe8, 0x39, 0x38, 0x35, 0x30, 0x7c } } -#define REMOVE_STYLESHEET_TXN_IID \ +#define REMOVE_STYLESHEET_TXN_CID \ {/* d05e2981-2fbe-11d3-9ce4-e8393835307c */ \ 0xd05e2981, 0x2fbe, 0x11d3, { 0x9c, 0xe4, 0xe8, 0x39, 0x38, 0x35, 0x30, 0x7c } } @@ -39,6 +39,8 @@ class AddStyleSheetTxn : public EditTxn public: + static const nsIID& GetCID() { static nsIID iid = ADD_STYLESHEET_TXN_CID; return iid; } + virtual ~AddStyleSheetTxn(); /** Initialize the transaction. @@ -80,6 +82,9 @@ class RemoveStyleSheetTxn : public EditTxn friend class TransactionFactory; public: + + static const nsIID& GetCID() { static nsIID iid = REMOVE_STYLESHEET_TXN_CID; return iid; } + virtual ~RemoveStyleSheetTxn(); /** Initialize the transaction. diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index dc9c8b67f7f..ebe2143f957 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -41,8 +41,6 @@ class nsIFrame; //const static char* kMOZEditorBogusNodeValue="TRUE"; const unsigned char nbsp = 160; -static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID); -// static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); enum @@ -430,6 +428,10 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo nsCOMPtr endNode; PRInt32 endOffset; res = mEditor->GetEndNodeAndOffset(aSelection, &endNode, &endOffset); + if (NS_FAILED(res)) + { + return res; + } if (endNode.get() != node.get()) { // block parents the same? use default deletion diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 79918e62c8f..aca6d3527b4 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -56,7 +56,6 @@ const unsigned char nbsp = 160; #include "nsJSEditorLog.h" #endif // ENABLE_JS_EDITOR_LOG -static NS_DEFINE_IID(kInsertHTMLTxnIID, NS_INSERT_HTML_TXN_IID); static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID); static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID); diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index c0d01d5195d..08fd2fbbc22 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -34,7 +34,6 @@ #include "nsLayoutCID.h" #include "nsIEditProperty.h" -static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID); static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID); @@ -233,10 +232,10 @@ nsresult nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, PRBool *aCancel, PlaceholderTxn **aTxn, - const nsString *aInString, - nsString *aOutString, - TypeInState typeInState, - PRInt32 aMaxLength) + const nsString *aInString, + nsString *aOutString, + TypeInState aTypeInState, + PRInt32 aMaxLength) { if (!aSelection || !aCancel || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;} CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -246,7 +245,7 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, nsString inString = *aInString; // we might want to mutate the input // before setting the output, do that in a local var - if (-1 != aMaxLength && (mFlags&TEXT_EDITOR_FLAG_PLAINTEXT)) + if ((-1 != aMaxLength) && (mFlags&TEXT_EDITOR_FLAG_PLAINTEXT)) { // get the current text length // get the length of inString @@ -301,9 +300,9 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, *aOutString = inString; } - if (mBogusNode || (PR_TRUE==typeInState.IsAnySet())) + if (mBogusNode || (PR_TRUE==aTypeInState.IsAnySet())) { - result = TransactionFactory::GetNewTransaction(kPlaceholderTxnIID, (EditTxn **)aTxn); + result = TransactionFactory::GetNewTransaction(PlaceholderTxn::GetCID(), (EditTxn **)aTxn); if (NS_FAILED(result)) { return result; } if (!*aTxn) { return NS_ERROR_NULL_POINTER; } (*aTxn)->SetName(InsertTextTxn::gInsertTextTxnName); @@ -312,9 +311,9 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection, result = WillInsert(aSelection, aCancel); if (NS_SUCCEEDED(result) && (PR_FALSE==*aCancel)) { - if (PR_TRUE==typeInState.IsAnySet()) + if (PR_TRUE==aTypeInState.IsAnySet()) { // for every property that is set, insert a new inline style node - result = CreateStyleForInsertText(aSelection, typeInState); + result = CreateStyleForInsertText(aSelection, aTypeInState); } } return result;