Bug 1605956 - Don't invalidate scroll anchor on visual viewport offset updates if visual viewport size is not set. r=botond

As we only use the offset if the visual viewport size is set.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-12-30 17:03:46 +00:00
Родитель 5015323ddf
Коммит ce358595b7
1 изменённых файлов: 13 добавлений и 12 удалений

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

@ -10649,24 +10649,25 @@ void PresShell::ResetVisualViewportSize() {
bool PresShell::SetVisualViewportOffset(const nsPoint& aScrollOffset,
const nsPoint& aPrevLayoutScrollPos) {
bool didChange = false;
if (GetVisualViewportOffset() != aScrollOffset) {
nsPoint prevOffset = GetVisualViewportOffset();
mVisualViewportOffset = Some(aScrollOffset);
didChange = true;
nsPoint prevOffset = GetVisualViewportOffset();
if (prevOffset == aScrollOffset) {
return false;
}
if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
window->VisualViewport()->PostScrollEvent(prevOffset,
aPrevLayoutScrollPos);
}
mVisualViewportOffset = Some(aScrollOffset);
if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
window->VisualViewport()->PostScrollEvent(prevOffset, aPrevLayoutScrollPos);
}
if (IsVisualViewportSizeSet()) {
if (nsIScrollableFrame* rootScrollFrame =
GetRootScrollFrameAsScrollable()) {
ScrollAnchorContainer* container = rootScrollFrame->Anchor();
container->UserScrolled();
rootScrollFrame->Anchor()->UserScrolled();
}
}
return didChange;
return true;
}
void PresShell::ScrollToVisual(const nsPoint& aVisualViewportOffset,