Bug 486741. Remove hack around broken scrollbars, since it's not needed anymore. r+sr=jst

This commit is contained in:
Boris Zbarsky 2009-05-11 22:04:58 -04:00
parent f20778f925
commit 4ce33a6c6d
3 changed files with 48 additions and 53 deletions

View File

@ -1917,64 +1917,12 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
}
}
// 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

View File

@ -93,6 +93,7 @@ _TEST_FILES = test_bug1682.html \
test_bug481440.html \
test_bug481647.html \
test_bug482659.html \
test_bug486741.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -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>