Bug 1460509 - part 34: Make HTMLEditRules::MaybeSplitAncestorsForInsertWithTransaction() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r?m_kato
MozReview-Commit-ID: 7MqtKPNAOZ1
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -8380,16 +8380,19 @@ HTMLEditRules::MaybeSplitAncestorsForIns
return SplitNodeResult(aStartOfDeepestRightNode);
}
SplitNodeResult splitNodeResult =
HTMLEditorRef().SplitNodeDeepWithTransaction(
*pointToInsert.GetChild(),
aStartOfDeepestRightNode,
SplitAtEdges::eAllowToCreateEmptyContainer);
+ if (NS_WARN_IF(!CanHandleEditAction())) {
+ return SplitNodeResult(NS_ERROR_EDITOR_DESTROYED);
+ }
NS_WARNING_ASSERTION(splitNodeResult.Succeeded(),
"Failed to split the node for insert the element");
return splitNodeResult;
}
nsresult
HTMLEditRules::JoinNearestEditableNodesWithTransaction(
nsIContent& aNodeLeft,
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -523,19 +523,19 @@ protected:
* after calling this method.
* @param aStartOfDeepestRightNode The start point of deepest right node.
* This point must be descendant of
* active editing host.
* @return When succeeded, SplitPoint() returns
* the point to insert the element.
*/
template<typename PT, typename CT>
- SplitNodeResult MaybeSplitAncestorsForInsertWithTransaction(
- nsAtom& aTag,
- const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode);
+ MOZ_MUST_USE SplitNodeResult
+ MaybeSplitAncestorsForInsertWithTransaction(
+ nsAtom& aTag, const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode);
/**
* JoinNearestEditableNodesWithTransaction() joins two editable nodes which
* are themselves or the nearest editable node of aLeftNode and aRightNode.
* XXX This method's behavior is odd. For example, if user types Backspace
* key at the second editable paragraph in this case:
* <div contenteditable>
* <p>first editable paragraph</p>