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

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

Issue 1780993003: Account for scroll origin in scroll animators. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 m_targetOffset = targetPos; 145 m_targetOffset = targetPos;
146 ASSERT(m_runState == RunState::RunningOnMainThread 146 ASSERT(m_runState == RunState::RunningOnMainThread
147 || m_runState == RunState::RunningOnCompositor 147 || m_runState == RunState::RunningOnCompositor
148 || m_runState == RunState::RunningOnCompositorButNeedsUpdate 148 || m_runState == RunState::RunningOnCompositorButNeedsUpdate
149 || m_runState == RunState::RunningOnCompositorButNeedsTakeover); 149 || m_runState == RunState::RunningOnCompositorButNeedsTakeover);
150 150
151 // Running on the main thread, simply update the target offset instead 151 // Running on the main thread, simply update the target offset instead
152 // of sending to the compositor. 152 // of sending to the compositor.
153 if (m_runState == RunState::RunningOnMainThread) { 153 if (m_runState == RunState::RunningOnMainThread) {
154 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, targe tPos); 154 m_animationCurve->updateTarget(m_timeFunction() - m_startTime,
155 compositorOffsetFromBlinkOffset(targetPos));
155 return true; 156 return true;
156 } 157 }
157 158
158 if (registerAndScheduleAnimation()) 159 if (registerAndScheduleAnimation())
159 m_runState = RunState::RunningOnCompositorButNeedsUpdate; 160 m_runState = RunState::RunningOnCompositorButNeedsUpdate;
160 return true; 161 return true;
161 } 162 }
162 163
163 if ((targetPos - currentPosition()).isZero()) 164 if ((targetPos - currentPosition()).isZero())
164 return false; 165 return false;
(...skipping 18 matching lines...) Expand all
183 184
184 void ScrollAnimator::tickAnimation(double monotonicTime) 185 void ScrollAnimator::tickAnimation(double monotonicTime)
185 { 186 {
186 if (m_runState != RunState::RunningOnMainThread) 187 if (m_runState != RunState::RunningOnMainThread)
187 return; 188 return;
188 189
189 TRACE_EVENT0("blink", "ScrollAnimator::tickAnimation"); 190 TRACE_EVENT0("blink", "ScrollAnimator::tickAnimation");
190 double elapsedTime = monotonicTime - m_startTime; 191 double elapsedTime = monotonicTime - m_startTime;
191 192
192 bool isFinished = (elapsedTime > m_animationCurve->duration()); 193 bool isFinished = (elapsedTime > m_animationCurve->duration());
193 FloatPoint offset = isFinished ? m_animationCurve->targetValue() 194 FloatPoint offset = blinkOffsetFromCompositorOffset(isFinished
194 : m_animationCurve->getValue(elapsedTime); 195 ? m_animationCurve->targetValue()
196 : m_animationCurve->getValue(elapsedTime));
195 197
196 offset = FloatPoint(m_scrollableArea->clampScrollPosition(offset)); 198 offset = FloatPoint(m_scrollableArea->clampScrollPosition(offset));
197 199
198 m_currentPosX = offset.x(); 200 m_currentPosX = offset.x();
199 m_currentPosY = offset.y(); 201 m_currentPosY = offset.y();
200 202
201 if (isFinished) 203 if (isFinished)
202 m_runState = RunState::PostAnimationCleanup; 204 m_runState = RunState::PostAnimationCleanup;
203 else 205 else
204 scrollableArea()->scheduleAnimation(); 206 scrollableArea()->scheduleAnimation();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 || m_runState == RunState::RunningOnCompositorButNeedsUpdate) { 285 || m_runState == RunState::RunningOnCompositorButNeedsUpdate) {
284 if (m_runState == RunState::RunningOnCompositorButNeedsUpdate) { 286 if (m_runState == RunState::RunningOnCompositorButNeedsUpdate) {
285 // Abort the running animation before a new one with an updated 287 // Abort the running animation before a new one with an updated
286 // target is added. 288 // target is added.
287 abortAnimation(); 289 abortAnimation();
288 290
289 m_compositorAnimationId = 0; 291 m_compositorAnimationId = 0;
290 m_compositorAnimationGroupId = 0; 292 m_compositorAnimationGroupId = 0;
291 293
292 m_animationCurve->updateTarget(m_timeFunction() - m_startTime, 294 m_animationCurve->updateTarget(m_timeFunction() - m_startTime,
293 m_targetOffset); 295 compositorOffsetFromBlinkOffset(m_targetOffset));
294 m_runState = RunState::WaitingToSendToCompositor; 296 m_runState = RunState::WaitingToSendToCompositor;
295 } 297 }
296 298
297 if (!m_animationCurve) { 299 if (!m_animationCurve) {
298 m_animationCurve = adoptPtr(CompositorFactory::current().createScrol lOffsetAnimationCurve( 300 m_animationCurve = adoptPtr(CompositorFactory::current().createScrol lOffsetAnimationCurve(
299 m_targetOffset, 301 compositorOffsetFromBlinkOffset(m_targetOffset),
300 CompositorAnimationCurve::TimingFunctionTypeEaseInOut, 302 CompositorAnimationCurve::TimingFunctionTypeEaseInOut,
301 m_lastGranularity == ScrollByPixel ? 303 m_lastGranularity == ScrollByPixel ?
302 CompositorScrollOffsetAnimationCurve::ScrollDurationInverseD elta : 304 CompositorScrollOffsetAnimationCurve::ScrollDurationInverseD elta :
303 CompositorScrollOffsetAnimationCurve::ScrollDurationConstant )); 305 CompositorScrollOffsetAnimationCurve::ScrollDurationConstant ));
304 m_animationCurve->setInitialValue(currentPosition()); 306 m_animationCurve->setInitialValue(compositorOffsetFromBlinkOffset(cu rrentPosition()));
305 } 307 }
306 308
307 bool runningOnMainThread = false; 309 bool runningOnMainThread = false;
308 bool sentToCompositor = sendAnimationToCompositor(); 310 bool sentToCompositor = sendAnimationToCompositor();
309 if (!sentToCompositor) { 311 if (!sentToCompositor) {
310 runningOnMainThread = registerAndScheduleAnimation(); 312 runningOnMainThread = registerAndScheduleAnimation();
311 if (runningOnMainThread) 313 if (runningOnMainThread)
312 m_runState = RunState::RunningOnMainThread; 314 m_runState = RunState::RunningOnMainThread;
313 } 315 }
314 316
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 403 }
402 return true; 404 return true;
403 } 405 }
404 406
405 DEFINE_TRACE(ScrollAnimator) 407 DEFINE_TRACE(ScrollAnimator)
406 { 408 {
407 ScrollAnimatorBase::trace(visitor); 409 ScrollAnimatorBase::trace(visitor);
408 } 410 }
409 411
410 } // namespace blink 412 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698