зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 9843839bf1df (bug 1406482) for mozilla::EditorBase::InsertTextImpl crashes
MozReview-Commit-ID: J7rX4lX2lxM
This commit is contained in:
Родитель
9c145b38f6
Коммит
5fee8a40bb
|
@ -2481,7 +2481,6 @@ EditorBase::FindBetterInsertionPoint(nsCOMPtr<nsINode>& aNode,
|
|||
nsresult
|
||||
EditorBase::InsertTextImpl(const nsAString& aStringToInsert,
|
||||
nsCOMPtr<nsINode>* aInOutNode,
|
||||
nsIContent* aChildAtOffset,
|
||||
int32_t* aInOutOffset,
|
||||
nsIDocument* aDoc)
|
||||
{
|
||||
|
@ -2513,15 +2512,14 @@ EditorBase::InsertTextImpl(const nsAString& aStringToInsert,
|
|||
|
||||
// If a neighboring text node already exists, use that
|
||||
if (!node->IsNodeOfType(nsINode::eTEXT)) {
|
||||
if (offset && aChildAtOffset &&
|
||||
aChildAtOffset->GetPreviousSibling() &&
|
||||
aChildAtOffset->GetPreviousSibling()->IsNodeOfType(nsINode::eTEXT)) {
|
||||
node = aChildAtOffset->GetPreviousSibling();
|
||||
nsIContent* child = node->GetChildAt(offset);
|
||||
if (offset && child && child->GetPreviousSibling() &&
|
||||
child->GetPreviousSibling()->IsNodeOfType(nsINode::eTEXT)) {
|
||||
node = child->GetPreviousSibling();
|
||||
offset = node->Length();
|
||||
} else if (offset < static_cast<int32_t>(node->Length()) &&
|
||||
aChildAtOffset &&
|
||||
aChildAtOffset->IsNodeOfType(nsINode::eTEXT)) {
|
||||
node = aChildAtOffset;
|
||||
child && child->IsNodeOfType(nsINode::eTEXT)) {
|
||||
node = child;
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,6 @@ public:
|
|||
|
||||
virtual nsresult InsertTextImpl(const nsAString& aStringToInsert,
|
||||
nsCOMPtr<nsINode>* aInOutNode,
|
||||
nsIContent* aChildAtOffset,
|
||||
int32_t* aInOutOffset,
|
||||
nsIDocument* aDoc);
|
||||
nsresult InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert,
|
||||
|
|
|
@ -1296,7 +1296,6 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
|||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
NS_ENSURE_STATE(aSelection->GetRangeAt(0));
|
||||
nsCOMPtr<nsINode> selNode = aSelection->GetRangeAt(0)->GetStartContainer();
|
||||
nsIContent* selChild = aSelection->GetRangeAt(0)->GetChildAtStartOffset();
|
||||
int32_t selOffset = aSelection->GetRangeAt(0)->StartOffset();
|
||||
NS_ENSURE_STATE(selNode);
|
||||
|
||||
|
@ -1321,14 +1320,13 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
|||
}
|
||||
if (inString->IsEmpty()) {
|
||||
rv = mHTMLEditor->InsertTextImpl(*inString, address_of(selNode),
|
||||
selChild, &selOffset, doc);
|
||||
&selOffset, doc);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
WSRunObject wsObj(mHTMLEditor, selNode, selOffset);
|
||||
rv = wsObj.InsertText(*inString, address_of(selNode), selChild,
|
||||
&selOffset, doc);
|
||||
rv = wsObj.InsertText(*inString, address_of(selNode), &selOffset, doc);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1400,7 +1398,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
|||
} else {
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
rv = mHTMLEditor->InsertTextImpl(subStr, address_of(curNode),
|
||||
selChild, &curOffset, doc);
|
||||
&curOffset, doc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
@ -1432,8 +1430,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
|||
// is it a tab?
|
||||
if (subStr.Equals(tabStr)) {
|
||||
rv =
|
||||
wsObj.InsertText(spacesStr, address_of(curNode), selChild,
|
||||
&curOffset, doc);
|
||||
wsObj.InsertText(spacesStr, address_of(curNode), &curOffset, doc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
pos++;
|
||||
}
|
||||
|
@ -1445,8 +1442,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
|||
NS_ENSURE_TRUE(br, NS_ERROR_FAILURE);
|
||||
pos++;
|
||||
} else {
|
||||
rv = wsObj.InsertText(subStr, address_of(curNode), selChild,
|
||||
&curOffset, doc);
|
||||
rv = wsObj.InsertText(subStr, address_of(curNode), &curOffset, doc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3118,7 +3118,6 @@ HTMLEditor::DeleteText(nsGenericDOMDataNode& aCharData,
|
|||
nsresult
|
||||
HTMLEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||
nsCOMPtr<nsINode>* aInOutNode,
|
||||
nsIContent* aChildAtOffset,
|
||||
int32_t* aInOutOffset,
|
||||
nsIDocument* aDoc)
|
||||
{
|
||||
|
@ -3127,8 +3126,8 @@ HTMLEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return EditorBase::InsertTextImpl(aStringToInsert, aInOutNode, aChildAtOffset,
|
||||
aInOutOffset, aDoc);
|
||||
return EditorBase::InsertTextImpl(aStringToInsert, aInOutNode, aInOutOffset,
|
||||
aDoc);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -313,7 +313,6 @@ public:
|
|||
uint32_t aLength);
|
||||
virtual nsresult InsertTextImpl(const nsAString& aStringToInsert,
|
||||
nsCOMPtr<nsINode>* aInOutNode,
|
||||
nsIContent* aChildAtOffset,
|
||||
int32_t* aInOutOffset,
|
||||
nsIDocument* aDoc) override;
|
||||
NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode* aNode) override;
|
||||
|
|
|
@ -726,7 +726,6 @@ TextEditRules::WillInsertText(EditAction aAction,
|
|||
// get the (collapsed) selection location
|
||||
NS_ENSURE_STATE(aSelection->GetRangeAt(0));
|
||||
nsCOMPtr<nsINode> selNode = aSelection->GetRangeAt(0)->GetStartContainer();
|
||||
nsIContent* selChild = aSelection->GetRangeAt(0)->GetChildAtStartOffset();
|
||||
int32_t selOffset = aSelection->GetRangeAt(0)->StartOffset();
|
||||
NS_ENSURE_STATE(selNode);
|
||||
|
||||
|
@ -754,7 +753,7 @@ TextEditRules::WillInsertText(EditAction aAction,
|
|||
selOffset = IMESelectionOffset;
|
||||
}
|
||||
rv = mTextEditor->InsertTextImpl(*outString, address_of(selNode),
|
||||
selChild, &selOffset, doc);
|
||||
&selOffset, doc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
// aAction == EditAction::insertText; find where we are
|
||||
|
@ -766,7 +765,7 @@ TextEditRules::WillInsertText(EditAction aAction,
|
|||
AutoTransactionsConserveSelection dontChangeMySelection(mTextEditor);
|
||||
|
||||
rv = mTextEditor->InsertTextImpl(*outString, address_of(curNode),
|
||||
selChild, &curOffset, doc);
|
||||
&curOffset, doc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (curNode) {
|
||||
|
|
|
@ -704,7 +704,6 @@ TextEditor::InsertLineBreak()
|
|||
// get the (collapsed) selection location
|
||||
NS_ENSURE_STATE(selection->GetRangeAt(0));
|
||||
nsCOMPtr<nsINode> selNode = selection->GetRangeAt(0)->GetStartContainer();
|
||||
nsIContent* selChild = selection->GetRangeAt(0)->GetChildAtStartOffset();
|
||||
int32_t selOffset = selection->GetRangeAt(0)->StartOffset();
|
||||
NS_ENSURE_STATE(selNode);
|
||||
|
||||
|
@ -723,7 +722,7 @@ TextEditor::InsertLineBreak()
|
|||
|
||||
// insert a linefeed character
|
||||
rv = InsertTextImpl(NS_LITERAL_STRING("\n"), address_of(selNode),
|
||||
selChild, &selOffset, doc);
|
||||
&selOffset, doc);
|
||||
if (!selNode) {
|
||||
rv = NS_ERROR_NULL_POINTER; // don't return here, so DidDoAction is called
|
||||
}
|
||||
|
|
|
@ -234,7 +234,6 @@ WSRunObject::InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
|
|||
nsresult
|
||||
WSRunObject::InsertText(const nsAString& aStringToInsert,
|
||||
nsCOMPtr<nsINode>* aInOutParent,
|
||||
nsIContent* aChildAtOffset,
|
||||
int32_t* aInOutOffset,
|
||||
nsIDocument* aDoc)
|
||||
{
|
||||
|
@ -357,8 +356,7 @@ WSRunObject::InsertText(const nsAString& aStringToInsert,
|
|||
}
|
||||
|
||||
// Ready, aim, fire!
|
||||
mHTMLEditor->InsertTextImpl(theString, aInOutParent, aChildAtOffset,
|
||||
aInOutOffset, aDoc);
|
||||
mHTMLEditor->InsertTextImpl(theString, aInOutParent, aInOutOffset, aDoc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,6 @@ public:
|
|||
// trailingws before {aInOutParent,aInOutOffset} needs to be removed.
|
||||
nsresult InsertText(const nsAString& aStringToInsert,
|
||||
nsCOMPtr<nsINode>* aInOutNode,
|
||||
nsIContent* aChildAtOffset,
|
||||
int32_t* aInOutOffset,
|
||||
nsIDocument* aDoc);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче