Bug 1460509 - part 76: Mark HTMLEditRules::MoveContents() as MOZ_MUST_USE since it may return NS_ERROR_EDITOR_DESTROYED r?m_kato
MozReview-Commit-ID: gBAssBJfrF
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -3539,16 +3539,21 @@ HTMLEditRules::TryToJoinBlocksWithTransa
CheckForInvisibleBR(*leftBlock, BRLocation::beforeBlock,
leftBlockChild.Offset());
EditActionResult ret(NS_OK);
if (mergeLists) {
// XXX Why do we ignore the result of MoveContents()?
int32_t offset = leftBlockChild.Offset();
EditActionResult retMoveContents =
MoveContents(*rightList, *leftList, &offset);
+ if (NS_WARN_IF(retMoveContents.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
+ return ret;
+ }
+ NS_WARNING_ASSERTION(retMoveContents.Succeeded(),
+ "Failed to move contents from the right list to the left list");
if (retMoveContents.Handled()) {
ret.MarkAsHandled();
}
// leftBlockChild was moved to rightList. So, it's invalid now.
leftBlockChild.Clear();
} else {
// Left block is a parent of right block, and the parent of the previous
// visible content. Right block is a child and contains the contents we
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -318,18 +318,19 @@ protected:
* MoveContents() moves the contents of aElement to (aDestElement,
* aInOutDestOffset). DTD containment rules are followed throughout.
*
* @param aInOutDestOffset updated to point after inserted content.
* @return Sets true to handled if this actually moves
* the nodes.
* canceled is always false.
*/
- EditActionResult MoveContents(Element& aElement, Element& aDestElement,
- int32_t* aInOutDestOffset);
+ MOZ_MUST_USE EditActionResult
+ MoveContents(Element& aElement, Element& aDestElement,
+ int32_t* aInOutDestOffset);
/**
* DeleteElementsExceptTableRelatedElements() removes elements except
* table related elements (except <table> itself) and their contents
* from the DOM tree.
*
* @param aNode If this is not a table related element, this
* node will be removed from the DOM tree.