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