From 1a146ac9e1a9d3743d58ba9b40d328561ecb2fb1 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 18 May 2017 00:51:16 -0400 Subject: [PATCH] Bug 1365830 - Don't flush layout for (0, 0) in nsGlobalWindow::ScrollTo(); r=bzbarsky Accurate layout information for this operation isn't ever needed. --- dom/base/nsGlobalWindow.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index fe1370229da7..e573aa44da60 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -8433,7 +8433,14 @@ nsGlobalWindow::ScrollTo(double aXScroll, double aYScroll) void nsGlobalWindow::ScrollTo(const ScrollToOptions& aOptions) { - FlushPendingNotifications(FlushType::Layout); + // When scrolling to a non-zero offset, we need to determine whether that + // position is within our scrollable range, so we need updated layout + // information which requires a layout flush, otherwise all we need is to + // flush frames to be able to access our scrollable frame here. + FlushType flushType = (aScroll.x || aScroll.y) ? + FlushType::Layout : + FlushType::Frames; + FlushPendingNotifications(flushType); nsIScrollableFrame *sf = GetScrollFrame(); if (sf) { @@ -8459,7 +8466,14 @@ void nsGlobalWindow::ScrollTo(const CSSIntPoint& aScroll, const ScrollOptions& aOptions) { - FlushPendingNotifications(FlushType::Layout); + // When scrolling to a non-zero offset, we need to determine whether that + // position is within our scrollable range, so we need updated layout + // information which requires a layout flush, otherwise all we need is to + // flush frames to be able to access our scrollable frame here. + FlushType flushType = (aScroll.x || aScroll.y) ? + FlushType::Layout : + FlushType::Frames; + FlushPendingNotifications(flushType); nsIScrollableFrame *sf = GetScrollFrame(); if (sf) {