Highlights:
updated to new nsCOMPtr usage nsTextEditor::InsertBreak() implemented splits the text node at the caret (deletes any extended selection to force a collapsed selection.) inserts a <BR> which I assume we'll convert to a CR when we write to a text stream. undo and redo work, except for the bug noted below More stuff: interface cleanup strategic debugging code added delete selection txn sets the collapses the selection...this is just a placeholder, but I needed it for undo/redo of InsertBreak. join and split now work for text nodes as well as interior nodes git-svn-id: svn://10.0.0.236/trunk@21009 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
#include "SplitElementTxn.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIEditorSupport.h"
|
||||
|
||||
static NS_DEFINE_IID(kIEditorSupportIID, NS_IEDITORSUPPORT_IID);
|
||||
|
||||
// note that aEditor is not refcounted
|
||||
SplitElementTxn::SplitElementTxn()
|
||||
@@ -53,7 +56,14 @@ nsresult SplitElementTxn::Do(void)
|
||||
// insert the new node
|
||||
if ((NS_SUCCEEDED(result)) && (mParent))
|
||||
{
|
||||
result = mEditor->SplitNode(mExistingRightNode, mOffset, mNewLeftNode, mParent);
|
||||
nsCOMPtr<nsIEditorSupport> editor;
|
||||
result = mEditor->QueryInterface(kIEditorSupportIID, getter_AddRefs(editor));
|
||||
if (NS_SUCCEEDED(result) && editor) {
|
||||
result = editor->SplitNodeImpl(mExistingRightNode, mOffset, mNewLeftNode, mParent);
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -62,13 +72,29 @@ nsresult SplitElementTxn::Do(void)
|
||||
nsresult SplitElementTxn::Undo(void)
|
||||
{
|
||||
// this assumes Do inserted the new node in front of the prior existing node
|
||||
nsresult result = mEditor->JoinNodes(mExistingRightNode, mNewLeftNode, mParent, PR_FALSE);
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIEditorSupport> editor;
|
||||
result = mEditor->QueryInterface(kIEditorSupportIID, getter_AddRefs(editor));
|
||||
if (NS_SUCCEEDED(result) && editor) {
|
||||
result = editor->JoinNodesImpl(mExistingRightNode, mNewLeftNode, mParent, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult SplitElementTxn::Redo(void)
|
||||
{
|
||||
nsresult result = mEditor->SplitNode(mExistingRightNode, mOffset, mNewLeftNode, mParent);
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIEditorSupport> editor;
|
||||
result = mEditor->QueryInterface(kIEditorSupportIID, getter_AddRefs(editor));
|
||||
if (NS_SUCCEEDED(result) && editor) {
|
||||
result = editor->SplitNodeImpl(mExistingRightNode, mOffset, mNewLeftNode, mParent);
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user