Bug 1446533 part 8. Remove nsIDOMCharacterData::DeleteData. r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 19 Mar 2018 15:45:31 -0400
changeset 408873 e429f3715268cdf04045b30cc8e27aa8f8a939db
parent 408872 3e3ac3c3b9893746b775c682d564fba950a3a55b
child 408874 b10a7fadaee8e081da9e3a3a01654983c8e479b7
push id33663
push userapavel@mozilla.com
push dateMon, 19 Mar 2018 22:40:21 +0000
treeherdermozilla-central@bfb7edfd0436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1446533
milestone61.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 1446533 part 8. Remove nsIDOMCharacterData::DeleteData. r=mystor MozReview-Commit-ID: 7100YyU5jOG
dom/base/CharacterData.cpp
dom/base/CharacterData.h
dom/base/nsRange.cpp
dom/interfaces/core/nsIDOMCharacterData.idl
editor/libeditor/CompositionTransaction.cpp
editor/libeditor/EditorBase.cpp
editor/libeditor/InsertTextTransaction.cpp
editor/libeditor/JoinNodeTransaction.cpp
editor/libeditor/SplitNodeTransaction.cpp
--- a/dom/base/CharacterData.cpp
+++ b/dom/base/CharacterData.cpp
@@ -227,20 +227,23 @@ CharacterData::InsertData(uint32_t aOffs
 {
   nsresult rv = SetTextInternal(aOffset, 0, aData.BeginReading(),
                                 aData.Length(), true);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
 }
 
-nsresult
-CharacterData::DeleteData(uint32_t aOffset, uint32_t aCount)
+void
+CharacterData::DeleteData(uint32_t aOffset, uint32_t aCount, ErrorResult& aRv)
 {
-  return SetTextInternal(aOffset, aCount, nullptr, 0, true);
+  nsresult rv = SetTextInternal(aOffset, aCount, nullptr, 0, true);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+  }
 }
 
 nsresult
 CharacterData::ReplaceData(uint32_t aOffset, uint32_t aCount,
                            const nsAString& aData)
 {
   return SetTextInternal(aOffset, aCount, aData.BeginReading(),
                          aData.Length(), true);
--- a/dom/base/CharacterData.h
+++ b/dom/base/CharacterData.h
@@ -91,17 +91,16 @@ public:
 
   NS_IMPL_FROMCONTENT_HELPER(CharacterData, IsCharacterData())
 
   virtual void GetNodeValueInternal(nsAString& aNodeValue) override;
   virtual void SetNodeValueInternal(const nsAString& aNodeValue,
                                     ErrorResult& aError) override;
 
   // Implementation for nsIDOMCharacterData
-  nsresult DeleteData(uint32_t aOffset, uint32_t aCount);
   nsresult ReplaceData(uint32_t aOffset, uint32_t aCount,
                        const nsAString& aArg);
 
   // nsINode methods
   virtual uint32_t GetChildCount() const override;
   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
   virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
   virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
@@ -178,20 +177,17 @@ public:
   // WebIDL API
   void GetData(nsAString& aData) const;
   virtual void SetData(const nsAString& aData, ErrorResult& rv);
   // nsINode::Length() returns the right thing for our length attribute
   void SubstringData(uint32_t aStart, uint32_t aCount, nsAString& aReturn,
                      ErrorResult& rv);
   void AppendData(const nsAString& aData, ErrorResult& rv);
   void InsertData(uint32_t aOffset, const nsAString& aData, ErrorResult& rv);
-  void DeleteData(uint32_t aOffset, uint32_t aCount, ErrorResult& rv)
-  {
-    rv = DeleteData(aOffset, aCount);
-  }
+  void DeleteData(uint32_t aOffset, uint32_t aCount, ErrorResult& rv);
   void ReplaceData(uint32_t aOffset, uint32_t aCount, const nsAString& aData,
                    ErrorResult& rv)
   {
     rv = ReplaceData(aOffset, aCount, aData);
   }
 
   uint32_t TextDataLength() const
   {
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -2313,18 +2313,21 @@ nsRange::CutContents(DocumentFragment** 
               clone->SetNodeValue(cutValue, err);
               if (NS_WARN_IF(err.Failed())) {
                 return err.StealNSResult();
               }
               nodeToResult = clone;
             }
 
             nsMutationGuard guard;
-            rv = charData->DeleteData(startOffset, endOffset - startOffset);
-            NS_ENSURE_SUCCESS(rv, rv);
+            ErrorResult err;
+            charData->DeleteData(startOffset, endOffset - startOffset, err);
+            if (NS_WARN_IF(err.Failed())) {
+              return err.StealNSResult();
+            }
             NS_ENSURE_STATE(!guard.Mutated(0) ||
                             ValidateCurrentNode(this, iter));
           }
 
           handled = true;
         }
         else  {
           // Delete or extract everything after startOffset.
@@ -2346,17 +2349,21 @@ nsRange::CutContents(DocumentFragment** 
               clone->SetNodeValue(cutValue, err);
               if (NS_WARN_IF(err.Failed())) {
                 return err.StealNSResult();
               }
               nodeToResult = clone;
             }
 
             nsMutationGuard guard;
-            rv = charData->DeleteData(startOffset, dataLength);
+            ErrorResult err;
+            charData->DeleteData(startOffset, dataLength, err);
+            if (NS_WARN_IF(err.Failed())) {
+              return err.StealNSResult();
+            }
             NS_ENSURE_SUCCESS(rv, rv);
             NS_ENSURE_STATE(!guard.Mutated(0) ||
                             ValidateCurrentNode(this, iter));
           }
 
           handled = true;
         }
       }
@@ -2376,18 +2383,21 @@ nsRange::CutContents(DocumentFragment** 
           clone->SetNodeValue(cutValue, err);
           if (NS_WARN_IF(err.Failed())) {
             return err.StealNSResult();
           }
           nodeToResult = clone;
         }
 
         nsMutationGuard guard;
-        rv = charData->DeleteData(0, endOffset);
-        NS_ENSURE_SUCCESS(rv, rv);
+        ErrorResult err;
+        charData->DeleteData(0, endOffset, err);
+        if (NS_WARN_IF(err.Failed())) {
+          return err.StealNSResult();
+        }
         NS_ENSURE_STATE(!guard.Mutated(0) ||
                         ValidateCurrentNode(this, iter));
         handled = true;
       }
     }
 
     if (!handled && (node == endContainer || node == startContainer)) {
       if (node && node->IsElement() &&
@@ -2720,30 +2730,30 @@ nsRange::CloneContents(ErrorResult& aRv)
     {
       if (node == mEnd.Container()) {
         // We only need the data before mEndOffset, so get rid of any
         // data after it.
 
         uint32_t dataLength = charData->Length();
         if (dataLength > (uint32_t)mEnd.Offset())
         {
-          aRv = charData->DeleteData(mEnd.Offset(), dataLength - mEnd.Offset());
+          charData->DeleteData(mEnd.Offset(), dataLength - mEnd.Offset(), aRv);
           if (aRv.Failed()) {
             return nullptr;
           }
         }
       }
 
       if (node == mStart.Container()) {
         // We don't need any data before mStartOffset, so just
         // delete it!
 
         if (mStart.Offset() > 0)
         {
-          aRv = charData->DeleteData(0, mStart.Offset());
+          charData->DeleteData(0, mStart.Offset(), aRv);
           if (aRv.Failed()) {
             return nullptr;
           }
         }
       }
     }
 
     // Clone the parent hierarchy between commonAncestor and node.
--- a/dom/interfaces/core/nsIDOMCharacterData.idl
+++ b/dom/interfaces/core/nsIDOMCharacterData.idl
@@ -11,16 +11,13 @@
  * 
  * For more information on this interface please see 
  * http://www.w3.org/TR/DOM-Level-2-Core/
  */
 
 [uuid(4109a2d2-e7af-445d-bb72-c7c9b875f35e)]
 interface nsIDOMCharacterData : nsIDOMNode
 {
-  void                      deleteData(in unsigned long offset, 
-                                       in unsigned long count)
-                                  raises(DOMException);
   void                      replaceData(in unsigned long offset, 
                                         in unsigned long count, 
                                         in DOMString arg)
                                   raises(DOMException);
 };
--- a/editor/libeditor/CompositionTransaction.cpp
+++ b/editor/libeditor/CompositionTransaction.cpp
@@ -127,17 +127,17 @@ CompositionTransaction::DoTransaction()
     // text.  So we need remove remained text into other text node.
     if (replaceableLength < mReplaceLength) {
       int32_t remainLength = mReplaceLength - replaceableLength;
       nsCOMPtr<nsINode> node = mTextNode->GetNextSibling();
       while (node && node->IsNodeOfType(nsINode::eTEXT) &&
              remainLength > 0) {
         Text* text = static_cast<Text*>(node.get());
         uint32_t textLength = text->TextLength();
-        text->DeleteData(0, remainLength);
+        text->DeleteData(0, remainLength, IgnoreErrors());
         mEditorBase->RangeUpdaterRef().SelAdjDeleteText(text, 0, remainLength);
         remainLength -= textLength;
         node = node->GetNextSibling();
       }
     }
   }
 
   nsresult rv = SetSelectionForRanges();
@@ -153,21 +153,24 @@ CompositionTransaction::UndoTransaction(
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Get the selection first so we'll fail before making any changes if we
   // can't get it
   RefPtr<Selection> selection = mEditorBase->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
-  nsresult rv = mTextNode->DeleteData(mOffset, mStringToInsert.Length());
-  NS_ENSURE_SUCCESS(rv, rv);
+  ErrorResult err;
+  mTextNode->DeleteData(mOffset, mStringToInsert.Length(), err);
+  if (NS_WARN_IF(err.Failed())) {
+    return err.StealNSResult();
+  }
 
   // set the selection to the insertion point where the string was removed
-  rv = selection->Collapse(mTextNode, mOffset);
+  nsresult rv = selection->Collapse(mTextNode, mOffset);
   NS_ASSERTION(NS_SUCCEEDED(rv),
                "Selection could not be collapsed after undo of IME insert.");
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -3217,17 +3217,17 @@ EditorBase::SplitNodeImpl(const EditorDO
     // If it's a text node, just shuffle around some text
     Text* rightAsText = aStartOfRightNode.GetContainerAsText();
     Text* leftAsText = aNewLeftNode.GetAsText();
     if (rightAsText && leftAsText) {
       // Fix right node
       nsAutoString leftText;
       rightAsText->SubstringData(0, aStartOfRightNode.Offset(),
                                  leftText, IgnoreErrors());
-      rightAsText->DeleteData(0, aStartOfRightNode.Offset());
+      rightAsText->DeleteData(0, aStartOfRightNode.Offset(), IgnoreErrors());
       // Fix left node
       leftAsText->GetAsText()->SetData(leftText, IgnoreErrors());
     } else {
       MOZ_DIAGNOSTIC_ASSERT(!rightAsText && !leftAsText);
       // Otherwise it's an interior node, so shuffle around the children. Go
       // through list backwards so deletes don't interfere with the iteration.
       if (!firstChildOfRightNode) {
         MoveAllChildren(*aStartOfRightNode.GetContainer(),
--- a/editor/libeditor/InsertTextTransaction.cpp
+++ b/editor/libeditor/InsertTextTransaction.cpp
@@ -88,17 +88,19 @@ InsertTextTransaction::DoTransaction()
                  SelAdjInsertText(*mTextNode, mOffset, mStringToInsert);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 InsertTextTransaction::UndoTransaction()
 {
-  return mTextNode->DeleteData(mOffset, mStringToInsert.Length());
+  ErrorResult rv;
+  mTextNode->DeleteData(mOffset, mStringToInsert.Length(), rv);
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 InsertTextTransaction::Merge(nsITransaction* aTransaction,
                              bool* aDidMerge)
 {
   if (!aTransaction || !aDidMerge) {
     return NS_OK;
--- a/editor/libeditor/JoinNodeTransaction.cpp
+++ b/editor/libeditor/JoinNodeTransaction.cpp
@@ -101,17 +101,20 @@ JoinNodeTransaction::UndoTransaction()
       NS_WARN_IF(!mLeftNode) ||
       NS_WARN_IF(!mRightNode)) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // First, massage the existing node so it is in its post-split state
   ErrorResult rv;
   if (mRightNode->GetAsText()) {
-    rv = mRightNode->GetAsText()->DeleteData(0, mOffset);
+    mRightNode->GetAsText()->DeleteData(0, mOffset, rv);
+    if (rv.Failed()) {
+      return rv.StealNSResult();
+    }
   } else {
     nsCOMPtr<nsIContent> child = mRightNode->GetFirstChild();
     for (uint32_t i = 0; i < mOffset; i++) {
       if (rv.Failed()) {
         return rv.StealNSResult();
       }
       if (!child) {
         return NS_ERROR_NULL_POINTER;
--- a/editor/libeditor/SplitNodeTransaction.cpp
+++ b/editor/libeditor/SplitNodeTransaction.cpp
@@ -140,20 +140,20 @@ SplitNodeTransaction::RedoTransaction()
       NS_WARN_IF(!mStartOfRightNode.IsSet())) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // First, massage the existing node so it is in its post-split state
   if (mStartOfRightNode.IsInTextNode()) {
     Text* rightNodeAsText = mStartOfRightNode.GetContainerAsText();
     MOZ_DIAGNOSTIC_ASSERT(rightNodeAsText);
-    nsresult rv =
-      rightNodeAsText->DeleteData(0, mStartOfRightNode.Offset());
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
+    ErrorResult rv;
+    rightNodeAsText->DeleteData(0, mStartOfRightNode.Offset(), rv);
+    if (NS_WARN_IF(rv.Failed())) {
+      return rv.StealNSResult();
     }
   } else {
     nsCOMPtr<nsIContent> child =
       mStartOfRightNode.GetContainer()->GetFirstChild();
     nsCOMPtr<nsIContent> nextSibling;
     for (uint32_t i = 0; i < mStartOfRightNode.Offset(); i++) {
       // XXX This must be bad behavior.  Perhaps, we should work with
       //     mStartOfRightNode::GetChild().  Even if some children