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

Side by Side Diff: Source/platform/scroll/ScrollAnimatorNone.cpp

Issue 244253002: Avoid useless initialization in ScrollAnimatorNone::PerAxisData::animateScroll() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // FIXME: Add in jank detection trace events into this function. 327 // FIXME: Add in jank detection trace events into this function.
328 bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime) 328 bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime)
329 { 329 {
330 double lastScrollInterval = currentTime - m_lastAnimationTime; 330 double lastScrollInterval = currentTime - m_lastAnimationTime;
331 if (lastScrollInterval < kMinimumTimerInterval) 331 if (lastScrollInterval < kMinimumTimerInterval)
332 return true; 332 return true;
333 333
334 m_lastAnimationTime = currentTime; 334 m_lastAnimationTime = currentTime;
335 335
336 double deltaTime = currentTime - m_startTime; 336 double deltaTime = currentTime - m_startTime;
337 double newPosition = *m_currentPosition;
338 337
339 if (deltaTime > m_animationTime) { 338 if (deltaTime > m_animationTime) {
340 *m_currentPosition = m_desiredPosition; 339 *m_currentPosition = m_desiredPosition;
341 reset(); 340 reset();
342 return false; 341 return false;
343 } 342 }
344 if (deltaTime < m_attackTime) 343 double newPosition;
abarth-chromium 2014/04/20 14:10:05 Can we initialize it to zero? We generally like t
Inactive 2014/04/20 15:00:56 Counter proposal: I moved the initialization to a
344 if (deltaTime < m_attackTime) {
345 newPosition = attackCurve(m_attackCurve, deltaTime, m_attackTime, m_star tPosition, m_attackPosition); 345 newPosition = attackCurve(m_attackCurve, deltaTime, m_attackTime, m_star tPosition, m_attackPosition);
346 else if (deltaTime < (m_animationTime - m_releaseTime)) 346 } else if (deltaTime < (m_animationTime - m_releaseTime)) {
347 newPosition = m_attackPosition + (deltaTime - m_attackTime) * m_desiredV elocity; 347 newPosition = m_attackPosition + (deltaTime - m_attackTime) * m_desiredV elocity;
348 else { 348 } else {
349 // release is based on targeting the exact final position. 349 // release is based on targeting the exact final position.
350 double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime); 350 double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime);
351 newPosition = releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime, m_releasePosition, m_desiredPosition); 351 newPosition = releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime, m_releasePosition, m_desiredPosition);
352 } 352 }
353 353
354 // Normalize velocity to a per second amount. Could be used to check for jan k. 354 // Normalize velocity to a per second amount. Could be used to check for jan k.
355 if (lastScrollInterval > 0) 355 if (lastScrollInterval > 0)
356 m_currentVelocity = (newPosition - *m_currentPosition) / lastScrollInter val; 356 m_currentVelocity = (newPosition - *m_currentPosition) / lastScrollInter val;
357 *m_currentPosition = newPosition; 357 *m_currentPosition = newPosition;
358 358
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 return m_animationActive; 517 return m_animationActive;
518 } 518 }
519 519
520 void ScrollAnimatorNone::stopAnimationTimerIfNeeded() 520 void ScrollAnimatorNone::stopAnimationTimerIfNeeded()
521 { 521 {
522 if (animationTimerActive()) 522 if (animationTimerActive())
523 m_animationActive = false; 523 m_animationActive = false;
524 } 524 }
525 525
526 } // namespace WebCore 526 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698