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

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 expected result 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 if (offset)
dstockwell 2013/09/10 22:19:42 I had a hard time understanding that the special c
Steve Block 2013/09/11 00:11:52 I guess I don't see scale == infinity as a special
467 fractionalTime = (fractionalTime - offset) * scale; 467 fractionalTime -= offset;
468 if (scale != 1.0 && fractionalTime) {
469 ASSERT(scale >= 0 && !std::isinf(scale));
470 fractionalTime *= scale;
471 }
468 472
473 ASSERT(fractionalTime >= 0 && fractionalTime <= 1);
469 return fractionalTime; 474 return fractionalTime;
470 } 475 }
471 476
472 double AnimationBase::progress(double scale, double offset, const TimingFunction * timingFunction) const 477 double AnimationBase::progress(double scale, double offset, const TimingFunction * timingFunction) const
473 { 478 {
474 if (preActive()) 479 if (preActive())
475 return 0; 480 return 0;
476 481
477 double dur = m_animation->duration(); 482 double dur = m_animation->duration();
478 if (m_animation->iterationCount() > 0) 483 if (m_animation->iterationCount() > 0)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 return 0; 577 return 0;
573 578
574 double elapsedTime = beginAnimationUpdateTime() - m_startTime; 579 double elapsedTime = beginAnimationUpdateTime() - m_startTime;
575 // It's possible for the start time to be ahead of the last update time 580 // 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 581 // if the compositor has just sent notification for the start of an
577 // accelerated animation. 582 // accelerated animation.
578 return max(elapsedTime, 0.0); 583 return max(elapsedTime, 0.0);
579 } 584 }
580 585
581 } // namespace WebCore 586 } // 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