Bug 1620504 - part 6: Clean up warnings in DeleteNodeTransaction r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 09 Mar 2020 14:57:23 +0000
changeset 517708 9c9ad4a094e1a8a8951281ddd4883b8066117c45
parent 517707 5682b9bb1b301314959ecaa635762c9b3894a472
child 517709 a6d650d461d82b3929ed329e79b8c245c76d7832
push id37199
push useropoprus@mozilla.com
push dateTue, 10 Mar 2020 03:43:44 +0000
treeherdermozilla-central@6f21f98dcfcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1620504
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1620504 - part 6: Clean up warnings in DeleteNodeTransaction r=m_kato Depends on D65871 Differential Revision: https://phabricator.services.mozilla.com/D65872
editor/libeditor/DeleteNodeTransaction.cpp
--- a/editor/libeditor/DeleteNodeTransaction.cpp
+++ b/editor/libeditor/DeleteNodeTransaction.cpp
@@ -41,18 +41,17 @@ NS_INTERFACE_MAP_END_INHERITING(EditTran
 bool DeleteNodeTransaction::CanDoIt() const {
   if (NS_WARN_IF(!mNodeToDelete) || NS_WARN_IF(!mEditorBase) || !mParentNode ||
       !mEditorBase->IsModifiableNode(*mParentNode)) {
     return false;
   }
   return true;
 }
 
-NS_IMETHODIMP
-DeleteNodeTransaction::DoTransaction() {
+NS_IMETHODIMP DeleteNodeTransaction::DoTransaction() {
   if (NS_WARN_IF(!CanDoIt())) {
     return NS_OK;
   }
 
   if (!mEditorBase->AsHTMLEditor() && mNodeToDelete->IsText()) {
     uint32_t length = mNodeToDelete->AsText()->TextLength();
     if (length > 0) {
       mEditorBase->AsTextEditor()->WillDeleteText(length, 0, length);
@@ -65,62 +64,64 @@ DeleteNodeTransaction::DoTransaction() {
 
   // give range updater a chance.  SelAdjDeleteNode() needs to be called
   // *before* we do the action, unlike some of the other RangeItem update
   // methods.
   mEditorBase->RangeUpdaterRef().SelAdjDeleteNode(mNodeToDelete);
 
   ErrorResult error;
   mParentNode->RemoveChild(*mNodeToDelete, error);
+  NS_WARNING_ASSERTION(!error.Failed(), "nsINode::RemoveChild() failed");
   return error.StealNSResult();
 }
 
-MOZ_CAN_RUN_SCRIPT_BOUNDARY
-NS_IMETHODIMP
+MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP
 DeleteNodeTransaction::UndoTransaction() {
   if (NS_WARN_IF(!CanDoIt())) {
     // This is a legal state, the transaction is a no-op.
     return NS_OK;
   }
   ErrorResult error;
   RefPtr<EditorBase> editorBase = mEditorBase;
   nsCOMPtr<nsINode> parent = mParentNode;
   nsCOMPtr<nsINode> nodeToDelete = mNodeToDelete;
   nsCOMPtr<nsIContent> refNode = mRefNode;
   parent->InsertBefore(*nodeToDelete, refNode, error);
-  if (NS_WARN_IF(error.Failed())) {
+  if (error.Failed()) {
+    NS_WARNING("nsINode::InsertBefore() failed");
     return error.StealNSResult();
   }
   if (!editorBase->AsHTMLEditor() && nodeToDelete->IsText()) {
     uint32_t length = nodeToDelete->AsText()->TextLength();
     if (length > 0) {
-      error = MOZ_KnownLive(editorBase->AsTextEditor())
-                  ->DidInsertText(length, 0, length);
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
+      nsresult rv = MOZ_KnownLive(editorBase->AsTextEditor())
+                        ->DidInsertText(length, 0, length);
+      if (NS_FAILED(rv)) {
+        NS_WARNING("TextEditor::DidInsertText() failed");
+        return rv;
       }
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP
-DeleteNodeTransaction::RedoTransaction() {
+NS_IMETHODIMP DeleteNodeTransaction::RedoTransaction() {
   if (NS_WARN_IF(!CanDoIt())) {
     // This is a legal state, the transaction is a no-op.
     return NS_OK;
   }
 
   if (!mEditorBase->AsHTMLEditor() && mNodeToDelete->IsText()) {
     uint32_t length = mNodeToDelete->AsText()->TextLength();
     if (length > 0) {
       mEditorBase->AsTextEditor()->WillDeleteText(length, 0, length);
     }
   }
 
   mEditorBase->RangeUpdaterRef().SelAdjDeleteNode(mNodeToDelete);
 
   ErrorResult error;
   mParentNode->RemoveChild(*mNodeToDelete, error);
+  NS_WARNING_ASSERTION(!error.Failed(), "nsINode::RemoveChild() failed");
   return error.StealNSResult();
 }
 
 }  // namespace mozilla