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:
parent
7286e61a81
commit
13c14e71dc
@ -108,6 +108,8 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!newElement) return NS_ERROR_NULL_POINTER;
|
||||
mNewNode = do_QueryInterface(newElement);
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditor->MarkNodeDirty(mNewNode);
|
||||
}
|
||||
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewNode)), "could not create element.");
|
||||
if (!mNewNode) return NS_ERROR_NULL_POINTER;
|
||||
@ -135,9 +137,6 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
||||
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditor->InsertFormattingForNode(mNewNode);
|
||||
|
||||
// only set selection to insertion point if editor gives permission
|
||||
PRBool bAdjustSelection;
|
||||
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -108,6 +108,8 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!newElement) return NS_ERROR_NULL_POINTER;
|
||||
mNewNode = do_QueryInterface(newElement);
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditor->MarkNodeDirty(mNewNode);
|
||||
}
|
||||
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewNode)), "could not create element.");
|
||||
if (!mNewNode) return NS_ERROR_NULL_POINTER;
|
||||
@ -135,9 +137,6 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
||||
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditor->InsertFormattingForNode(mNewNode);
|
||||
|
||||
// only set selection to insertion point if editor gives permission
|
||||
PRBool bAdjustSelection;
|
||||
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -393,11 +393,11 @@ public:
|
||||
NS_IMETHOD InsertNoneditableTextNode(nsIDOMNode* aParent, PRInt32 aOffset,
|
||||
nsString& aStr) = 0;
|
||||
/**
|
||||
* InsertFormattingForNode() inserts formatting before and/or after a node.
|
||||
* InsertFormattingForNode() sets a special dirty attribute on the node.
|
||||
* Usually this will be called immediately after creating a new node.
|
||||
* @param aNode The node for which to insert formatting.
|
||||
*/
|
||||
NS_IMETHOD InsertFormattingForNode(nsIDOMNode* aNode) = 0;
|
||||
NS_IMETHOD MarkNodeDirty(nsIDOMNode* aNode) = 0;
|
||||
|
||||
/* ------------ Output methods -------------- */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user