зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
23b339760b
Коммит
6c48f47e99
|
@ -7695,6 +7695,9 @@ HTMLEditRules::SplitParagraph(
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
WSRunObject::PrepareToSplitAcrossBlocks(&HTMLEditorRef(),
|
WSRunObject::PrepareToSplitAcrossBlocks(&HTMLEditorRef(),
|
||||||
address_of(selNode), &selOffset);
|
address_of(selNode), &selOffset);
|
||||||
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
}
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -7708,6 +7711,9 @@ HTMLEditRules::SplitParagraph(
|
||||||
aParentDivOrP,
|
aParentDivOrP,
|
||||||
EditorRawDOMPoint(selNode, selOffset),
|
EditorRawDOMPoint(selNode, selOffset),
|
||||||
SplitAtEdges::eAllowToCreateEmptyContainer);
|
SplitAtEdges::eAllowToCreateEmptyContainer);
|
||||||
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
}
|
||||||
if (NS_WARN_IF(splitDivOrPResult.Failed())) {
|
if (NS_WARN_IF(splitDivOrPResult.Failed())) {
|
||||||
return splitDivOrPResult.Rv();
|
return splitDivOrPResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -7719,6 +7725,9 @@ HTMLEditRules::SplitParagraph(
|
||||||
// prevent an empty p).
|
// prevent an empty p).
|
||||||
if (aNextBRNode && HTMLEditorRef().IsVisibleBRElement(aNextBRNode)) {
|
if (aNextBRNode && HTMLEditorRef().IsVisibleBRElement(aNextBRNode)) {
|
||||||
rv = HTMLEditorRef().DeleteNodeWithTransaction(*aNextBRNode);
|
rv = HTMLEditorRef().DeleteNodeWithTransaction(*aNextBRNode);
|
||||||
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
}
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -7727,6 +7736,9 @@ HTMLEditRules::SplitParagraph(
|
||||||
// Remove ID attribute on the paragraph from the existing right node.
|
// Remove ID attribute on the paragraph from the existing right node.
|
||||||
rv = HTMLEditorRef().RemoveAttributeWithTransaction(aParentDivOrP,
|
rv = HTMLEditorRef().RemoveAttributeWithTransaction(aParentDivOrP,
|
||||||
*nsGkAtoms::id);
|
*nsGkAtoms::id);
|
||||||
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
}
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -7753,12 +7765,18 @@ HTMLEditRules::SplitParagraph(
|
||||||
EditorRawDOMPoint atStartOfChild(child, 0);
|
EditorRawDOMPoint atStartOfChild(child, 0);
|
||||||
IgnoredErrorResult ignoredError;
|
IgnoredErrorResult ignoredError;
|
||||||
SelectionRef().Collapse(atStartOfChild, ignoredError);
|
SelectionRef().Collapse(atStartOfChild, ignoredError);
|
||||||
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
}
|
||||||
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
||||||
"Failed to collapse selection at the end of the child");
|
"Failed to collapse selection at the end of the child");
|
||||||
} else {
|
} else {
|
||||||
EditorRawDOMPoint atChild(child);
|
EditorRawDOMPoint atChild(child);
|
||||||
IgnoredErrorResult ignoredError;
|
IgnoredErrorResult ignoredError;
|
||||||
SelectionRef().Collapse(atChild, ignoredError);
|
SelectionRef().Collapse(atChild, ignoredError);
|
||||||
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
}
|
||||||
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
NS_WARNING_ASSERTION(!ignoredError.Failed(),
|
||||||
"Failed to collapse selection at the child");
|
"Failed to collapse selection at the child");
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,9 +397,10 @@ protected:
|
||||||
* removed.
|
* removed.
|
||||||
*/
|
*/
|
||||||
template<typename PT, typename CT>
|
template<typename PT, typename CT>
|
||||||
nsresult SplitParagraph(Element& aParentDivOrP,
|
MOZ_MUST_USE nsresult
|
||||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
SplitParagraph(Element& aParentDivOrP,
|
||||||
nsIContent* aBRNode);
|
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
||||||
|
nsIContent* aBRNode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReturnInListItem() handles insertParagraph command (i.e., handling
|
* ReturnInListItem() handles insertParagraph command (i.e., handling
|
||||||
|
|
Загрузка…
Ссылка в новой задаче