Bug 1268195 - When restoring a scroll position outside of incremental load, don't keep trying in a loop - just do it once and stop. r=tnikkel

It may be that when the frame is reconstructed after load, the frame gets shorter,
and the old scroll position cannot be restored, because it is out of bounds. In
such a case, we don't want to keep mRestorePos tracking the old scroll position,
because it can get incorrectly applied on a future frame reconstruction. Instead,
for scroll position restorations during frame reconstructions, we just try the
restore once and then clear mRestorePos.

MozReview-Commit-ID: BHoJHz0mGmf
This commit is contained in:
Kartikaya Gupta
2016-04-29 23:06:18 -04:00
parent 6a8a891605
commit ec78701cab
8 changed files with 136 additions and 13 deletions

View File

@@ -2411,6 +2411,7 @@ PresShell::RestoreRootScrollPosition()
{
nsIScrollableFrame* scrollableFrame = GetRootScrollFrameAsScrollable();
if (scrollableFrame) {
scrollableFrame->SetRestoringHistoryScrollPosition(true);
scrollableFrame->ScrollToRestoredPosition();
}
}
@@ -2468,6 +2469,11 @@ PresShell::EndLoad(nsIDocument *aDocument)
void
PresShell::LoadComplete()
{
nsIScrollableFrame* scrollableFrame = GetRootScrollFrameAsScrollable();
if (scrollableFrame) {
scrollableFrame->SetRestoringHistoryScrollPosition(false);
}
gfxTextPerfMetrics *tp = nullptr;
if (mPresContext) {
tp = mPresContext->GetTextPerfMetrics();