improved paste performance in editor (WIP) (bug 28783)

set/remove inline stlye rewrite (lots of bug #s)


git-svn-id: svn://10.0.0.236/trunk@63943 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jfrancis%netscape.com
2000-03-24 00:13:30 +00:00
parent 7286e61a81
commit 13c14e71dc
5 changed files with 34 additions and 54 deletions

View File

@@ -23,6 +23,7 @@
#include "InsertElementTxn.h"
#include "nsIDOMSelection.h"
#include "nsIContent.h"
#include "nsIDOMNodeList.h"
#ifdef NS_DEBUG
static PRBool gNoisy = PR_FALSE;
@@ -78,37 +79,27 @@ NS_IMETHODIMP InsertElementTxn::Do(void)
if (!mNode || !mParent) return NS_ERROR_NOT_INITIALIZED;
nsresult result;
nsCOMPtr<nsIDOMNodeList> childNodes;
nsCOMPtr<nsIDOMNode>refNode;
//if (0!=mOffset)
{ // get a ref node
PRInt32 i=0;
result = mParent->GetFirstChild(getter_AddRefs(refNode));
if (NS_SUCCEEDED(result) && refNode)
{
for (; i<mOffset; i++)
{
nsCOMPtr<nsIDOMNode>nextSib;
result = refNode->GetNextSibling(getter_AddRefs(nextSib));
if (NS_FAILED(result)) {
break; // couldn't get a next sibling, so make aNode the first child
}
refNode = do_QueryInterface(nextSib);
if (!refNode) {
break; // couldn't get a next sibling, so make aNode the first child
}
}
}
nsresult result = mParent->GetChildNodes(getter_AddRefs(childNodes));
if (NS_FAILED(result)) return result;
if (childNodes)
{
PRUint32 count;
childNodes->GetLength(&count);
if (mOffset>count) mOffset = count;
result = childNodes->Item(mOffset, getter_AddRefs(refNode));
if (NS_FAILED(result)) return result;
// note, it's ok for mRefNode to be null. that means append
}
mEditor->MarkNodeDirty(mNode);
nsCOMPtr<nsIDOMNode> resultNode;
result = mParent->InsertBefore(mNode, refNode, getter_AddRefs(resultNode));
if (NS_FAILED(result)) return result;
if (!resultNode) return NS_ERROR_NULL_POINTER;
// Try to insert formatting whitespace for the new node:
mEditor->InsertFormattingForNode(resultNode);
// only set selection to insertion point if editor gives permission
PRBool bAdjustSelection;
mEditor->ShouldTxnSetSelection(&bAdjustSelection);