Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1245)

Unified Diff: third_party/WebKit/Source/core/layout/ScrollAnchor.cpp

Issue 1926473003: Smooth scroll animation should not override scroll anchoring update (MT) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable test for mac Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
index dbefd1b256907f3901c8ce3c78e5c3360262ac94..642b37ec1613f5c21cb729a55778a05187885cf5 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
@@ -172,9 +172,21 @@ void ScrollAnchor::restore()
LayoutSize adjustment = computeRelativeOffset(m_anchorObject, m_scroller, m_corner) - m_savedRelativeOffset;
if (!adjustment.isZero()) {
- m_scroller->setScrollPosition(
- m_scroller->scrollPositionDouble() + DoubleSize(adjustment),
- AnchoringScroll);
+ ScrollAnimatorBase* animator = m_scroller->existingScrollAnimator();
+ if (!animator || !animator->hasRunningAnimation()) {
+ m_scroller->setScrollPosition(
+ m_scroller->scrollPositionDouble() + DoubleSize(adjustment),
+ AnchoringScroll);
+ } else {
+ // If in the middle of a scroll animation, stop the animation, make
+ // the adjustment, and continue the animation on the pending delta.
+ FloatSize pendingDelta = animator->desiredTargetPosition() - FloatPoint(m_scroller->scrollPositionDouble());
+ animator->cancelAnimation();
+ m_scroller->setScrollPosition(
+ m_scroller->scrollPositionDouble() + DoubleSize(adjustment),
+ AnchoringScroll);
+ animator->userScroll(ScrollByPixel, pendingDelta);
+ }
// Update UMA metric.
DEFINE_STATIC_LOCAL(EnumerationHistogram, adjustedOffsetHistogram,
("Layout.ScrollAnchor.AdjustedScrollOffset", 2));

Powered by Google App Engine
This is Rietveld 408576698