Bug 486741. Remove hack around broken scrollbars, since it's not needed anymore. r+sr=jst
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 11 May 2009 22:04:58 -0400
changeset 28216 347ad022cc332025fa03ebd9c66c69c22f9d6420
parent 28215 b43f2b9e0c32b84da29c455b4cec30f6932b6cd7
child 28217 de33f2e0b22fac8f1dfa8ba76aa32266735001f2
push id6947
push userbzbarsky@mozilla.com
push dateTue, 12 May 2009 02:05:45 +0000
treeherdermozilla-central@de33f2e0b22f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs486741
milestone1.9.2a1pre
Bug 486741. Remove hack around broken scrollbars, since it's not needed anymore. r+sr=jst
content/html/document/src/nsHTMLDocument.cpp
content/html/document/test/Makefile.in
content/html/document/test/test_bug486741.html
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1912,74 +1912,22 @@ nsHTMLDocument::OpenCommon(const nsACStr
     SetIsInitialDocument(PR_FALSE);
 
     nsCOMPtr<nsIScriptGlobalObject> newScope(do_QueryReferent(mScopeObject));
     if (oldScope && newScope != oldScope) {
       nsContentUtils::ReparentContentWrappersInScope(oldScope, newScope);
     }
   }
 
-  // XXX This is a nasty workaround for a scrollbar code bug
-  // (http://bugzilla.mozilla.org/show_bug.cgi?id=55334).
-
-  // Hold on to our root element
-  nsCOMPtr<nsIContent> root = GetRootContent();
-
-  if (root) {
-    PRInt32 rootIndex = mChildren.IndexOfChild(root);
-    NS_ASSERTION(rootIndex >= 0, "Root must be in list!");
-    
-    PRUint32 count = root->GetChildCount();
-
-    // Remove all the children from the root.
-    while (count-- > 0) {
-      root->RemoveChildAt(count, PR_TRUE);
-    }
-
-    count = root->GetAttrCount();
-
-    // Remove all attributes from the root element
-    while (count-- > 0) {
-      const nsAttrName* name = root->GetAttrNameAt(count);
-      // Hold a strong reference here so that the atom doesn't go away during
-      // UnsetAttr.
-      nsCOMPtr<nsIAtom> localName = name->LocalName();
-      root->UnsetAttr(name->NamespaceID(), localName, PR_FALSE);
-    }
-
-    // Remove the root from the childlist
-    mChildren.RemoveChildAt(rootIndex);
-    mCachedRootContent = nsnull;
-  }
-
-  // Call Reset(), this will now do the full reset, except removing
-  // the root from the document, doing that confuses the scrollbar
-  // code in mozilla since the document in the root element and all
-  // the anonymous content (i.e. scrollbar elements) is set to
-  // null.
-
+  // Call Reset(), this will now do the full reset
   Reset(channel, group);
   if (baseURI) {
     mDocumentBaseURI = baseURI;
   }
 
-  if (root) {
-    // Tear down the frames for the root element.
-    MOZ_AUTO_DOC_UPDATE(this, UPDATE_CONTENT_MODEL, PR_TRUE);
-    nsNodeUtils::ContentRemoved(this, root, 0);
-
-    // Put the root element back into the document, we don't notify
-    // the document about this insertion since the sink will do that
-    // for us and that'll create frames for the root element and the
-    // scrollbars work as expected (since the document in the root
-    // element was never set to null)
-
-    mChildren.AppendChild(root);
-  }
-
   if (IsEditingOn()) {
     // Reset() blows away all event listeners in the document, and our
     // editor relies heavily on those. Midas is turned on, to make it
     // work, re-initialize it to give it a chance to add its event
     // listeners again.
 
     TurnEditingOff();
     EditingStateChanged();
--- a/content/html/document/test/Makefile.in
+++ b/content/html/document/test/Makefile.in
@@ -88,12 +88,13 @@ include $(topsrcdir)/config/rules.mk
 		bug448564-iframe-1.html \
 		bug448564-iframe-2.html \
 		bug448564-iframe-3.html \
 		bug448564-echo.sjs \
 		bug448564-submit.js \
 		test_bug481440.html \
 		test_bug481647.html \
 		test_bug482659.html \
+		test_bug486741.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/content/html/document/test/test_bug486741.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=486741
+-->
+<head>
+  <title>Test for Bug 486741</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=486741">Mozilla Bug 486741</a>
+<p id="display"><iframe id="f"></iframe></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 486741 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+  var d = $("f").contentDocument;
+  var root = d.documentElement;
+  is(root.tagName, "HTML", "Unexpected root");
+
+  d.open();
+  var newRoot = d.documentElement;
+  is(newRoot.tagName, "HTML", "Unexpected new root");
+  isnot(newRoot, root, "Shouldn't be the same node");
+
+  d.write("Test");
+  d.close();
+
+  var newNewRoot = d.documentElement;
+  is(newNewRoot.tagName, "HTML", "Unexpected new root after write");
+  is(newNewRoot, newNewRoot, "write+close shouldn't change the root");
+
+  SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>