| OLD | NEW |
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return bezier.solve(t, solveEpsilon(duration)); | 61 return bezier.solve(t, solveEpsilon(duration)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 static inline double solveStepsFunction(int numSteps, bool stepAtStart, double t
) | 64 static inline double solveStepsFunction(int numSteps, bool stepAtStart, double t
) |
| 65 { | 65 { |
| 66 if (stepAtStart) | 66 if (stepAtStart) |
| 67 return min(1.0, (floor(numSteps * t) + 1) / numSteps); | 67 return min(1.0, (floor(numSteps * t) + 1) / numSteps); |
| 68 return floor(numSteps * t) / numSteps; | 68 return floor(numSteps * t) / numSteps; |
| 69 } | 69 } |
| 70 | 70 |
| 71 AnimationBase::AnimationBase(const Animation* transition, RenderObject* renderer
, CompositeAnimation* compAnim) | 71 AnimationBase::AnimationBase(const PrimitiveAnimation* transition, RenderObject*
renderer, CompositeAnimation* compAnim) |
| 72 : m_animState(AnimationStateNew) | 72 : m_animState(AnimationStateNew) |
| 73 , m_isAccelerated(false) | 73 , m_isAccelerated(false) |
| 74 , m_transformFunctionListValid(false) | 74 , m_transformFunctionListValid(false) |
| 75 , m_filterFunctionListsMatch(false) | 75 , m_filterFunctionListsMatch(false) |
| 76 , m_startTime(0) | 76 , m_startTime(0) |
| 77 , m_pauseTime(-1) | 77 , m_pauseTime(-1) |
| 78 , m_requestedStartTime(0) | 78 , m_requestedStartTime(0) |
| 79 , m_totalDuration(-1) | 79 , m_totalDuration(-1) |
| 80 , m_nextIterationDuration(-1) | 80 , m_nextIterationDuration(-1) |
| 81 , m_object(renderer) | 81 , m_object(renderer) |
| 82 , m_animation(const_cast<Animation*>(transition)) | 82 , m_animation(const_cast<PrimitiveAnimation*>(transition)) |
| 83 , m_compAnim(compAnim) | 83 , m_compAnim(compAnim) |
| 84 { | 84 { |
| 85 // Compute the total duration | 85 // Compute the total duration |
| 86 if (m_animation->iterationCount() > 0) | 86 if (m_animation->iterationCount() > 0) |
| 87 m_totalDuration = m_animation->duration() * m_animation->iterationCount(
); | 87 m_totalDuration = m_animation->duration() * m_animation->iterationCount(
); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void AnimationBase::setNeedsStyleRecalc(Node* node) | 90 void AnimationBase::setNeedsStyleRecalc(Node* node) |
| 91 { | 91 { |
| 92 ASSERT(!node || (node->document() && !node->document()->inPageCache())); | 92 ASSERT(!node || (node->document() && !node->document()->inPageCache())); |
| 93 if (node) | 93 if (node) |
| 94 node->setNeedsStyleRecalc(SyntheticStyleChange); | 94 node->setNeedsStyleRecalc(SyntheticStyleChange); |
| 95 } | 95 } |
| 96 | 96 |
| 97 double AnimationBase::duration() const | 97 double AnimationBase::duration() const |
| 98 { | 98 { |
| 99 return m_animation->duration(); | 99 return m_animation->duration(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool AnimationBase::playStatePlaying() const | 102 bool AnimationBase::playStatePlaying() const |
| 103 { | 103 { |
| 104 return m_animation->playState() == AnimPlayStatePlaying; | 104 return m_animation->playState() == AnimPlayStatePlaying; |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool AnimationBase::animationsMatch(const Animation* anim) const | 107 bool AnimationBase::animationsMatch(const PrimitiveAnimation* anim) const |
| 108 { | 108 { |
| 109 return m_animation->animationsMatch(anim); | 109 return m_animation->animationsMatch(anim); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void AnimationBase::updateStateMachine(AnimStateInput input, double param) | 112 void AnimationBase::updateStateMachine(AnimStateInput input, double param) |
| 113 { | 113 { |
| 114 if (!m_compAnim) | 114 if (!m_compAnim) |
| 115 return; | 115 return; |
| 116 | 116 |
| 117 // If we get AnimationStateInputRestartAnimation then we force a new animati
on, regardless of state. | 117 // If we get AnimationStateInputRestartAnimation then we force a new animati
on, regardless of state. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 // concept in AnimationTimeController. So we need to somehow sync the two. U
ntil then, the possible | 484 // concept in AnimationTimeController. So we need to somehow sync the two. U
ntil then, the possible |
| 485 // error is small and will probably not be noticeable. Until we fix this, re
move the assert. | 485 // error is small and will probably not be noticeable. Until we fix this, re
move the assert. |
| 486 // https://bugs.webkit.org/show_bug.cgi?id=52037 | 486 // https://bugs.webkit.org/show_bug.cgi?id=52037 |
| 487 // ASSERT(fractionalTime >= 0); | 487 // ASSERT(fractionalTime >= 0); |
| 488 if (fractionalTime < 0) | 488 if (fractionalTime < 0) |
| 489 fractionalTime = 0; | 489 fractionalTime = 0; |
| 490 | 490 |
| 491 int integralTime = static_cast<int>(fractionalTime); | 491 int integralTime = static_cast<int>(fractionalTime); |
| 492 const int integralIterationCount = static_cast<int>(m_animation->iterationCo
unt()); | 492 const int integralIterationCount = static_cast<int>(m_animation->iterationCo
unt()); |
| 493 const bool iterationCountHasFractional = m_animation->iterationCount() - int
egralIterationCount; | 493 const bool iterationCountHasFractional = m_animation->iterationCount() - int
egralIterationCount; |
| 494 if (m_animation->iterationCount() != Animation::IterationCountInfinite && !i
terationCountHasFractional) | 494 if (m_animation->iterationCount() != PrimitiveAnimation::IterationCountInfin
ite && !iterationCountHasFractional) |
| 495 integralTime = min(integralTime, integralIterationCount - 1); | 495 integralTime = min(integralTime, integralIterationCount - 1); |
| 496 | 496 |
| 497 fractionalTime -= integralTime; | 497 fractionalTime -= integralTime; |
| 498 | 498 |
| 499 if (((m_animation->direction() == Animation::AnimationDirectionAlternate) &&
(integralTime & 1)) | 499 if (((m_animation->direction() == PrimitiveAnimation::AnimationDirectionAlte
rnate) && (integralTime & 1)) |
| 500 || ((m_animation->direction() == Animation::AnimationDirectionAlternateR
everse) && !(integralTime & 1)) | 500 || ((m_animation->direction() == PrimitiveAnimation::AnimationDirectionA
lternateReverse) && !(integralTime & 1)) |
| 501 || m_animation->direction() == Animation::AnimationDirectionReverse) | 501 || m_animation->direction() == PrimitiveAnimation::AnimationDirectionRev
erse) |
| 502 fractionalTime = 1 - fractionalTime; | 502 fractionalTime = 1 - fractionalTime; |
| 503 | 503 |
| 504 if (scale != 1 || offset) | 504 if (scale != 1 || offset) |
| 505 fractionalTime = (fractionalTime - offset) * scale; | 505 fractionalTime = (fractionalTime - offset) * scale; |
| 506 | 506 |
| 507 return fractionalTime; | 507 return fractionalTime; |
| 508 } | 508 } |
| 509 | 509 |
| 510 double AnimationBase::progress(double scale, double offset, const TimingFunction
* tf) const | 510 double AnimationBase::progress(double scale, double offset, const TimingFunction
* tf) const |
| 511 { | 511 { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 return m_pauseTime - m_startTime; | 612 return m_pauseTime - m_startTime; |
| 613 if (m_startTime <= 0) | 613 if (m_startTime <= 0) |
| 614 return 0; | 614 return 0; |
| 615 if (postActive()) | 615 if (postActive()) |
| 616 return 1; | 616 return 1; |
| 617 | 617 |
| 618 return beginAnimationUpdateTime() - m_startTime; | 618 return beginAnimationUpdateTime() - m_startTime; |
| 619 } | 619 } |
| 620 | 620 |
| 621 } // namespace WebCore | 621 } // namespace WebCore |
| OLD | NEW |