Bug 1446533 part 6. Remove nsIDOMCharacterData::GetLength r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 19 Mar 2018 15:33:28 -0400
changeset 408821 1182d32f823ece8fdf519d4722134f2746a26d6a
parent 408820 87162a82c06235c8b42a7d248bb22e5ee5d06fb9
child 408822 c4984d2a063a21b0f04acd61e5641fef1d9118fa
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 6. Remove nsIDOMCharacterData::GetLength r=mystor MozReview-Commit-ID: FCBGyqPfC4B
dom/base/CharacterData.cpp
dom/base/CharacterData.h
dom/base/nsRange.cpp
dom/interfaces/core/nsIDOMCharacterData.idl
dom/xslt/xpath/XPathExpression.cpp
--- a/dom/base/CharacterData.cpp
+++ b/dom/base/CharacterData.cpp
@@ -179,23 +179,16 @@ CharacterData::SetData(const nsAString& 
 {
   nsresult rv = SetTextInternal(0, mText.GetLength(), aData.BeginReading(),
                                 aData.Length(), true);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
 }
 
-nsresult
-CharacterData::GetLength(uint32_t* aLength)
-{
-  *aLength = mText.GetLength();
-  return NS_OK;
-}
-
 void
 CharacterData::SubstringData(uint32_t aStart, uint32_t aCount,
                              nsAString& aReturn, ErrorResult& rv)
 {
   aReturn.Truncate();
 
   uint32_t textLength = mText.GetLength();
   if (aStart > textLength) {
--- 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 GetLength(uint32_t* aLength);
   nsresult InsertData(uint32_t aOffset, const nsAString& aArg);
   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;
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -2329,18 +2329,17 @@ nsRange::CutContents(DocumentFragment** 
           }
 
           handled = true;
         }
         else
         {
           // Delete or extract everything after startOffset.
 
-          rv = charData->GetLength(&dataLength);
-          NS_ENSURE_SUCCESS(rv, rv);
+          dataLength = charData->Length();
 
           if (dataLength >= startOffset) {
             if (retval) {
               nsAutoString cutValue;
               ErrorResult err;
               charData->SubstringData(startOffset, dataLength, cutValue, err);
               if (NS_WARN_IF(err.Failed())) {
                 return err.StealNSResult();
@@ -2723,30 +2722,23 @@ nsRange::CloneContents(ErrorResult& aRv)
     }
 
     // If it's CharacterData, make sure we only clone what
     // is in the range.
     //
     // XXX_kin: We need to also handle ProcessingInstruction
     // XXX_kin: according to the spec.
 
-    nsCOMPtr<nsIDOMCharacterData> charData(do_QueryInterface(clone));
-
-    if (charData)
+    if (auto charData = CharacterData::FromContent(clone))
     {
       if (node == mEnd.Container()) {
         // We only need the data before mEndOffset, so get rid of any
         // data after it.
 
-        uint32_t dataLength = 0;
-        aRv = charData->GetLength(&dataLength);
-        if (aRv.Failed()) {
-          return nullptr;
-        }
-
+        uint32_t dataLength = charData->Length();
         if (dataLength > (uint32_t)mEnd.Offset())
         {
           aRv = charData->DeleteData(mEnd.Offset(), dataLength - mEnd.Offset());
           if (aRv.Failed()) {
             return nullptr;
           }
         }
       }
--- a/dom/interfaces/core/nsIDOMCharacterData.idl
+++ b/dom/interfaces/core/nsIDOMCharacterData.idl
@@ -11,17 +11,16 @@
  * 
  * 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
 {
-  readonly attribute unsigned long        length;
   void                      insertData(in unsigned long offset, 
                                        in DOMString arg)
                                   raises(DOMException);
   void                      deleteData(in unsigned long offset, 
                                        in unsigned long count)
                                   raises(DOMException);
   void                      replaceData(in unsigned long offset, 
                                         in unsigned long count, 
--- a/dom/xslt/xpath/XPathExpression.cpp
+++ b/dom/xslt/xpath/XPathExpression.cpp
@@ -4,24 +4,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Move.h"
 #include "XPathExpression.h"
 #include "txExpr.h"
 #include "txExprResult.h"
 #include "txIXPathContext.h"
 #include "nsError.h"
-#include "nsIDOMCharacterData.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIDOMDocument.h"
 #include "nsINode.h"
 #include "XPathResult.h"
 #include "txURIUtils.h"
 #include "txXPathTreeWalker.h"
 #include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/Text.h"
 #include "mozilla/dom/XPathResultBinding.h"
 
 using mozilla::Move;
 
 namespace mozilla {
 namespace dom {
 
 class EvalContextImpl : public txIEvalContext
@@ -121,25 +121,20 @@ XPathExpression::EvaluateWithContext(nsI
             return nullptr;
         }
     }
 
     uint16_t nodeType = aContextNode.NodeType();
 
     if (nodeType == nsINode::TEXT_NODE ||
         nodeType == nsINode::CDATA_SECTION_NODE) {
-        nsCOMPtr<nsIDOMCharacterData> textNode =
-            do_QueryInterface(&aContextNode);
-        if (!textNode) {
-            aRv.Throw(NS_ERROR_FAILURE);
-            return nullptr;
-        }
+        Text* textNode = aContextNode.GetAsText();
+        MOZ_ASSERT(textNode);
 
-        uint32_t textLength;
-        textNode->GetLength(&textLength);
+        uint32_t textLength = textNode->Length();
         if (textLength == 0) {
             aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
             return nullptr;
         }
 
         // XXX Need to get logical XPath text node for CDATASection
         //     and Text nodes.
     }