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-10 08:35:46 +00:00
Родитель 32ea4fd540
Коммит a1b1fdf915
5 изменённых файлов: 46 добавлений и 8 удалений

Просмотреть файл

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

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body style="margin: 0;">
<div style="height: 50px; width: 50px; background-color: red;"/>
<div style="height: 1000px;"/>
<div id="d" style="height: 50px; width: 50px; background-color: green;"/>
<div style="height: 1000px;"/>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
var xhr = new XMLHttpRequest();
xhr.onprogress = function() {
};
xhr.onload = function() {
document.documentElement.innerHTML = this.responseXML.documentElement.innerHTML;
};
xhr.open("get", "deferred-anchor-ref.xhtml");
xhr.send();
</script>
</head>
</html>

Просмотреть файл

@ -1,3 +1,4 @@
HTTP == deferred-anchor.xhtml#d deferred-anchor-ref.xhtml#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