Bug 1498812 - Part 9: Switch session store/session history to use visual viewport for scroll position tracking. r=mikedeboer,snorp

For simplicity's sake, for now we keep storing only one scroll position per
history entry (bug 1499210), so if we have to choose between the layout and the
visual viewport, the latter is a vastly better choice, as it more accurately
represents the scroll position as perceived by the user, especially when the
page has been pinch-zoomed.

This also means that instead of the normal scroll events, the session store now
has to listen for the corresponding events specific to the visual viewport.

We also extend the scroll position test to check that the scroll position isn't
just properly saved, but also actually properly restored in practice as well.
We only add this test now instead of already adding it beforehand like we did
with the rest of the test
- to avoid having to temporarily extend the checkScroll() helper function to
  deal with todo()/todo_is etc.
- because getting that part of the test to complete without timing out (which
  would be one of its natural failure modes, because the expected events would
  be missing) would require faking even more scroll events
- because we already have the todo() tests that are telling us the we didn't
  *store* any scroll position in the first place, so there's no point in trying
  to actually restore anything

For the GeckoView saveAndRestoreState test, we now spin the event loop once
before setting the scroll position in order to give APZ opportunity to settle
down after the initial page load.

Differential Revision: https://phabricator.services.mozilla.com/D15690
This commit is contained in:
Jan Henning
2019-01-11 19:50:09 +00:00
parent a207c5d710
commit d561bbf114
11 changed files with 66 additions and 50 deletions

View File

@@ -5626,7 +5626,7 @@ nsDocShell::SetTitle(const nsAString& aTitle) {
nsPoint nsDocShell::GetCurScrollPos() {
nsPoint scrollPos;
if (nsIScrollableFrame* sf = GetRootScrollFrame()) {
scrollPos = sf->GetScrollPosition();
scrollPos = sf->GetVisualViewportOffset();
}
return scrollPos;
}