Bug 1460509 - part 39: Make HTMLEditRules::SplitParagraph() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r=m_kato

MozReview-Commit-ID: 38hfUl88xXI

--HG--
extra : rebase_source : 7086a0f907487a74bc4656ec3f27fee99727af19
This commit is contained in:
Masayuki Nakano 2018-05-15 16:15:35 +09:00
Родитель 23b339760b
Коммит 6c48f47e99
2 изменённых файлов: 22 добавлений и 3 удалений

Просмотреть файл

@ -7695,6 +7695,9 @@ HTMLEditRules::SplitParagraph(
nsresult rv =
WSRunObject::PrepareToSplitAcrossBlocks(&HTMLEditorRef(),
address_of(selNode), &selOffset);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -7708,6 +7711,9 @@ HTMLEditRules::SplitParagraph(
aParentDivOrP,
EditorRawDOMPoint(selNode, selOffset),
SplitAtEdges::eAllowToCreateEmptyContainer);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(splitDivOrPResult.Failed())) {
return splitDivOrPResult.Rv();
}
@ -7719,6 +7725,9 @@ HTMLEditRules::SplitParagraph(
// prevent an empty p).
if (aNextBRNode && HTMLEditorRef().IsVisibleBRElement(aNextBRNode)) {
rv = HTMLEditorRef().DeleteNodeWithTransaction(*aNextBRNode);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -7727,6 +7736,9 @@ HTMLEditRules::SplitParagraph(
// Remove ID attribute on the paragraph from the existing right node.
rv = HTMLEditorRef().RemoveAttributeWithTransaction(aParentDivOrP,
*nsGkAtoms::id);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -7753,12 +7765,18 @@ HTMLEditRules::SplitParagraph(
EditorRawDOMPoint atStartOfChild(child, 0);
IgnoredErrorResult ignoredError;
SelectionRef().Collapse(atStartOfChild, ignoredError);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
NS_WARNING_ASSERTION(!ignoredError.Failed(),
"Failed to collapse selection at the end of the child");
} else {
EditorRawDOMPoint atChild(child);
IgnoredErrorResult ignoredError;
SelectionRef().Collapse(atChild, ignoredError);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
NS_WARNING_ASSERTION(!ignoredError.Failed(),
"Failed to collapse selection at the child");
}

Просмотреть файл

@ -397,9 +397,10 @@ protected:
* removed.
*/
template<typename PT, typename CT>
nsresult SplitParagraph(Element& aParentDivOrP,
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
nsIContent* aBRNode);
MOZ_MUST_USE nsresult
SplitParagraph(Element& aParentDivOrP,
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
nsIContent* aBRNode);
/**
* ReturnInListItem() handles insertParagraph command (i.e., handling