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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp

Issue 2383113003: Refactor ScrollableArea::setScrollPosition. (Closed)
Patch Set: nits and rebase Created 4 years, 2 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 /* 1 /*
2 * Copyright (c) 2011, Google Inc. All rights reserved. 2 * Copyright (c) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 if (registerAndScheduleAnimation()) 184 if (registerAndScheduleAnimation())
185 m_runState = RunState::WaitingToSendToCompositor; 185 m_runState = RunState::WaitingToSendToCompositor;
186 186
187 return true; 187 return true;
188 } 188 }
189 189
190 void ScrollAnimator::adjustAnimationAndSetScrollPosition( 190 void ScrollAnimator::adjustAnimationAndSetScrollPosition(
191 const DoublePoint& position, 191 const DoublePoint& position,
192 ScrollType scrollType) { 192 ScrollType scrollType) {
193 DoublePoint adjustedPos = m_scrollableArea->clampScrollPosition(position); 193 IntSize adjustment =
194 IntSize actualAdjustment = 194 roundedIntPoint(position) -
195 roundedIntPoint(adjustedPos) -
196 roundedIntPoint(m_scrollableArea->scrollPositionDouble()); 195 roundedIntPoint(m_scrollableArea->scrollPositionDouble());
197 196
198 scrollPositionChanged(adjustedPos, scrollType); 197 scrollPositionChanged(position, scrollType);
199 198
200 if (m_runState == RunState::Idle) { 199 if (m_runState == RunState::Idle) {
201 adjustImplOnlyScrollOffsetAnimation(actualAdjustment); 200 adjustImplOnlyScrollOffsetAnimation(adjustment);
202 } else if (hasRunningAnimation()) { 201 } else if (hasRunningAnimation()) {
203 m_targetOffset += toFloatSize(actualAdjustment); 202 m_targetOffset += toFloatSize(adjustment);
204 if (m_animationCurve) { 203 if (m_animationCurve) {
205 m_animationCurve->applyAdjustment(actualAdjustment); 204 m_animationCurve->applyAdjustment(adjustment);
206 if (m_runState != RunState::RunningOnMainThread && 205 if (m_runState != RunState::RunningOnMainThread &&
207 registerAndScheduleAnimation()) 206 registerAndScheduleAnimation())
208 m_runState = RunState::RunningOnCompositorButNeedsAdjustment; 207 m_runState = RunState::RunningOnCompositorButNeedsAdjustment;
209 } 208 }
210 } 209 }
211 } 210 }
212 211
213 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset) { 212 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset) {
214 m_currentPos = offset; 213 m_currentPos = offset;
215 214
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 return false; 432 return false;
434 } 433 }
435 return true; 434 return true;
436 } 435 }
437 436
438 DEFINE_TRACE(ScrollAnimator) { 437 DEFINE_TRACE(ScrollAnimator) {
439 ScrollAnimatorBase::trace(visitor); 438 ScrollAnimatorBase::trace(visitor);
440 } 439 }
441 440
442 } // namespace blink 441 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698