Bug 1177247 - Prevent HandlePossibleViewportChange from clobbering a restored scroll position from forward/back navigation. r=botond

When the mochitest docshell/test/test_bug590573.html is run with APZ enabled,
it fails because the HandlePossibleViewportChange code clobbers the scroll
position after it has been restored by the session history code. Instead of
using the default 0,0 as the initial scroll position we now pick up the
pre-existing scroll position and use that.
This commit is contained in:
Kartikaya Gupta 2015-06-25 23:54:25 -07:00
parent 06d449dbbe
commit e8768b5c0a

View File

@ -248,7 +248,16 @@ TabChildBase::InitializeRootMetrics()
// This is the root layer, so the cumulative resolution is the same
// as the resolution.
mLastRootMetrics.SetPresShellResolution(mLastRootMetrics.GetCumulativeResolution().ToScaleFactor().scale);
mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0));
nsCOMPtr<nsIPresShell> shell = GetPresShell();
if (shell && shell->GetRootScrollFrameAsScrollable()) {
// The session history code might restore a scroll position when navigating
// back or forward, and we don't want to clobber that.
nsPoint pos = shell->GetRootScrollFrameAsScrollable()->GetScrollPosition();
mLastRootMetrics.SetScrollOffset(CSSPoint::FromAppUnits(pos));
} else {
mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0));
}
TABC_LOG("After InitializeRootMetrics, mLastRootMetrics is %s\n",
Stringify(mLastRootMetrics).c_str());