зеркало из https://github.com/mozilla/gecko-dev.git
backout fix for bug 386009 to see if it causes orange.
This commit is contained in:
Родитель
2f896221de
Коммит
2fd8467fdb
|
@ -94,18 +94,38 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||||
|
|
||||||
NS_ASSERTION(mEditor && mParent, "bad state");
|
NS_ASSERTION(mEditor && mParent, "bad state");
|
||||||
if (!mEditor || !mParent) return NS_ERROR_NOT_INITIALIZED;
|
if (!mEditor || !mParent) return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
// create a new node
|
||||||
|
nsAutoString textNodeTag;
|
||||||
|
nsresult result = nsEditor::GetTextNodeTag(textNodeTag);
|
||||||
|
if (NS_FAILED(result)) { return result; }
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> newContent;
|
if (textNodeTag == mTag)
|
||||||
|
{
|
||||||
//new call to use instead to get proper HTML element, bug# 39919
|
nsCOMPtr<nsIDOMDocument>doc;
|
||||||
nsresult result = mEditor->CreateHTMLContent(mTag, getter_AddRefs(newContent));
|
result = mEditor->GetDocument(getter_AddRefs(doc));
|
||||||
if (NS_FAILED(result)) return result;
|
if (NS_FAILED(result)) return result;
|
||||||
nsCOMPtr<nsIDOMElement>newElement = do_QueryInterface(newContent);
|
if (!doc) return NS_ERROR_NULL_POINTER;
|
||||||
if (!newElement) return NS_ERROR_NULL_POINTER;
|
|
||||||
mNewNode = do_QueryInterface(newElement);
|
const nsString stringData;
|
||||||
// Try to insert formatting whitespace for the new node:
|
nsCOMPtr<nsIDOMText>newTextNode;
|
||||||
mEditor->MarkNodeDirty(mNewNode);
|
result = doc->CreateTextNode(stringData, getter_AddRefs(newTextNode));
|
||||||
|
if (NS_FAILED(result)) return result;
|
||||||
|
if (!newTextNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
mNewNode = do_QueryInterface(newTextNode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIContent> newContent;
|
||||||
|
|
||||||
|
//new call to use instead to get proper HTML element, bug# 39919
|
||||||
|
result = mEditor->CreateHTMLContent(mTag, getter_AddRefs(newContent));
|
||||||
|
if (NS_FAILED(result)) return result;
|
||||||
|
nsCOMPtr<nsIDOMElement>newElement = do_QueryInterface(newContent);
|
||||||
|
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.");
|
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewNode)), "could not create element.");
|
||||||
if (!mNewNode) return NS_ERROR_NULL_POINTER;
|
if (!mNewNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
|
|
|
@ -2523,6 +2523,22 @@ NS_IMETHODIMP nsEditor::ScrollSelectionIntoView(PRBool aScrollToAnchor)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** static helper method */
|
||||||
|
nsresult nsEditor::GetTextNodeTag(nsAString& aOutString)
|
||||||
|
{
|
||||||
|
aOutString.Truncate();
|
||||||
|
static nsString *gTextNodeTag=nsnull;
|
||||||
|
if (!gTextNodeTag)
|
||||||
|
{
|
||||||
|
if ( (gTextNodeTag = new nsString) == 0 )
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
gTextNodeTag->AssignLiteral("special text node tag");
|
||||||
|
}
|
||||||
|
aOutString = *gTextNodeTag;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||||
nsCOMPtr<nsIDOMNode> *aInOutNode,
|
nsCOMPtr<nsIDOMNode> *aInOutNode,
|
||||||
PRInt32 *aInOutOffset,
|
PRInt32 *aInOutOffset,
|
||||||
|
|
|
@ -368,6 +368,10 @@ public:
|
||||||
nsresult RestorePreservedSelection(nsISelection *aSel);
|
nsresult RestorePreservedSelection(nsISelection *aSel);
|
||||||
void StopPreservingSelection();
|
void StopPreservingSelection();
|
||||||
|
|
||||||
|
|
||||||
|
/** return the string that represents text nodes in the content tree */
|
||||||
|
static nsresult GetTextNodeTag(nsAString& aOutString);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
|
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
|
||||||
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче