| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 static AnimationStack* ensureAnimationStack(Element* element) | 59 static AnimationStack* ensureAnimationStack(Element* element) |
| 60 { | 60 { |
| 61 return element->ensureActiveAnimations()->defaultStack(); | 61 return element->ensureActiveAnimations()->defaultStack(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void Animation::applyEffects(bool previouslyInEffect) | 64 void Animation::applyEffects(bool previouslyInEffect) |
| 65 { | 65 { |
| 66 ASSERT(player()); | 66 ASSERT(player()); |
| 67 if (!m_target || !m_effect) |
| 68 return; |
| 69 |
| 67 if (!previouslyInEffect) { | 70 if (!previouslyInEffect) { |
| 68 ensureAnimationStack(m_target.get())->add(this); | 71 ensureAnimationStack(m_target.get())->add(this); |
| 69 m_activeInAnimationStack = true; | 72 m_activeInAnimationStack = true; |
| 70 } | 73 } |
| 74 |
| 71 m_compositableValues = m_effect->sample(currentIteration(), timeFraction()); | 75 m_compositableValues = m_effect->sample(currentIteration(), timeFraction()); |
| 72 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); | 76 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
| 73 } | 77 } |
| 74 | 78 |
| 75 void Animation::clearEffects() | 79 void Animation::clearEffects() |
| 76 { | 80 { |
| 77 ASSERT(player()); | 81 ASSERT(player()); |
| 78 ASSERT(m_activeInAnimationStack); | 82 ASSERT(m_activeInAnimationStack); |
| 79 ensureAnimationStack(m_target.get())->remove(this); | 83 ensureAnimationStack(m_target.get())->remove(this); |
| 80 m_activeInAnimationStack = false; | 84 m_activeInAnimationStack = false; |
| 81 m_compositableValues.clear(); | 85 m_compositableValues.clear(); |
| 82 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); | 86 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
| 83 } | 87 } |
| 84 | 88 |
| 85 void Animation::updateChildrenAndEffects(bool wasInEffect) const | 89 void Animation::updateChildrenAndEffects(bool wasInEffect) const |
| 86 { | 90 { |
| 91 if (!m_effect) |
| 92 return; |
| 93 |
| 87 ASSERT(m_activeInAnimationStack == wasInEffect); | 94 ASSERT(m_activeInAnimationStack == wasInEffect); |
| 88 if (isInEffect()) | 95 if (isInEffect()) |
| 89 const_cast<Animation*>(this)->applyEffects(wasInEffect); | 96 const_cast<Animation*>(this)->applyEffects(wasInEffect); |
| 90 else if (wasInEffect) | 97 else if (wasInEffect) |
| 91 const_cast<Animation*>(this)->clearEffects(); | 98 const_cast<Animation*>(this)->clearEffects(); |
| 92 } | 99 } |
| 93 | 100 |
| 101 double Animation::calculateTimeToEffectChange(double inheritedTime, double activ
eTime, Phase phase) const |
| 102 { |
| 103 switch (phase) { |
| 104 case PhaseBefore: |
| 105 return activeTime - inheritedTime; |
| 106 case PhaseActive: |
| 107 return 0; |
| 108 case PhaseAfter: |
| 109 // If this Animation is still in effect then it will need to update |
| 110 // when its parent goes out of effect. We have no way of knowing when |
| 111 // that will be, however, so the parent will need to supply it. |
| 112 return std::numeric_limits<double>::infinity(); |
| 113 case PhaseNone: |
| 114 default: |
| 115 ASSERT_NOT_REACHED(); |
| 116 return 0; |
| 117 } |
| 118 } |
| 119 |
| 94 } // namespace WebCore | 120 } // namespace WebCore |
| OLD | NEW |