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

Side by Side Diff: Source/core/page/animation/AnimationBase.cpp

Issue 23451031: Fix AnimationBase::fractionalTime() to handle a scale of infinity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added a comment Created 7 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 if (m_animation->iterationCount() != CSSAnimationData::IterationCountInfinit e && !iterationCountHasFractional) 456 if (m_animation->iterationCount() != CSSAnimationData::IterationCountInfinit e && !iterationCountHasFractional)
457 integralTime = min(integralTime, integralIterationCount - 1); 457 integralTime = min(integralTime, integralIterationCount - 1);
458 458
459 fractionalTime -= integralTime; 459 fractionalTime -= integralTime;
460 460
461 if (((m_animation->direction() == CSSAnimationData::AnimationDirectionAltern ate) && (integralTime & 1)) 461 if (((m_animation->direction() == CSSAnimationData::AnimationDirectionAltern ate) && (integralTime & 1))
462 || ((m_animation->direction() == CSSAnimationData::AnimationDirectionAlt ernateReverse) && !(integralTime & 1)) 462 || ((m_animation->direction() == CSSAnimationData::AnimationDirectionAlt ernateReverse) && !(integralTime & 1))
463 || m_animation->direction() == CSSAnimationData::AnimationDirectionRever se) 463 || m_animation->direction() == CSSAnimationData::AnimationDirectionRever se)
464 fractionalTime = 1 - fractionalTime; 464 fractionalTime = 1 - fractionalTime;
465 465
466 if (scale != 1 || offset) 466 fractionalTime -= offset;
467 fractionalTime = (fractionalTime - offset) * scale; 467 // Note that if fractionalTime == 0 here, scale may be infinity, but in
468 // this case we don't need to apply scale anyway.
469 if (scale != 1.0 && fractionalTime) {
470 ASSERT(scale >= 0 && !std::isinf(scale));
471 fractionalTime *= scale;
472 }
468 473
474 ASSERT(fractionalTime >= 0 && fractionalTime <= 1);
469 return fractionalTime; 475 return fractionalTime;
470 } 476 }
471 477
472 double AnimationBase::progress(double scale, double offset, const TimingFunction * timingFunction) const 478 double AnimationBase::progress(double scale, double offset, const TimingFunction * timingFunction) const
473 { 479 {
474 if (preActive()) 480 if (preActive())
475 return 0; 481 return 0;
476 482
477 double dur = m_animation->duration(); 483 double dur = m_animation->duration();
478 if (m_animation->iterationCount() > 0) 484 if (m_animation->iterationCount() > 0)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 return 0; 578 return 0;
573 579
574 double elapsedTime = beginAnimationUpdateTime() - m_startTime; 580 double elapsedTime = beginAnimationUpdateTime() - m_startTime;
575 // It's possible for the start time to be ahead of the last update time 581 // It's possible for the start time to be ahead of the last update time
576 // if the compositor has just sent notification for the start of an 582 // if the compositor has just sent notification for the start of an
577 // accelerated animation. 583 // accelerated animation.
578 return max(elapsedTime, 0.0); 584 return max(elapsedTime, 0.0);
579 } 585 }
580 586
581 } // namespace WebCore 587 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/animations/sample-on-last-keyframe-expected.txt ('k') | Source/core/page/animation/KeyframeAnimation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698