Bug 1509575 - Restore the visual viewport offset from the main thread during a first paint. r=kats

During a "first paint" transaction, compositor-side state such as APZ's copy
of the visual viewport offset is overwritten. However, the scroll frame may
persist on the main thread, and in such a case we want to restore the visual
viewport offset stored in the scroll frame. This comes into play during e.g.
navigation back to a page.

Differential Revision: https://phabricator.services.mozilla.com/D16238

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-01-15 01:30:53 +00:00
Родитель 1df8d17b47
Коммит 869afb0d73
2 изменённых файлов: 9 добавлений и 1 удалений

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

@ -61,7 +61,7 @@ function* test(testDriver) {
// Flush state just to be sure.
yield waitForApzFlushedRepaints(testDriver);
todo_is(window.visualViewport.pageLeft, visualX, "visual viewport remains unchanged");
is(window.visualViewport.pageLeft, visualX, "visual viewport remains unchanged");
}
waitUntilApzStable()

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

@ -8708,6 +8708,14 @@ static void MaybeReflowForInflationScreenSizeChange(
metrics.SetBaseScrollOffset(apzScrollPosition);
if (aIsRootContent) {
if (aLayerManager->GetIsFirstPaint() &&
presShell->IsVisualViewportOffsetSet()) {
// Restore the visual viewport offset to the copy stored on the
// main thread.
presShell->SetPendingVisualScrollUpdate(
presShell->GetVisualViewportOffset(), FrameMetrics::eRestore);
}
if (const Maybe<nsIPresShell::VisualScrollUpdate>& visualUpdate =
presShell->GetPendingVisualScrollUpdate()) {
metrics.SetVisualViewportOffset(