Bug 1460509 - part 76: Mark HTMLEditRules::MoveContents() as MOZ_MUST_USE since it may return NS_ERROR_EDITOR_DESTROYED r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 17 May 2018 23:52:47 +0900
changeset 798794 42b5fcdcebaef787f5746fe750a1f8df5f5ad84c
parent 798793 2790be26fe1665a79b37887ebd6123a7939beaaa
child 798795 97f28b39d4d325c7f74c0a1f24118e9a65fa4e87
push id110840
push usermasayuki@d-toybox.com
push dateWed, 23 May 2018 13:41:58 +0000
reviewersm_kato
bugs1460509
milestone62.0a1
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
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditRules.h
--- 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.