зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1417344 - Clean up HTMLEditor::InsertBR. r=masayuki on a CLOSED TREE
--HG-- extra : amend_source : bae27242fcf6e011ba4d1b5e11b5e02a1ddd3bb9
This commit is contained in:
Родитель
2d464b0cf6
Коммит
090fe8ebd5
|
@ -954,8 +954,7 @@ HTMLEditor::TypedText(const nsAString& aString,
|
||||||
|
|
||||||
if (aAction == eTypedBR) {
|
if (aAction == eTypedBR) {
|
||||||
// only inserts a br node
|
// only inserts a br node
|
||||||
nsCOMPtr<nsIDOMNode> brNode;
|
return InsertBR();
|
||||||
return InsertBR(address_of(brNode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TextEditor::TypedText(aString, aAction);
|
return TextEditor::TypedText(aString, aAction);
|
||||||
|
@ -1062,11 +1061,8 @@ HTMLEditor::CreateBR(nsIDOMNode* aNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
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
|
// calling it text insertion to trigger moz br treatment by rules
|
||||||
AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
|
AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
|
||||||
|
|
||||||
|
@ -1078,27 +1074,18 @@ HTMLEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> selNode;
|
nsCOMPtr<nsINode> selNode;
|
||||||
int32_t selOffset;
|
int32_t selOffset;
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = CreateBR(selNode, selOffset, outBRNode);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
selection->SetInterlinePosition(true);
|
|
||||||
|
|
||||||
// position selection after br
|
// position selection after br
|
||||||
nsCOMPtr<nsINode> brNode = do_QueryInterface(*outBRNode);
|
RefPtr<Element> br = CreateBR(selNode, selOffset, nsIEditor::eNext);
|
||||||
if (NS_WARN_IF(!brNode)) {
|
if (NS_WARN_IF(!br)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
EditorRawDOMPoint afterBrNode(brNode);
|
return NS_OK;
|
||||||
if (NS_WARN_IF(!afterBrNode.AdvanceOffset())) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
return selection->Collapse(afterBrNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -477,7 +477,7 @@ protected:
|
||||||
nsCOMPtr<nsIDOMNode>* outBRNode,
|
nsCOMPtr<nsIDOMNode>* outBRNode,
|
||||||
nsIEditor::EDirection aSelect = nsIEditor::eNone) override;
|
nsIEditor::EDirection aSelect = nsIEditor::eNone) override;
|
||||||
|
|
||||||
nsresult InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode);
|
nsresult InsertBR();
|
||||||
|
|
||||||
// Table Editing (implemented in nsTableEditor.cpp)
|
// Table Editing (implemented in nsTableEditor.cpp)
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче