Bug 1446533 part 9. Remove nsIDOMCharacterData::ReplaceData. r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 19 Mar 2018 15:45:34 -0400
changeset 408825 b10a7fadaee8e081da9e3a3a01654983c8e479b7
parent 408824 e429f3715268cdf04045b30cc8e27aa8f8a939db
child 408826 6525e7ba0b1d25e045834a80cc2c441cb5429b14
push id101056
push userbzbarsky@mozilla.com
push dateMon, 19 Mar 2018 19:51:43 +0000
treeherdermozilla-inbound@1a0cc5a0be89 [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 9. Remove nsIDOMCharacterData::ReplaceData. r=mystor MozReview-Commit-ID: Lei6xZ2rw2K
dom/base/CharacterData.cpp
dom/base/CharacterData.h
dom/interfaces/core/nsIDOMCharacterData.idl
editor/libeditor/CompositionTransaction.cpp
editor/libeditor/TextEditRules.cpp
--- a/dom/base/CharacterData.cpp
+++ b/dom/base/CharacterData.cpp
@@ -236,22 +236,25 @@ void
 CharacterData::DeleteData(uint32_t aOffset, uint32_t aCount, ErrorResult& aRv)
 {
   nsresult rv = SetTextInternal(aOffset, aCount, nullptr, 0, true);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
 }
 
-nsresult
+void
 CharacterData::ReplaceData(uint32_t aOffset, uint32_t aCount,
-                           const nsAString& aData)
+                           const nsAString& aData, ErrorResult& aRv)
 {
-  return SetTextInternal(aOffset, aCount, aData.BeginReading(),
-                         aData.Length(), true);
+  nsresult rv = SetTextInternal(aOffset, aCount, aData.BeginReading(),
+                                aData.Length(), true);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+  }  
 }
 
 nsresult
 CharacterData::SetTextInternal(uint32_t aOffset, uint32_t aCount,
                                const char16_t* aBuffer,
                                uint32_t aLength, bool aNotify,
                                CharacterDataChangeInfo::Details* aDetails)
 {
--- a/dom/base/CharacterData.h
+++ b/dom/base/CharacterData.h
@@ -90,20 +90,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 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,
                                      bool aNotify) override;
   virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
                                             bool aNotify) override;
@@ -179,20 +175,17 @@ public:
   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);
   void ReplaceData(uint32_t aOffset, uint32_t aCount, const nsAString& aData,
-                   ErrorResult& rv)
-  {
-    rv = ReplaceData(aOffset, aCount, aData);
-  }
+                   ErrorResult& rv);
 
   uint32_t TextDataLength() const
   {
     return mText.GetLength();
   }
 
   //----------------------------------------
 
--- a/dom/interfaces/core/nsIDOMCharacterData.idl
+++ b/dom/interfaces/core/nsIDOMCharacterData.idl
@@ -11,13 +11,9 @@
  * 
  * 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                      replaceData(in unsigned long offset, 
-                                        in unsigned long count, 
-                                        in DOMString arg)
-                                  raises(DOMException);
 };
--- a/editor/libeditor/CompositionTransaction.cpp
+++ b/editor/libeditor/CompositionTransaction.cpp
@@ -108,20 +108,20 @@ CompositionTransaction::DoTransaction()
     mTextNode->InsertData(mOffset, mStringToInsert, rv);
     if (NS_WARN_IF(rv.Failed())) {
       return rv.StealNSResult();
     }
     mEditorBase->RangeUpdaterRef().
                    SelAdjInsertText(*mTextNode, mOffset, mStringToInsert);
   } else {
     uint32_t replaceableLength = mTextNode->TextLength() - mOffset;
-    nsresult rv =
-      mTextNode->ReplaceData(mOffset, mReplaceLength, mStringToInsert);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
+    ErrorResult rv;
+    mTextNode->ReplaceData(mOffset, mReplaceLength, mStringToInsert, rv);
+    if (NS_WARN_IF(rv.Failed())) {
+      return rv.StealNSResult();
     }
     mEditorBase->RangeUpdaterRef().
                    SelAdjDeleteText(mTextNode, mOffset, mReplaceLength);
     mEditorBase->RangeUpdaterRef().
                    SelAdjInsertText(*mTextNode, mOffset, mStringToInsert);
 
     // If IME text node is multiple node, ReplaceData doesn't remove all IME
     // text.  So we need remove remained text into other text node.
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -1616,17 +1616,18 @@ TextEditRules::HideLastPWInput()
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   uint32_t start, end;
   nsContentUtils::GetSelectionInTextControl(selection, mTextEditor->GetRoot(),
                                             start, end);
 
   nsCOMPtr<nsINode> selNode = GetTextNode(selection);
   NS_ENSURE_TRUE(selNode, NS_OK);
 
-  selNode->GetAsText()->ReplaceData(mLastStart, mLastLength, hiddenText);
+  selNode->GetAsText()->ReplaceData(mLastStart, mLastLength, hiddenText,
+                                    IgnoreErrors());
   // XXXbz Selection::Collapse/Extend take int32_t, but there are tons of
   // callsites... Converting all that is a battle for another day.
   selection->Collapse(selNode, start);
   if (start != end) {
     selection->Extend(selNode, end);
   }
   return NS_OK;
 }