Bug 1496864 - When performing a main thread scroll, update the main thread's view of the visual viewport offset right away. r=kats

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2018-11-08 22:24:44 +00:00
parent 1722841caf
commit 52ee4ae5bf

View File

@ -2948,12 +2948,19 @@ ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, nsAtom* aOrig
// the RCD-RSF this will have the effect of resetting the visual viewport
// offset to be the same as the new scroll (= layout viewport) offset.
// The APZ callback transform, which reflects the difference between these
// offsets, will subsequently be cleared. However, it we wait for APZ to
// offsets, will subsequently be cleared. However, if we wait for APZ to
// clear it, the main thread could end up using the old value and get
// incorrect results, so just clear it now.
if (mIsRoot && nsLayoutUtils::CanScrollOriginClobberApz(mLastScrollOrigin)) {
content->SetProperty(nsGkAtoms::apzCallbackTransform, new CSSPoint(),
nsINode::DeleteProperty<CSSPoint>);
// Similarly, update the main thread's view of the visual viewport
// offset. Otherwise, if we perform calculations that depend on this
// offset (e.g. by using nsIDOMWindowUtils.getVisualViewportOffset()
// in chrome JS code) before it's updated by the next APZ repaint,
// we could get incorrect results.
presContext->PresShell()->SetVisualViewportOffset(pt);
}
ScrollVisual();