Bug 952087 Anchor scroll fails if the anchor is created between DOMContentLoaded and onload r=smaug

This commit is contained in:
Neil Rashbrook 2014-01-07 18:34:21 +00:00
parent 4d46ad1708
commit 796419d6e8
5 changed files with 49 additions and 8 deletions

View File

@ -8821,6 +8821,10 @@ void
nsDocument::ScrollToRef()
{
if (mScrolledToRefAlready) {
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->ScrollToAnchor();
}
return;
}

View File

@ -1025,15 +1025,20 @@ nsDocumentViewer::LoadComplete(nsresult aStatus)
}
}
// Now that the document has loaded, we can tell the presshell
// to unsuppress painting.
if (mPresShell && !mStopped) {
nsCOMPtr<nsIPresShell> shellDeathGrip(mPresShell);
mPresShell->UnsuppressPainting();
// mPresShell could have been removed now, see bug 378682/421432
if (!mStopped) {
if (mDocument) {
mDocument->ScrollToRef();
}
// Now that the document has loaded, we can tell the presshell
// to unsuppress painting.
if (mPresShell) {
mPresShell->ScrollToAnchor();
mPresShell->LoadComplete();
nsCOMPtr<nsIPresShell> shellDeathGrip(mPresShell);
mPresShell->UnsuppressPainting();
// mPresShell could have been removed now, see bug 378682/421432
if (mPresShell) {
mPresShell->LoadComplete();
}
}
}

View File

@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
</head>
<body style="margin: 0;">
<div>
<div style="height: 50px; width: 50px; background-color: red;"></div>
<div style="height: 1000px;"></div>
<div id="d" style="height: 50px; width: 50px; background-color: green;"></div>
<div style="height: 1000px;"></div>
</div>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<script>
var xhr = new XMLHttpRequest();
xhr.onload = function() {
document.body.appendChild(document.importNode(this.responseXML.getElementsByTagName("div")[0], true));
};
xhr.open("get", "deferred-anchor-ref.html");
xhr.responseType = "document";
xhr.send();
</script>
</head>
<body style="margin: 0;">
</body>
</html>

View File

@ -1,3 +1,4 @@
== deferred-anchor.html#d deferred-anchor-ref.html#d
HTTP == fixed-1.html fixed-1.html?ref
HTTP == fixed-opacity-1.html fixed-opacity-1.html?ref
skip-if(B2G) HTTP == fixed-opacity-2.html fixed-opacity-2.html?ref