зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1417344 - Clean up HTMLEditor::InsertBR. r=masayuki
No one uses out parameter of InsertBR, so we should remove it. Also, CreateBR has direction parameter for selection, so we should use it. MozReview-Commit-ID: 8heqaXpR9He --HG-- extra : rebase_source : 27b952f080a70fe039c9b43d7ae9f1394d4de01e
This commit is contained in:
Родитель
03e55255d3
Коммит
d85b9324d9
|
@ -954,8 +954,7 @@ HTMLEditor::TypedText(const nsAString& aString,
|
|||
|
||||
if (aAction == eTypedBR) {
|
||||
// only inserts a br node
|
||||
nsCOMPtr<nsIDOMNode> brNode;
|
||||
return InsertBR(address_of(brNode));
|
||||
return InsertBR();
|
||||
}
|
||||
|
||||
return TextEditor::TypedText(aString, aAction);
|
||||
|
@ -1062,11 +1061,8 @@ HTMLEditor::CreateBR(nsIDOMNode* aNode,
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
|
||||
HTMLEditor::InsertBR()
|
||||
{
|
||||
NS_ENSURE_TRUE(outBRNode, NS_ERROR_NULL_POINTER);
|
||||
*outBRNode = nullptr;
|
||||
|
||||
// calling it text insertion to trigger moz br treatment by rules
|
||||
AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
|
||||
|
||||
|
@ -1078,27 +1074,18 @@ HTMLEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> selNode;
|
||||
nsCOMPtr<nsINode> selNode;
|
||||
int32_t selOffset;
|
||||
nsresult rv =
|
||||
GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = CreateBR(selNode, selOffset, outBRNode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
selection->SetInterlinePosition(true);
|
||||
|
||||
// position selection after br
|
||||
nsCOMPtr<nsINode> brNode = do_QueryInterface(*outBRNode);
|
||||
if (NS_WARN_IF(!brNode)) {
|
||||
RefPtr<Element> br = CreateBR(selNode, selOffset, nsIEditor::eNext);
|
||||
if (NS_WARN_IF(!br)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
EditorRawDOMPoint afterBrNode(brNode);
|
||||
if (NS_WARN_IF(!afterBrNode.AdvanceOffset())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return selection->Collapse(afterBrNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -477,7 +477,7 @@ protected:
|
|||
nsCOMPtr<nsIDOMNode>* outBRNode,
|
||||
nsIEditor::EDirection aSelect = nsIEditor::eNone) override;
|
||||
|
||||
nsresult InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode);
|
||||
nsresult InsertBR();
|
||||
|
||||
// Table Editing (implemented in nsTableEditor.cpp)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче