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

Side by Side Diff: third_party/WebKit/Source/core/layout/ScrollAnchor.cpp

Issue 1950243005: Communicate MT changes to impl-only scroll offset animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jbroman's feedback Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ScrollAnchor.h" 5 #include "core/layout/ScrollAnchor.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/UseCounter.h" 8 #include "core/frame/UseCounter.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/layout/line/InlineTextBox.h" 10 #include "core/layout/line/InlineTextBox.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // should scroll by 1px instead of 0.2px.) This is true regardless of whethe r 199 // should scroll by 1px instead of 0.2px.) This is true regardless of whethe r
200 // the ScrollableArea actually uses fractional scroll positions. 200 // the ScrollableArea actually uses fractional scroll positions.
201 IntSize adjustment = 201 IntSize adjustment =
202 roundedIntSize(computeRelativeOffset(m_anchorObject, m_scroller, m_corne r)) - 202 roundedIntSize(computeRelativeOffset(m_anchorObject, m_scroller, m_corne r)) -
203 roundedIntSize(m_savedRelativeOffset); 203 roundedIntSize(m_savedRelativeOffset);
204 if (!adjustment.isZero()) { 204 if (!adjustment.isZero()) {
205 DoublePoint desiredPos = m_scroller->scrollPositionDouble() + adjustment ; 205 DoublePoint desiredPos = m_scroller->scrollPositionDouble() + adjustment ;
206 ScrollAnimatorBase* animator = m_scroller->existingScrollAnimator(); 206 ScrollAnimatorBase* animator = m_scroller->existingScrollAnimator();
207 if (!animator || !animator->hasRunningAnimation()) { 207 if (!animator || !animator->hasRunningAnimation()) {
208 m_scroller->setScrollPosition(desiredPos, AnchoringScroll); 208 m_scroller->setScrollPosition(desiredPos, AnchoringScroll);
209 animator->updateImplOnlyScrollOffsetAnimation(FloatSize(adjustment)) ;
209 } else { 210 } else {
210 // If in the middle of a scroll animation, stop the animation, make 211 // If in the middle of a scroll animation, stop the animation, make
211 // the adjustment, and continue the animation on the pending delta. 212 // the adjustment, and continue the animation on the pending delta.
212 FloatSize pendingDelta = animator->desiredTargetPosition() - FloatPo int(m_scroller->scrollPositionDouble()); 213 FloatSize pendingDelta = animator->desiredTargetPosition() - FloatPo int(m_scroller->scrollPositionDouble());
213 animator->cancelAnimation(); 214 animator->cancelAnimation();
214 m_scroller->setScrollPosition(desiredPos, AnchoringScroll); 215 m_scroller->setScrollPosition(desiredPos, AnchoringScroll);
215 animator->userScroll(ScrollByPixel, pendingDelta); 216 animator->userScroll(ScrollByPixel, pendingDelta);
216 } 217 }
217 // Update UMA metric. 218 // Update UMA metric.
218 DEFINE_STATIC_LOCAL(EnumerationHistogram, adjustedOffsetHistogram, 219 DEFINE_STATIC_LOCAL(EnumerationHistogram, adjustedOffsetHistogram,
219 ("Layout.ScrollAnchor.AdjustedScrollOffset", 2)); 220 ("Layout.ScrollAnchor.AdjustedScrollOffset", 2));
220 adjustedOffsetHistogram.count(1); 221 adjustedOffsetHistogram.count(1);
221 UseCounter::count(scrollerLayoutBox(m_scroller)->document(), UseCounter: :ScrollAnchored); 222 UseCounter::count(scrollerLayoutBox(m_scroller)->document(), UseCounter: :ScrollAnchored);
222 } 223 }
223 } 224 }
224 225
225 void ScrollAnchor::clear() 226 void ScrollAnchor::clear()
226 { 227 {
227 LayoutObject* anchorObject = m_anchorObject; 228 LayoutObject* anchorObject = m_anchorObject;
228 m_anchorObject = nullptr; 229 m_anchorObject = nullptr;
229 230
230 if (anchorObject) 231 if (anchorObject)
231 anchorObject->maybeClearIsScrollAnchorObject(); 232 anchorObject->maybeClearIsScrollAnchorObject();
232 } 233 }
233 234
234 } // namespace blink 235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698