diff --git a/mozilla/editor/base/ChangeAttributeTxn.cpp b/mozilla/editor/base/ChangeAttributeTxn.cpp index e3cc0e8fb0b..dd9f0aee61f 100644 --- a/mozilla/editor/base/ChangeAttributeTxn.cpp +++ b/mozilla/editor/base/ChangeAttributeTxn.cpp @@ -95,13 +95,6 @@ nsresult ChangeAttributeTxn::Redo(void) return result; } -nsresult ChangeAttributeTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/base/ChangeAttributeTxn.h b/mozilla/editor/base/ChangeAttributeTxn.h index 48bded0e116..8ccaf230756 100644 --- a/mozilla/editor/base/ChangeAttributeTxn.h +++ b/mozilla/editor/base/ChangeAttributeTxn.h @@ -54,8 +54,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/base/CreateElementTxn.cpp b/mozilla/editor/base/CreateElementTxn.cpp index 44f1b69170a..db9192ecfaa 100644 --- a/mozilla/editor/base/CreateElementTxn.cpp +++ b/mozilla/editor/base/CreateElementTxn.cpp @@ -93,13 +93,6 @@ nsresult CreateElementTxn::Redo(void) return result; } -nsresult CreateElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/base/CreateElementTxn.h b/mozilla/editor/base/CreateElementTxn.h index bbe1c4a4421..51a08414563 100644 --- a/mozilla/editor/base/CreateElementTxn.h +++ b/mozilla/editor/base/CreateElementTxn.h @@ -57,8 +57,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/base/DeleteElementTxn.cpp b/mozilla/editor/base/DeleteElementTxn.cpp index b381eedf414..3b37f7c7982 100644 --- a/mozilla/editor/base/DeleteElementTxn.cpp +++ b/mozilla/editor/base/DeleteElementTxn.cpp @@ -113,13 +113,6 @@ nsresult DeleteElementTxn::Redo(void) return result; } -nsresult DeleteElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/base/DeleteElementTxn.h b/mozilla/editor/base/DeleteElementTxn.h index 9cf3469f918..296a16bfe55 100644 --- a/mozilla/editor/base/DeleteElementTxn.h +++ b/mozilla/editor/base/DeleteElementTxn.h @@ -51,8 +51,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/base/DeleteRangeTxn.cpp b/mozilla/editor/base/DeleteRangeTxn.cpp index 3246b90e9f2..9ac38a55b41 100644 --- a/mozilla/editor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/base/DeleteRangeTxn.cpp @@ -153,13 +153,6 @@ nsresult DeleteRangeTxn::Redo(void) return result; } -nsresult DeleteRangeTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/base/DeleteRangeTxn.h b/mozilla/editor/base/DeleteRangeTxn.h index 09af0e639c6..aa9d5bb4070 100644 --- a/mozilla/editor/base/DeleteRangeTxn.h +++ b/mozilla/editor/base/DeleteRangeTxn.h @@ -55,8 +55,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/base/DeleteTextTxn.cpp b/mozilla/editor/base/DeleteTextTxn.cpp index eda056e3a3a..f7c12e41cc3 100644 --- a/mozilla/editor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/base/DeleteTextTxn.cpp @@ -49,13 +49,6 @@ nsresult DeleteTextTxn::Undo(void) return (mElement->InsertData(mOffset, mDeletedText)); } -nsresult DeleteTextTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/base/DeleteTextTxn.h b/mozilla/editor/base/DeleteTextTxn.h index ad2fd0de334..61a0fa8f4d3 100644 --- a/mozilla/editor/base/DeleteTextTxn.h +++ b/mozilla/editor/base/DeleteTextTxn.h @@ -49,7 +49,6 @@ public: virtual nsresult Undo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); diff --git a/mozilla/editor/base/EditAggregateTxn.cpp b/mozilla/editor/base/EditAggregateTxn.cpp index e07c6d3f8c6..6497b1d71fe 100644 --- a/mozilla/editor/base/EditAggregateTxn.cpp +++ b/mozilla/editor/base/EditAggregateTxn.cpp @@ -100,7 +100,7 @@ nsresult EditAggregateTxn::Redo(void) nsresult EditAggregateTxn::GetIsTransient(PRBool *aIsTransient) { if (nsnull!=aIsTransient) - *aIsTransient = PR_TRUE; + *aIsTransient = PR_FALSE; return NS_OK; } diff --git a/mozilla/editor/base/EditTxn.cpp b/mozilla/editor/base/EditTxn.cpp index d17b6d2583f..b3ff90077dc 100644 --- a/mozilla/editor/base/EditTxn.cpp +++ b/mozilla/editor/base/EditTxn.cpp @@ -50,7 +50,7 @@ nsresult EditTxn::Redo(void) nsresult EditTxn::GetIsTransient(PRBool *aIsTransient) { if (nsnull!=aIsTransient) - *aIsTransient = PR_TRUE; + *aIsTransient = PR_FALSE; return NS_OK; } diff --git a/mozilla/editor/base/InsertTextTxn.cpp b/mozilla/editor/base/InsertTextTxn.cpp index 5b17c17ff84..7876f201ee1 100644 --- a/mozilla/editor/base/InsertTextTxn.cpp +++ b/mozilla/editor/base/InsertTextTxn.cpp @@ -49,13 +49,6 @@ nsresult InsertTextTxn::Undo(void) return (mElement->DeleteData(mOffset, length)); } -nsresult InsertTextTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { // set out param default value diff --git a/mozilla/editor/base/InsertTextTxn.h b/mozilla/editor/base/InsertTextTxn.h index 134cddb790b..417c037597f 100644 --- a/mozilla/editor/base/InsertTextTxn.h +++ b/mozilla/editor/base/InsertTextTxn.h @@ -50,8 +50,6 @@ public: virtual nsresult Undo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/base/SplitElementTxn.cpp b/mozilla/editor/base/SplitElementTxn.cpp index dcabdec1865..0568cc41d8b 100644 --- a/mozilla/editor/base/SplitElementTxn.cpp +++ b/mozilla/editor/base/SplitElementTxn.cpp @@ -71,13 +71,6 @@ nsresult SplitElementTxn::Redo(void) return result; } -nsresult SplitElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult SplitElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/base/SplitElementTxn.h b/mozilla/editor/base/SplitElementTxn.h index 051021e6bb8..0a163ee1eb8 100644 --- a/mozilla/editor/base/SplitElementTxn.h +++ b/mozilla/editor/base/SplitElementTxn.h @@ -50,8 +50,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/base/TransactionFactory.cpp b/mozilla/editor/base/TransactionFactory.cpp index cc4be1af14f..2de202d0c46 100644 --- a/mozilla/editor/base/TransactionFactory.cpp +++ b/mozilla/editor/base/TransactionFactory.cpp @@ -18,6 +18,7 @@ #include "TransactionFactory.h" // transactions this factory knows how to build +#include "EditAggregateTxn.h" #include "InsertTextTxn.h" #include "DeleteTextTxn.h" #include "CreateElementTxn.h" @@ -27,6 +28,7 @@ #include "SplitElementTxn.h" #include "JoinElementTxn.h" +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); @@ -65,6 +67,8 @@ TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult) *aResult = new SplitElementTxn(); else if (aTxnType.Equals(kJoinElementTxnIID)) *aResult = new JoinElementTxn(); + else if (aTxnType.Equals(kEditAggregateTxnIID)) + *aResult = new EditAggregateTxn(); if (nsnull==*aResult) result = NS_ERROR_INVALID_ARG; diff --git a/mozilla/editor/base/editor.cpp b/mozilla/editor/base/editor.cpp index 61c9541778e..58b18d26ed4 100644 --- a/mozilla/editor/base/editor.cpp +++ b/mozilla/editor/base/editor.cpp @@ -826,17 +826,18 @@ nsresult nsEditor::CreateTxnForDeleteText(nsIDOMCharacterData *aElement, } nsresult -nsEditor::DeleteSelection() +nsEditor::DeleteSelection(nsIEditor::Direction aDir) { EditAggregateTxn *txn; - nsresult result = CreateTxnForDeleteSelection(&txn); + nsresult result = CreateTxnForDeleteSelection(aDir, &txn); if (NS_SUCCEEDED(result)) { result = Do(txn); } return result; } -nsresult nsEditor::CreateTxnForDeleteSelection(EditAggregateTxn ** aTxn) +nsresult nsEditor::CreateTxnForDeleteSelection(nsIEditor::Direction aDir, + EditAggregateTxn ** aTxn) { nsresult result; // allocate the out-param transaction @@ -854,21 +855,52 @@ nsresult nsEditor::CreateTxnForDeleteSelection(EditAggregateTxn ** aTxn) enumerator->First(); nsISupports *currentItem; result = enumerator->CurrentItem(¤tItem); - while ((NS_SUCCEEDED(result)) && (nsnull!=currentItem)) + /*while */ if ((NS_SUCCEEDED(result)) && (nsnull!=currentItem)) { nsCOMPtr range(currentItem); - DeleteRangeTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteRangeTxnIID, (EditTxn **)&txn); - if (nsnull!=txn) + PRBool isCollapsed; + range->GetIsCollapsed(&isCollapsed); + if (PR_FALSE==isCollapsed) { - txn->Init(range); - (*aTxn)->AppendChild(txn); + DeleteRangeTxn *txn; + result = TransactionFactory::GetNewTransaction(kDeleteRangeTxnIID, (EditTxn **)&txn); + if (nsnull!=txn) + { + txn->Init(range); + (*aTxn)->AppendChild(txn); + } + else + result = NS_ERROR_OUT_OF_MEMORY; } else - result = NS_ERROR_OUT_OF_MEMORY; + { // we have an insertion point. delete the thing in front of it or behind it, depending on aDir + nsCOMPtr node; + PRInt32 offset; + PRInt32 length=1; + result = range->GetStartParent(getter_AddRefs(node)); + result = range->GetStartOffset(&offset); + nsCOMPtr text = node.get(); + if (node) + { // we have text, so delete a char at the proper offset + // XXX: doesn't handle beginning/end of text node, which needs to jump to next|prev node + if (nsIEditor::eRTL==aDir) + { + if (0!=offset) + offset --; + } + DeleteTextTxn *txn; + result = CreateTxnForDeleteText(text, offset, length, &txn); + (*aTxn)->AppendChild(txn); + } + } + // XXX: should call IsDone -- waiting for fix from greg + // when fixed, change if to while if (NS_SUCCEEDED(result)) { nsresult nextResult = enumerator->Next(); + // XXX hack for now + if (nextResult==NS_ERROR_FAILURE) + return result; if (NS_SUCCEEDED(nextResult)) { result = enumerator->CurrentItem(¤tItem); diff --git a/mozilla/editor/base/editor.h b/mozilla/editor/base/editor.h index b42db894839..4e4c25c3835 100644 --- a/mozilla/editor/base/editor.h +++ b/mozilla/editor/base/editor.h @@ -162,7 +162,7 @@ public: nsresult DeleteElement(nsIDOMNode * aParent, nsIDOMNode * aElement); - nsresult DeleteSelection(); + nsresult DeleteSelection(nsIEditor::Direction aDir); nsresult InsertText(const nsString& aStringToInsert); @@ -215,7 +215,8 @@ protected: PRUint32 aLength, DeleteTextTxn **aTxn); - nsresult CreateTxnForDeleteSelection(EditAggregateTxn ** aTxn); + nsresult CreateTxnForDeleteSelection(nsIEditor::Direction aDir, + EditAggregateTxn ** aTxn); }; diff --git a/mozilla/editor/base/editorInterfaces.cpp b/mozilla/editor/base/editorInterfaces.cpp index baebf408a85..db9280928ac 100644 --- a/mozilla/editor/base/editorInterfaces.cpp +++ b/mozilla/editor/base/editorInterfaces.cpp @@ -136,58 +136,11 @@ nsEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) { switch(keyCode) { case nsIDOMEvent::VK_BACK: - { - if (PR_FALSE==ctrlKey) - { - // XXX: for now, just grab the first text node - nsCOMPtr currentNode; - nsCOMPtr textNode; - nsCOMPtr text; - if (NS_SUCCEEDED(mEditor->GetCurrentNode(getter_AddRefs(currentNode))) && - NS_SUCCEEDED(mEditor->GetFirstTextNode(currentNode,getter_AddRefs(textNode))) && - NS_SUCCEEDED(textNode->QueryInterface(kIDOMCharacterDataIID, getter_AddRefs(text)))) - { - // XXX: for now, just append the text - PRUint32 offset; - text->GetLength(&offset); - nsresult result = mEditor->DeleteText(text, offset-1, 1); - } - } - else - { - mEditor->DeleteSelection(); - } - } + mEditor->DeleteSelection(nsIEditor::eRTL); break; case nsIDOMEvent::VK_DELETE: - { - if (PR_FALSE==ctrlKey) - { - // XXX: for now, just grab the first text node - nsCOMPtr currentNode; - nsCOMPtr textNode; - nsCOMPtr text; - if (NS_SUCCEEDED(mEditor->GetCurrentNode(getter_AddRefs(currentNode))) && - NS_SUCCEEDED(mEditor->GetFirstTextNode(currentNode,getter_AddRefs(textNode))) && - NS_SUCCEEDED(textNode->QueryInterface(kIDOMCharacterDataIID, getter_AddRefs(text)))) - { - nsresult result = mEditor->DeleteText(text, 0, 1); - } - } - else - { // XXX: delete the first P we find - nsAutoString pTag("P"); - nsCOMPtr currentNode; - nsCOMPtr parentNode; - nsCOMPtr element; - if (NS_SUCCEEDED(mEditor->GetFirstNodeOfType(nsnull, pTag, getter_AddRefs(currentNode)))) - { - currentNode->GetParentNode(getter_AddRefs(parentNode)); - nsresult result = mEditor->DeleteElement(parentNode, currentNode); - } - } - } + mEditor->DeleteSelection(nsIEditor::eLTR); break; case nsIDOMEvent::VK_RETURN: diff --git a/mozilla/editor/core/ChangeAttributeTxn.cpp b/mozilla/editor/core/ChangeAttributeTxn.cpp index e3cc0e8fb0b..dd9f0aee61f 100644 --- a/mozilla/editor/core/ChangeAttributeTxn.cpp +++ b/mozilla/editor/core/ChangeAttributeTxn.cpp @@ -95,13 +95,6 @@ nsresult ChangeAttributeTxn::Redo(void) return result; } -nsresult ChangeAttributeTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/core/ChangeAttributeTxn.h b/mozilla/editor/core/ChangeAttributeTxn.h index 48bded0e116..8ccaf230756 100644 --- a/mozilla/editor/core/ChangeAttributeTxn.h +++ b/mozilla/editor/core/ChangeAttributeTxn.h @@ -54,8 +54,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/core/CreateElementTxn.cpp b/mozilla/editor/core/CreateElementTxn.cpp index 44f1b69170a..db9192ecfaa 100644 --- a/mozilla/editor/core/CreateElementTxn.cpp +++ b/mozilla/editor/core/CreateElementTxn.cpp @@ -93,13 +93,6 @@ nsresult CreateElementTxn::Redo(void) return result; } -nsresult CreateElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/core/CreateElementTxn.h b/mozilla/editor/core/CreateElementTxn.h index bbe1c4a4421..51a08414563 100644 --- a/mozilla/editor/core/CreateElementTxn.h +++ b/mozilla/editor/core/CreateElementTxn.h @@ -57,8 +57,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/core/DeleteElementTxn.cpp b/mozilla/editor/core/DeleteElementTxn.cpp index b381eedf414..3b37f7c7982 100644 --- a/mozilla/editor/core/DeleteElementTxn.cpp +++ b/mozilla/editor/core/DeleteElementTxn.cpp @@ -113,13 +113,6 @@ nsresult DeleteElementTxn::Redo(void) return result; } -nsresult DeleteElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/core/DeleteElementTxn.h b/mozilla/editor/core/DeleteElementTxn.h index 9cf3469f918..296a16bfe55 100644 --- a/mozilla/editor/core/DeleteElementTxn.h +++ b/mozilla/editor/core/DeleteElementTxn.h @@ -51,8 +51,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/core/DeleteRangeTxn.cpp b/mozilla/editor/core/DeleteRangeTxn.cpp index 3246b90e9f2..9ac38a55b41 100644 --- a/mozilla/editor/core/DeleteRangeTxn.cpp +++ b/mozilla/editor/core/DeleteRangeTxn.cpp @@ -153,13 +153,6 @@ nsresult DeleteRangeTxn::Redo(void) return result; } -nsresult DeleteRangeTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/core/DeleteRangeTxn.h b/mozilla/editor/core/DeleteRangeTxn.h index 09af0e639c6..aa9d5bb4070 100644 --- a/mozilla/editor/core/DeleteRangeTxn.h +++ b/mozilla/editor/core/DeleteRangeTxn.h @@ -55,8 +55,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/core/DeleteTextTxn.cpp b/mozilla/editor/core/DeleteTextTxn.cpp index eda056e3a3a..f7c12e41cc3 100644 --- a/mozilla/editor/core/DeleteTextTxn.cpp +++ b/mozilla/editor/core/DeleteTextTxn.cpp @@ -49,13 +49,6 @@ nsresult DeleteTextTxn::Undo(void) return (mElement->InsertData(mOffset, mDeletedText)); } -nsresult DeleteTextTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/core/DeleteTextTxn.h b/mozilla/editor/core/DeleteTextTxn.h index ad2fd0de334..61a0fa8f4d3 100644 --- a/mozilla/editor/core/DeleteTextTxn.h +++ b/mozilla/editor/core/DeleteTextTxn.h @@ -49,7 +49,6 @@ public: virtual nsresult Undo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); diff --git a/mozilla/editor/core/EditAggregateTxn.cpp b/mozilla/editor/core/EditAggregateTxn.cpp index e07c6d3f8c6..6497b1d71fe 100644 --- a/mozilla/editor/core/EditAggregateTxn.cpp +++ b/mozilla/editor/core/EditAggregateTxn.cpp @@ -100,7 +100,7 @@ nsresult EditAggregateTxn::Redo(void) nsresult EditAggregateTxn::GetIsTransient(PRBool *aIsTransient) { if (nsnull!=aIsTransient) - *aIsTransient = PR_TRUE; + *aIsTransient = PR_FALSE; return NS_OK; } diff --git a/mozilla/editor/core/EditTxn.cpp b/mozilla/editor/core/EditTxn.cpp index d17b6d2583f..b3ff90077dc 100644 --- a/mozilla/editor/core/EditTxn.cpp +++ b/mozilla/editor/core/EditTxn.cpp @@ -50,7 +50,7 @@ nsresult EditTxn::Redo(void) nsresult EditTxn::GetIsTransient(PRBool *aIsTransient) { if (nsnull!=aIsTransient) - *aIsTransient = PR_TRUE; + *aIsTransient = PR_FALSE; return NS_OK; } diff --git a/mozilla/editor/core/InsertTextTxn.cpp b/mozilla/editor/core/InsertTextTxn.cpp index 5b17c17ff84..7876f201ee1 100644 --- a/mozilla/editor/core/InsertTextTxn.cpp +++ b/mozilla/editor/core/InsertTextTxn.cpp @@ -49,13 +49,6 @@ nsresult InsertTextTxn::Undo(void) return (mElement->DeleteData(mOffset, length)); } -nsresult InsertTextTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { // set out param default value diff --git a/mozilla/editor/core/InsertTextTxn.h b/mozilla/editor/core/InsertTextTxn.h index 134cddb790b..417c037597f 100644 --- a/mozilla/editor/core/InsertTextTxn.h +++ b/mozilla/editor/core/InsertTextTxn.h @@ -50,8 +50,6 @@ public: virtual nsresult Undo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/core/SplitElementTxn.cpp b/mozilla/editor/core/SplitElementTxn.cpp index dcabdec1865..0568cc41d8b 100644 --- a/mozilla/editor/core/SplitElementTxn.cpp +++ b/mozilla/editor/core/SplitElementTxn.cpp @@ -71,13 +71,6 @@ nsresult SplitElementTxn::Redo(void) return result; } -nsresult SplitElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult SplitElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/core/SplitElementTxn.h b/mozilla/editor/core/SplitElementTxn.h index 051021e6bb8..0a163ee1eb8 100644 --- a/mozilla/editor/core/SplitElementTxn.h +++ b/mozilla/editor/core/SplitElementTxn.h @@ -50,8 +50,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/core/TransactionFactory.cpp b/mozilla/editor/core/TransactionFactory.cpp index cc4be1af14f..2de202d0c46 100644 --- a/mozilla/editor/core/TransactionFactory.cpp +++ b/mozilla/editor/core/TransactionFactory.cpp @@ -18,6 +18,7 @@ #include "TransactionFactory.h" // transactions this factory knows how to build +#include "EditAggregateTxn.h" #include "InsertTextTxn.h" #include "DeleteTextTxn.h" #include "CreateElementTxn.h" @@ -27,6 +28,7 @@ #include "SplitElementTxn.h" #include "JoinElementTxn.h" +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); @@ -65,6 +67,8 @@ TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult) *aResult = new SplitElementTxn(); else if (aTxnType.Equals(kJoinElementTxnIID)) *aResult = new JoinElementTxn(); + else if (aTxnType.Equals(kEditAggregateTxnIID)) + *aResult = new EditAggregateTxn(); if (nsnull==*aResult) result = NS_ERROR_INVALID_ARG; diff --git a/mozilla/editor/core/editor.cpp b/mozilla/editor/core/editor.cpp index 61c9541778e..58b18d26ed4 100644 --- a/mozilla/editor/core/editor.cpp +++ b/mozilla/editor/core/editor.cpp @@ -826,17 +826,18 @@ nsresult nsEditor::CreateTxnForDeleteText(nsIDOMCharacterData *aElement, } nsresult -nsEditor::DeleteSelection() +nsEditor::DeleteSelection(nsIEditor::Direction aDir) { EditAggregateTxn *txn; - nsresult result = CreateTxnForDeleteSelection(&txn); + nsresult result = CreateTxnForDeleteSelection(aDir, &txn); if (NS_SUCCEEDED(result)) { result = Do(txn); } return result; } -nsresult nsEditor::CreateTxnForDeleteSelection(EditAggregateTxn ** aTxn) +nsresult nsEditor::CreateTxnForDeleteSelection(nsIEditor::Direction aDir, + EditAggregateTxn ** aTxn) { nsresult result; // allocate the out-param transaction @@ -854,21 +855,52 @@ nsresult nsEditor::CreateTxnForDeleteSelection(EditAggregateTxn ** aTxn) enumerator->First(); nsISupports *currentItem; result = enumerator->CurrentItem(¤tItem); - while ((NS_SUCCEEDED(result)) && (nsnull!=currentItem)) + /*while */ if ((NS_SUCCEEDED(result)) && (nsnull!=currentItem)) { nsCOMPtr range(currentItem); - DeleteRangeTxn *txn; - result = TransactionFactory::GetNewTransaction(kDeleteRangeTxnIID, (EditTxn **)&txn); - if (nsnull!=txn) + PRBool isCollapsed; + range->GetIsCollapsed(&isCollapsed); + if (PR_FALSE==isCollapsed) { - txn->Init(range); - (*aTxn)->AppendChild(txn); + DeleteRangeTxn *txn; + result = TransactionFactory::GetNewTransaction(kDeleteRangeTxnIID, (EditTxn **)&txn); + if (nsnull!=txn) + { + txn->Init(range); + (*aTxn)->AppendChild(txn); + } + else + result = NS_ERROR_OUT_OF_MEMORY; } else - result = NS_ERROR_OUT_OF_MEMORY; + { // we have an insertion point. delete the thing in front of it or behind it, depending on aDir + nsCOMPtr node; + PRInt32 offset; + PRInt32 length=1; + result = range->GetStartParent(getter_AddRefs(node)); + result = range->GetStartOffset(&offset); + nsCOMPtr text = node.get(); + if (node) + { // we have text, so delete a char at the proper offset + // XXX: doesn't handle beginning/end of text node, which needs to jump to next|prev node + if (nsIEditor::eRTL==aDir) + { + if (0!=offset) + offset --; + } + DeleteTextTxn *txn; + result = CreateTxnForDeleteText(text, offset, length, &txn); + (*aTxn)->AppendChild(txn); + } + } + // XXX: should call IsDone -- waiting for fix from greg + // when fixed, change if to while if (NS_SUCCEEDED(result)) { nsresult nextResult = enumerator->Next(); + // XXX hack for now + if (nextResult==NS_ERROR_FAILURE) + return result; if (NS_SUCCEEDED(nextResult)) { result = enumerator->CurrentItem(¤tItem); diff --git a/mozilla/editor/core/editor.h b/mozilla/editor/core/editor.h index b42db894839..4e4c25c3835 100644 --- a/mozilla/editor/core/editor.h +++ b/mozilla/editor/core/editor.h @@ -162,7 +162,7 @@ public: nsresult DeleteElement(nsIDOMNode * aParent, nsIDOMNode * aElement); - nsresult DeleteSelection(); + nsresult DeleteSelection(nsIEditor::Direction aDir); nsresult InsertText(const nsString& aStringToInsert); @@ -215,7 +215,8 @@ protected: PRUint32 aLength, DeleteTextTxn **aTxn); - nsresult CreateTxnForDeleteSelection(EditAggregateTxn ** aTxn); + nsresult CreateTxnForDeleteSelection(nsIEditor::Direction aDir, + EditAggregateTxn ** aTxn); }; diff --git a/mozilla/editor/core/editorInterfaces.cpp b/mozilla/editor/core/editorInterfaces.cpp index baebf408a85..db9280928ac 100644 --- a/mozilla/editor/core/editorInterfaces.cpp +++ b/mozilla/editor/core/editorInterfaces.cpp @@ -136,58 +136,11 @@ nsEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) { switch(keyCode) { case nsIDOMEvent::VK_BACK: - { - if (PR_FALSE==ctrlKey) - { - // XXX: for now, just grab the first text node - nsCOMPtr currentNode; - nsCOMPtr textNode; - nsCOMPtr text; - if (NS_SUCCEEDED(mEditor->GetCurrentNode(getter_AddRefs(currentNode))) && - NS_SUCCEEDED(mEditor->GetFirstTextNode(currentNode,getter_AddRefs(textNode))) && - NS_SUCCEEDED(textNode->QueryInterface(kIDOMCharacterDataIID, getter_AddRefs(text)))) - { - // XXX: for now, just append the text - PRUint32 offset; - text->GetLength(&offset); - nsresult result = mEditor->DeleteText(text, offset-1, 1); - } - } - else - { - mEditor->DeleteSelection(); - } - } + mEditor->DeleteSelection(nsIEditor::eRTL); break; case nsIDOMEvent::VK_DELETE: - { - if (PR_FALSE==ctrlKey) - { - // XXX: for now, just grab the first text node - nsCOMPtr currentNode; - nsCOMPtr textNode; - nsCOMPtr text; - if (NS_SUCCEEDED(mEditor->GetCurrentNode(getter_AddRefs(currentNode))) && - NS_SUCCEEDED(mEditor->GetFirstTextNode(currentNode,getter_AddRefs(textNode))) && - NS_SUCCEEDED(textNode->QueryInterface(kIDOMCharacterDataIID, getter_AddRefs(text)))) - { - nsresult result = mEditor->DeleteText(text, 0, 1); - } - } - else - { // XXX: delete the first P we find - nsAutoString pTag("P"); - nsCOMPtr currentNode; - nsCOMPtr parentNode; - nsCOMPtr element; - if (NS_SUCCEEDED(mEditor->GetFirstNodeOfType(nsnull, pTag, getter_AddRefs(currentNode)))) - { - currentNode->GetParentNode(getter_AddRefs(parentNode)); - nsresult result = mEditor->DeleteElement(parentNode, currentNode); - } - } - } + mEditor->DeleteSelection(nsIEditor::eLTR); break; case nsIDOMEvent::VK_RETURN: diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp index e3cc0e8fb0b..dd9f0aee61f 100644 --- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp +++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp @@ -95,13 +95,6 @@ nsresult ChangeAttributeTxn::Redo(void) return result; } -nsresult ChangeAttributeTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h index 48bded0e116..8ccaf230756 100644 --- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h +++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h @@ -54,8 +54,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.cpp b/mozilla/editor/libeditor/base/CreateElementTxn.cpp index 44f1b69170a..db9192ecfaa 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.cpp +++ b/mozilla/editor/libeditor/base/CreateElementTxn.cpp @@ -93,13 +93,6 @@ nsresult CreateElementTxn::Redo(void) return result; } -nsresult CreateElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.h b/mozilla/editor/libeditor/base/CreateElementTxn.h index bbe1c4a4421..51a08414563 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.h +++ b/mozilla/editor/libeditor/base/CreateElementTxn.h @@ -57,8 +57,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp index b381eedf414..3b37f7c7982 100644 --- a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp @@ -113,13 +113,6 @@ nsresult DeleteElementTxn::Redo(void) return result; } -nsresult DeleteElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/libeditor/base/DeleteElementTxn.h b/mozilla/editor/libeditor/base/DeleteElementTxn.h index 9cf3469f918..296a16bfe55 100644 --- a/mozilla/editor/libeditor/base/DeleteElementTxn.h +++ b/mozilla/editor/libeditor/base/DeleteElementTxn.h @@ -51,8 +51,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp index 3246b90e9f2..9ac38a55b41 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp @@ -153,13 +153,6 @@ nsresult DeleteRangeTxn::Redo(void) return result; } -nsresult DeleteRangeTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.h b/mozilla/editor/libeditor/base/DeleteRangeTxn.h index 09af0e639c6..aa9d5bb4070 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.h +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.h @@ -55,8 +55,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp index eda056e3a3a..f7c12e41cc3 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp @@ -49,13 +49,6 @@ nsresult DeleteTextTxn::Undo(void) return (mElement->InsertData(mOffset, mDeletedText)); } -nsresult DeleteTextTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.h b/mozilla/editor/libeditor/base/DeleteTextTxn.h index ad2fd0de334..61a0fa8f4d3 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.h +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.h @@ -49,7 +49,6 @@ public: virtual nsresult Undo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); diff --git a/mozilla/editor/libeditor/base/EditAggregateTxn.cpp b/mozilla/editor/libeditor/base/EditAggregateTxn.cpp index e07c6d3f8c6..6497b1d71fe 100644 --- a/mozilla/editor/libeditor/base/EditAggregateTxn.cpp +++ b/mozilla/editor/libeditor/base/EditAggregateTxn.cpp @@ -100,7 +100,7 @@ nsresult EditAggregateTxn::Redo(void) nsresult EditAggregateTxn::GetIsTransient(PRBool *aIsTransient) { if (nsnull!=aIsTransient) - *aIsTransient = PR_TRUE; + *aIsTransient = PR_FALSE; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/EditTxn.cpp b/mozilla/editor/libeditor/base/EditTxn.cpp index d17b6d2583f..b3ff90077dc 100644 --- a/mozilla/editor/libeditor/base/EditTxn.cpp +++ b/mozilla/editor/libeditor/base/EditTxn.cpp @@ -50,7 +50,7 @@ nsresult EditTxn::Redo(void) nsresult EditTxn::GetIsTransient(PRBool *aIsTransient) { if (nsnull!=aIsTransient) - *aIsTransient = PR_TRUE; + *aIsTransient = PR_FALSE; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.cpp b/mozilla/editor/libeditor/base/InsertTextTxn.cpp index 5b17c17ff84..7876f201ee1 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertTextTxn.cpp @@ -49,13 +49,6 @@ nsresult InsertTextTxn::Undo(void) return (mElement->DeleteData(mOffset, length)); } -nsresult InsertTextTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { // set out param default value diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.h b/mozilla/editor/libeditor/base/InsertTextTxn.h index 134cddb790b..417c037597f 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.h +++ b/mozilla/editor/libeditor/base/InsertTextTxn.h @@ -50,8 +50,6 @@ public: virtual nsresult Undo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.cpp b/mozilla/editor/libeditor/base/SplitElementTxn.cpp index dcabdec1865..0568cc41d8b 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.cpp +++ b/mozilla/editor/libeditor/base/SplitElementTxn.cpp @@ -71,13 +71,6 @@ nsresult SplitElementTxn::Redo(void) return result; } -nsresult SplitElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (nsnull!=aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - nsresult SplitElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) { if (nsnull!=aDidMerge) diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.h b/mozilla/editor/libeditor/base/SplitElementTxn.h index 051021e6bb8..0a163ee1eb8 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.h +++ b/mozilla/editor/libeditor/base/SplitElementTxn.h @@ -50,8 +50,6 @@ public: virtual nsresult Redo(void); - virtual nsresult GetIsTransient(PRBool *aIsTransient); - virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction); virtual nsresult Write(nsIOutputStream *aOutputStream); diff --git a/mozilla/editor/libeditor/base/TransactionFactory.cpp b/mozilla/editor/libeditor/base/TransactionFactory.cpp index cc4be1af14f..2de202d0c46 100644 --- a/mozilla/editor/libeditor/base/TransactionFactory.cpp +++ b/mozilla/editor/libeditor/base/TransactionFactory.cpp @@ -18,6 +18,7 @@ #include "TransactionFactory.h" // transactions this factory knows how to build +#include "EditAggregateTxn.h" #include "InsertTextTxn.h" #include "DeleteTextTxn.h" #include "CreateElementTxn.h" @@ -27,6 +28,7 @@ #include "SplitElementTxn.h" #include "JoinElementTxn.h" +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); @@ -65,6 +67,8 @@ TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult) *aResult = new SplitElementTxn(); else if (aTxnType.Equals(kJoinElementTxnIID)) *aResult = new JoinElementTxn(); + else if (aTxnType.Equals(kEditAggregateTxnIID)) + *aResult = new EditAggregateTxn(); if (nsnull==*aResult) result = NS_ERROR_INVALID_ARG;