Bug 1447889 part 12. Remove nsIDOMRange::ToString. r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 27 Mar 2018 00:35:22 -0400
changeset 466222 dedb54f89b3de53965cf9577108e0305e5bb1f77
parent 466221 4abb3e23e0c5106da9c634e0ccd9e27400981fc0
child 466223 e97a30657dfe6610578993680b60ccce201fe518
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1447889
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 1447889 part 12. Remove nsIDOMRange::ToString. r=mystor MozReview-Commit-ID: 8TDYC3f4ENn
dom/base/nsContentAreaDragDrop.cpp
dom/base/nsRange.cpp
dom/base/nsRange.h
dom/interfaces/range/nsIDOMRange.idl
dom/webidl/Range.webidl
--- a/dom/base/nsContentAreaDragDrop.cpp
+++ b/dom/base/nsContentAreaDragDrop.cpp
@@ -353,17 +353,17 @@ DragDataProducer::GetNodeString(nsIConte
 
   outNodeString.Truncate();
 
   // use a range to get the text-equivalent of the node
   nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
   RefPtr<nsRange> range = doc->CreateRange(IgnoreErrors());
   if (range) {
     range->SelectNode(*node, IgnoreErrors());
-    range->ToString(outNodeString);
+    range->ToString(outNodeString, IgnoreErrors());
   }
 }
 
 nsresult
 DragDataProducer::Produce(DataTransfer* aDataTransfer,
                           bool* aCanDrag,
                           nsISelection** aSelection,
                           nsIContent** aDragNode,
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -2956,25 +2956,25 @@ nsRange::SurroundContents(nsINode& aNewP
     return;
   }
 
   // Select aNewParent, and its contents.
 
   SelectNode(aNewParent, aRv);
 }
 
-NS_IMETHODIMP
-nsRange::ToString(nsAString& aReturn)
+void
+nsRange::ToString(nsAString& aReturn, ErrorResult& aErr)
 {
   // clear the string
   aReturn.Truncate();
 
   // If we're unpositioned, return the empty string
   if (!mIsPositioned) {
-    return NS_OK;
+    return;
   }
 
 #ifdef DEBUG_range
       printf("Range dump: -----------------------\n");
 #endif /* DEBUG */
 
   // effeciency hack for simple case
   if (mStart.Container() == mEnd.Container()) {
@@ -2984,33 +2984,32 @@ nsRange::ToString(nsAString& aReturn)
     {
 #ifdef DEBUG_range
       // If debug, dump it:
       textNode->List(stdout);
       printf("End Range dump: -----------------------\n");
 #endif /* DEBUG */
 
       // grab the text
-      IgnoredErrorResult rv;
       textNode->SubstringData(mStart.Offset(), mEnd.Offset() - mStart.Offset(),
-                              aReturn, rv);
-      if (rv.Failed()) {
-        return NS_ERROR_UNEXPECTED;
-      }
-      return NS_OK;
+                              aReturn, aErr);
+      return;
     }
   }
 
   /* complex case: mStart.Container() != mEnd.Container(), or mStartParent not a text
      node revisit - there are potential optimizations here and also tradeoffs.
   */
 
   nsCOMPtr<nsIContentIterator> iter = NS_NewContentIterator();
   nsresult rv = iter->Init(this);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    aErr.Throw(rv);
+    return;
+  }
 
   nsString tempString;
 
   // loop through the content iterator, which returns nodes in the range in
   // close tag order, and grab the text from any text node
   while (!iter->IsDone())
   {
     nsINode *n = iter->GetCurrentNode();
@@ -3037,21 +3036,18 @@ nsRange::ToString(nsAString& aReturn)
     }
 
     iter->Next();
   }
 
 #ifdef DEBUG_range
   printf("End Range dump: -----------------------\n");
 #endif /* DEBUG */
-  return NS_OK;
 }
 
-
-
 NS_IMETHODIMP
 nsRange::Detach()
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsRange::CreateContextualFragment(const nsAString& aFragment,
--- a/dom/base/nsRange.h
+++ b/dom/base/nsRange.h
@@ -327,16 +327,17 @@ public:
   uint32_t GetEndOffset(ErrorResult& aRv) const;
   void InsertNode(nsINode& aNode, ErrorResult& aErr);
   bool IntersectsNode(nsINode& aNode, ErrorResult& aRv);
   bool IsPointInRange(nsINode& aContainer, uint32_t aOffset, ErrorResult& aErr)
   {
     return IsPointInRange(RawRangeBoundary(&aContainer, aOffset), aErr);
   }
   bool IsPointInRange(const RawRangeBoundary& aPoint, ErrorResult& aErr);
+  void ToString(nsAString& aReturn, ErrorResult& aErr);
 
   // *JS() methods are mapped to Range.*() of DOM.
   // They may move focus only when the range represents normal selection.
   // These methods shouldn't be used from internal.
   void CollapseJS(bool aToStart);
   void SelectNodeJS(nsINode& aNode, ErrorResult& aErr);
   void SelectNodeContentsJS(nsINode& aNode, ErrorResult& aErr);
   void SetEndJS(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr);
--- a/dom/interfaces/range/nsIDOMRange.idl
+++ b/dom/interfaces/range/nsIDOMRange.idl
@@ -21,17 +21,16 @@ interface nsIDOMRange : nsISupports
   void               setStartAfter(in nsIDOMNode refNode);
   void               setEndBefore(in nsIDOMNode refNode);
   void               setEndAfter(in nsIDOMNode refNode);
 
   nsIDOMDocumentFragment extractContents();
   nsIDOMDocumentFragment cloneContents();
   void               insertNode(in nsIDOMNode newNode);
   void               surroundContents(in nsIDOMNode newParent);
-  DOMString          toString();
   void               detach();
   
   // This method comes from
   // http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface
   nsIDOMDocumentFragment    createContextualFragment(in DOMString fragment);
 
   // This returns true if parent+offset equals either
   // of the boundary points or is between them.
--- a/dom/webidl/Range.webidl
+++ b/dom/webidl/Range.webidl
@@ -68,16 +68,17 @@ interface Range {
   [Throws]
   boolean isPointInRange(Node node, unsigned long offset);
   [Throws]
   short comparePoint(Node node, unsigned long offset);
 
   [Throws]
   boolean intersectsNode(Node node);
 
+  [Throws]
   stringifier;
 };
 
 // http://domparsing.spec.whatwg.org/#dom-range-createcontextualfragment
 partial interface Range {
   [CEReactions, Throws]
   DocumentFragment createContextualFragment(DOMString fragment);
 };