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 CSSAnimationData* transition, RenderObject* r
enderer, 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<CSSAnimationData*>(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 if (node) | 92 if (node) |
93 node->setNeedsStyleRecalc(SyntheticStyleChange); | 93 node->setNeedsStyleRecalc(SyntheticStyleChange); |
94 } | 94 } |
95 | 95 |
96 double AnimationBase::duration() const | 96 double AnimationBase::duration() const |
97 { | 97 { |
98 return m_animation->duration(); | 98 return m_animation->duration(); |
99 } | 99 } |
100 | 100 |
101 bool AnimationBase::playStatePlaying() const | 101 bool AnimationBase::playStatePlaying() const |
102 { | 102 { |
103 return m_animation->playState() == AnimPlayStatePlaying; | 103 return m_animation->playState() == AnimPlayStatePlaying; |
104 } | 104 } |
105 | 105 |
106 bool AnimationBase::animationsMatch(const Animation* anim) const | 106 bool AnimationBase::animationsMatch(const CSSAnimationData* anim) const |
107 { | 107 { |
108 return m_animation->animationsMatch(anim); | 108 return m_animation->animationsMatch(anim); |
109 } | 109 } |
110 | 110 |
111 void AnimationBase::updateStateMachine(AnimStateInput input, double param) | 111 void AnimationBase::updateStateMachine(AnimStateInput input, double param) |
112 { | 112 { |
113 if (!m_compAnim) | 113 if (!m_compAnim) |
114 return; | 114 return; |
115 | 115 |
116 // If we get AnimationStateInputRestartAnimation then we force a new animati
on, regardless of state. | 116 // 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... |
483 // concept in AnimationTimeController. So we need to somehow sync the two. U
ntil then, the possible | 483 // concept in AnimationTimeController. So we need to somehow sync the two. U
ntil then, the possible |
484 // error is small and will probably not be noticeable. Until we fix this, re
move the assert. | 484 // error is small and will probably not be noticeable. Until we fix this, re
move the assert. |
485 // https://bugs.webkit.org/show_bug.cgi?id=52037 | 485 // https://bugs.webkit.org/show_bug.cgi?id=52037 |
486 // ASSERT(fractionalTime >= 0); | 486 // ASSERT(fractionalTime >= 0); |
487 if (fractionalTime < 0) | 487 if (fractionalTime < 0) |
488 fractionalTime = 0; | 488 fractionalTime = 0; |
489 | 489 |
490 int integralTime = static_cast<int>(fractionalTime); | 490 int integralTime = static_cast<int>(fractionalTime); |
491 const int integralIterationCount = static_cast<int>(m_animation->iterationCo
unt()); | 491 const int integralIterationCount = static_cast<int>(m_animation->iterationCo
unt()); |
492 const bool iterationCountHasFractional = m_animation->iterationCount() - int
egralIterationCount; | 492 const bool iterationCountHasFractional = m_animation->iterationCount() - int
egralIterationCount; |
493 if (m_animation->iterationCount() != Animation::IterationCountInfinite && !i
terationCountHasFractional) | 493 if (m_animation->iterationCount() != CSSAnimationData::IterationCountInfinit
e && !iterationCountHasFractional) |
494 integralTime = min(integralTime, integralIterationCount - 1); | 494 integralTime = min(integralTime, integralIterationCount - 1); |
495 | 495 |
496 fractionalTime -= integralTime; | 496 fractionalTime -= integralTime; |
497 | 497 |
498 if (((m_animation->direction() == Animation::AnimationDirectionAlternate) &&
(integralTime & 1)) | 498 if (((m_animation->direction() == CSSAnimationData::AnimationDirectionAltern
ate) && (integralTime & 1)) |
499 || ((m_animation->direction() == Animation::AnimationDirectionAlternateR
everse) && !(integralTime & 1)) | 499 || ((m_animation->direction() == CSSAnimationData::AnimationDirectionAlt
ernateReverse) && !(integralTime & 1)) |
500 || m_animation->direction() == Animation::AnimationDirectionReverse) | 500 || m_animation->direction() == CSSAnimationData::AnimationDirectionRever
se) |
501 fractionalTime = 1 - fractionalTime; | 501 fractionalTime = 1 - fractionalTime; |
502 | 502 |
503 if (scale != 1 || offset) | 503 if (scale != 1 || offset) |
504 fractionalTime = (fractionalTime - offset) * scale; | 504 fractionalTime = (fractionalTime - offset) * scale; |
505 | 505 |
506 return fractionalTime; | 506 return fractionalTime; |
507 } | 507 } |
508 | 508 |
509 double AnimationBase::progress(double scale, double offset, const TimingFunction
* tf) const | 509 double AnimationBase::progress(double scale, double offset, const TimingFunction
* tf) const |
510 { | 510 { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 return m_pauseTime - m_startTime; | 611 return m_pauseTime - m_startTime; |
612 if (m_startTime <= 0) | 612 if (m_startTime <= 0) |
613 return 0; | 613 return 0; |
614 if (postActive()) | 614 if (postActive()) |
615 return 1; | 615 return 1; |
616 | 616 |
617 return beginAnimationUpdateTime() - m_startTime; | 617 return beginAnimationUpdateTime() - m_startTime; |
618 } | 618 } |
619 | 619 |
620 } // namespace WebCore | 620 } // namespace WebCore |
OLD | NEW |