Backed out changeset cc4b2dbdfd83 (bug 1530208) for failing dom/base/test/unit/test_isequalnode.js on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Mon, 04 Mar 2019 21:00:27 +0200
changeset 520133 ed6397d7e51a7e9084281d2a8b33b0c5e8eeedb7
parent 520132 a9911c4882de3ee2862a563988c01dc90bc69ec5
child 520134 a9bb4a23d4072a2735b50b577f9668728af06d30
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1530208
milestone67.0a1
backs outcc4b2dbdfd83244f10bbdc8bdf588edaea618663
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
Backed out changeset cc4b2dbdfd83 (bug 1530208) for failing dom/base/test/unit/test_isequalnode.js on a CLOSED TREE
dom/base/CharacterData.h
dom/base/nsINode.cpp
dom/base/nsTextFragment.cpp
dom/base/nsTextFragment.h
--- a/dom/base/CharacterData.h
+++ b/dom/base/CharacterData.h
@@ -203,24 +203,16 @@ class CharacterData : public nsIContent 
 
 #ifdef DEBUG
   void ToCString(nsAString& aBuf, int32_t aOffset, int32_t aLen) const;
 #endif
 
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(
       CharacterData, nsIContent)
 
-  /**
-   * Compare two CharacterData nodes for text equality.
-   */
-  MOZ_MUST_USE
-  bool TextEquals(const CharacterData* aOther) const {
-    return mText.TextEquals(aOther->mText);
-  }
-
  protected:
   virtual ~CharacterData();
 
   Element* GetNameSpaceElement() final {
     return Element::FromNodeOrNull(GetParentNode());
   }
 
   nsresult SetTextInternal(
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -811,22 +811,16 @@ uint16_t nsINode::CompareDocumentPositio
 
 bool nsINode::IsSameNode(nsINode* other) { return other == this; }
 
 bool nsINode::IsEqualNode(nsINode* aOther) {
   if (!aOther) {
     return false;
   }
 
-  // Might as well do a quick check to avoid walking our kids if we're
-  // obviously the same.
-  if (aOther == this) {
-    return true;
-  }
-
   nsAutoString string1, string2;
 
   nsINode* node1 = this;
   nsINode* node2 = aOther;
   do {
     uint16_t nodeType = node1->NodeType();
     if (nodeType != node2->NodeType()) {
       return false;
@@ -869,20 +863,22 @@ bool nsINode::IsEqualNode(nsINode* aOthe
         break;
       }
       case TEXT_NODE:
       case COMMENT_NODE:
       case CDATA_SECTION_NODE:
       case PROCESSING_INSTRUCTION_NODE: {
         MOZ_ASSERT(node1->IsCharacterData());
         MOZ_ASSERT(node2->IsCharacterData());
-        auto* data1 = static_cast<CharacterData*>(node1);
-        auto* data2 = static_cast<CharacterData*>(node2);
-
-        if (!data1->TextEquals(data2)) {
+        string1.Truncate();
+        static_cast<CharacterData*>(node1)->AppendTextTo(string1);
+        string2.Truncate();
+        static_cast<CharacterData*>(node2)->AppendTextTo(string2);
+
+        if (!string1.Equals(string2)) {
           return false;
         }
 
         break;
       }
       case DOCUMENT_NODE:
       case DOCUMENT_FRAGMENT_NODE:
         break;
--- a/dom/base/nsTextFragment.cpp
+++ b/dom/base/nsTextFragment.cpp
@@ -485,45 +485,8 @@ size_t nsTextFragment::SizeOfExcludingTh
 // every allocation
 void nsTextFragment::UpdateBidiFlag(const char16_t* aBuffer, uint32_t aLength) {
   if (mState.mIs2b && !mState.mIsBidi) {
     if (HasRTLChars(MakeSpan(aBuffer, aLength))) {
       mState.mIsBidi = true;
     }
   }
 }
-
-bool nsTextFragment::TextEquals(const nsTextFragment& aOther) const {
-  if (!Is2b()) {
-    // We're 1-byte.
-    if (!aOther.Is2b()) {
-      nsDependentCString ourStr(Get1b(), GetLength());
-      return ourStr.Equals(
-          nsDependentCString(aOther.Get1b(), aOther.GetLength()));
-    }
-
-    // We're 1-byte, the other thing is 2-byte.  Instead of implementing a
-    // separate codepath for this, just use our code below.
-    return aOther.TextEquals(*this);
-  }
-
-  nsDependentString ourStr(Get2b(), GetLength());
-  if (aOther.Is2b()) {
-    return ourStr.Equals(nsDependentString(aOther.Get2b(), aOther.GetLength()));
-  }
-
-  // We can't use EqualsASCII here, because the other string might not
-  // actually be ASCII.  Just roll our own compare; do it in the simple way.
-  // Bug 1532356 tracks not having to roll our own.
-  if (GetLength() != aOther.GetLength()) {
-    return false;
-  }
-
-  const char16_t* ourChars = Get2b();
-  const char* otherChars = aOther.Get1b();
-  for (uint32_t i = 0; i < GetLength(); ++i) {
-    if (ourChars[i] != static_cast<char16_t>(otherChars[i])) {
-      return false;
-    }
-  }
-
-  return true;
-}
--- a/dom/base/nsTextFragment.h
+++ b/dom/base/nsTextFragment.h
@@ -231,22 +231,16 @@ class nsTextFragment final {
     // NS_MAX_TEXT_FRAGMENT_LENGTH.
     uint32_t mLength : 29;
   };
 
 #define NS_MAX_TEXT_FRAGMENT_LENGTH (static_cast<uint32_t>(0x1FFFFFFF))
 
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
-  /**
-   * Check whether the text in this fragment is the same as the text in the
-   * other fragment.
-   */
-  MOZ_MUST_USE bool TextEquals(const nsTextFragment& aOther) const;
-
  private:
   void ReleaseText();
 
   /**
    * Scan the contents of the fragment and turn on mState.mIsBidi if it
    * includes any Bidi characters.
    */
   void UpdateBidiFlag(const char16_t* aBuffer, uint32_t aLength);