Backed out changeset 4427e7f72c8e (bug 1414233) for crashing in mochitest dom/base/test/test_bug1375050.html. r=backout on a CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 06 Nov 2017 23:38:00 +0200
changeset 443676 ffd4e32a403a933d53a1aa84edf94aa4b7a76dfc
parent 443665 02dd65e55fd1ea9d2639b32da9748047e6772564
child 443677 4864989da37ee59ed9318de7be1198f41075873a
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1414233, 1375050
milestone58.0a1
backs out4427e7f72c8eb1daf43ec2b20b3e3a49bfd7db0c
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 4427e7f72c8e (bug 1414233) for crashing in mochitest dom/base/test/test_bug1375050.html. r=backout on a CLOSED TREE
dom/base/nsRange.cpp
dom/base/nsRange.h
dom/html/nsGenericHTMLElement.cpp
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -3818,31 +3818,46 @@ IsLastNonemptyRowGroupOfTable(nsIFrame* 
       }
     }
   }
   return true;
 }
 
 void
 nsRange::GetInnerTextNoFlush(DOMString& aValue, ErrorResult& aError,
-                             nsIContent* aNode)
+                             nsIContent* aStartContainer, uint32_t aStartOffset,
+                             nsIContent* aEndContainer, uint32_t aEndOffset)
 {
   InnerTextAccumulator result(aValue);
-
-  if (aNode->IsNodeOfType(nsINode::eTEXT)) {
-    auto t = static_cast<nsGenericDOMDataNode*>(aNode);
-    AppendTransformedText(result, t, 0, t->Length());
-    return;
+  nsIContent* currentNode = aStartContainer;
+  TreeTraversalState currentState = AFTER_NODE;
+  if (aStartContainer->IsNodeOfType(nsINode::eTEXT)) {
+    auto t = static_cast<nsGenericDOMDataNode*>(aStartContainer);
+    if (aStartContainer == aEndContainer) {
+      AppendTransformedText(result, t, aStartOffset, aEndOffset);
+      return;
+    }
+    AppendTransformedText(result, t, aStartOffset, t->TextLength());
+  } else {
+    if (uint32_t(aStartOffset) < aStartContainer->GetChildCount()) {
+      currentNode = aStartContainer->GetChildAt(aStartOffset);
+      currentState = AT_NODE;
+    }
   }
 
-  nsIContent* currentNode = aNode->GetFirstChild();
-  TreeTraversalState currentState = AT_NODE;
-
-  nsIContent* endNode = aNode->GetLastChild();
+  nsIContent* endNode = aEndContainer;
   TreeTraversalState endState = AFTER_NODE;
+  if (aEndContainer->IsNodeOfType(nsINode::eTEXT)) {
+    endState = AT_NODE;
+  } else {
+    if (aEndOffset < aEndContainer->GetChildCount()) {
+      endNode = aEndContainer->GetChildAt(aEndOffset);
+      endState = AT_NODE;
+    }
+  }
 
   while (currentNode != endNode || currentState != endState) {
     nsIFrame* f = currentNode->GetPrimaryFrame();
     bool isVisibleAndNotReplaced = IsVisibleAndNotInReplacedElement(f);
     if (currentState == AT_NODE) {
       bool isText = currentNode->IsNodeOfType(nsINode::eTEXT);
       if (isText && currentNode->GetParent()->IsHTMLElement(nsGkAtoms::rp) &&
           ElementIsVisibleNoFlush(currentNode->GetParent()->AsElement())) {
@@ -3891,11 +3906,15 @@ nsRange::GetInnerTextNoFlush(DOMString& 
     if (next) {
       currentNode = next;
       currentState = AT_NODE;
     } else {
       currentNode = currentNode->GetParent();
     }
   }
 
+  if (aEndContainer->IsNodeOfType(nsINode::eTEXT)) {
+    nsGenericDOMDataNode* t = static_cast<nsGenericDOMDataNode*>(aEndContainer);
+    AppendTransformedText(result, t, 0, aEndOffset);
+  }
   // Do not flush trailing line breaks! Required breaks at the end of the text
   // are suppressed.
 }
--- a/dom/base/nsRange.h
+++ b/dom/base/nsRange.h
@@ -328,17 +328,20 @@ public:
   void SetEndAfter(nsINode& aNode, ErrorResult& aErr);
   void SetEndBefore(nsINode& aNode, ErrorResult& aErr);
   void SetStart(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr);
   void SetStartAfter(nsINode& aNode, ErrorResult& aErr);
   void SetStartBefore(nsINode& aNode, ErrorResult& aErr);
 
   static void GetInnerTextNoFlush(mozilla::dom::DOMString& aValue,
                                   mozilla::ErrorResult& aError,
-                                  nsIContent* aNode);
+                                  nsIContent* aStartContainer,
+                                  uint32_t aStartOffset,
+                                  nsIContent* aEndContainer,
+                                  uint32_t aEndOffset);
 
   nsINode* GetParentObject() const { return mOwner; }
   virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override final;
 
 private:
   // no copy's or assigns
   nsRange(const nsRange&);
   nsRange& operator=(const nsRange&);
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -3076,17 +3076,17 @@ nsGenericHTMLElement::GetInnerText(mozil
     // ensure the document is styled.
     if (!presShell || !presShell->DidInitialize() ||
         IsOrHasAncestorWithDisplayNone(this, presShell)) {
       GetTextContentInternal(aValue, aError);
       return;
     }
   }
 
-  nsRange::GetInnerTextNoFlush(aValue, aError, this);
+  nsRange::GetInnerTextNoFlush(aValue, aError, this, 0, this, GetChildCount());
 }
 
 void
 nsGenericHTMLElement::SetInnerText(const nsAString& aValue)
 {
   // Batch possible DOMSubtreeModified events.
   mozAutoSubtreeModified subtree(OwnerDoc(), nullptr);
   FireNodeRemovedForChildren();