зеркало из https://github.com/mozilla/pjs.git
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.
This commit is contained in:
Родитель
fa69f0e621
Коммит
5c7a93503f
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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} }
|
||||
|
@ -35,6 +35,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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,29 +1794,33 @@ nsEditor::InsertText(const nsString& aStringToInsert)
|
|||
else if (NS_ERROR_EDITOR_NO_TEXTNODE==result)
|
||||
{
|
||||
BeginTransaction();
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = GetSelection(getter_AddRefs(selection));
|
||||
if ((NS_SUCCEEDED(result)) && selection)
|
||||
result = Do(aggTxn);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = GetSelection(getter_AddRefs(selection));
|
||||
if ((NS_SUCCEEDED(result)) && selection)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
result = CreateNode(GetTextNodeTag(), selectedNode, offset, // offset+1, why the +1???
|
||||
getter_AddRefs(newNode));
|
||||
if (NS_SUCCEEDED(result) && newNode)
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCharacterData>newTextNode;
|
||||
newTextNode = do_QueryInterface(newNode);
|
||||
if (newTextNode)
|
||||
nsCOMPtr<nsIDOMNode> 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);
|
||||
nsCOMPtr<nsIDOMCharacterData>newTextNode;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<nsIEnumerator> 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();
|
||||
|
|
|
@ -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<nsIDOMNode> 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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<nsIDOMRange> mRange;
|
||||
|
||||
/** the editor for this transaction */
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
|
||||
friend class TransactionFactory;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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} }
|
||||
|
@ -35,6 +35,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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,29 +1794,33 @@ nsEditor::InsertText(const nsString& aStringToInsert)
|
|||
else if (NS_ERROR_EDITOR_NO_TEXTNODE==result)
|
||||
{
|
||||
BeginTransaction();
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = GetSelection(getter_AddRefs(selection));
|
||||
if ((NS_SUCCEEDED(result)) && selection)
|
||||
result = Do(aggTxn);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = GetSelection(getter_AddRefs(selection));
|
||||
if ((NS_SUCCEEDED(result)) && selection)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
result = CreateNode(GetTextNodeTag(), selectedNode, offset, // offset+1, why the +1???
|
||||
getter_AddRefs(newNode));
|
||||
if (NS_SUCCEEDED(result) && newNode)
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCharacterData>newTextNode;
|
||||
newTextNode = do_QueryInterface(newNode);
|
||||
if (newTextNode)
|
||||
nsCOMPtr<nsIDOMNode> 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);
|
||||
nsCOMPtr<nsIDOMCharacterData>newTextNode;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<nsIEnumerator> 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();
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<nsIDOMNode> 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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче