Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 TimedItem::TimedItem(const Timing& timing, PassOwnPtr<TimedItemEventDelegate> ev entDelegate) | 37 TimedItem::TimedItem(const Timing& timing, PassOwnPtr<TimedItemEventDelegate> ev entDelegate) |
| 38 : m_parent(0) | 38 : m_parent(0) |
| 39 , m_player(0) | 39 , m_player(0) |
| 40 , m_startTime(0) | 40 , m_startTime(0) |
| 41 , m_specified(timing) | 41 , m_specified(timing) |
| 42 , m_calculated() | 42 , m_calculated() |
| 43 , m_eventDelegate(eventDelegate) | 43 , m_eventDelegate(eventDelegate) |
| 44 , m_isFirstSample(true) | |
| 44 { | 45 { |
| 45 timing.assertValid(); | 46 timing.assertValid(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void TimedItem::updateInheritedTime(double inheritedTime) const | 49 void TimedItem::updateInheritedTime(double inheritedTime) const |
| 49 { | 50 { |
| 50 const double localTime = inheritedTime - m_startTime; | 51 const double localTime = inheritedTime - m_startTime; |
| 51 const double iterationDuration = m_specified.hasIterationDuration | 52 const double iterationDuration = m_specified.hasIterationDuration |
| 52 ? m_specified.iterationDuration | 53 ? m_specified.iterationDuration |
| 53 : intrinsicIterationDuration(); | 54 : intrinsicIterationDuration(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 79 const double newLocalTime = localTime < m_specified.startDelay ? m_speci fied.startDelay - 1 : activeDuration + m_specified.startDelay; | 80 const double newLocalTime = localTime < m_specified.startDelay ? m_speci fied.startDelay - 1 : activeDuration + m_specified.startDelay; |
| 80 const TimedItem::Phase phase = calculatePhase(activeDuration, newLocalTi me, m_specified); | 81 const TimedItem::Phase phase = calculatePhase(activeDuration, newLocalTi me, m_specified); |
| 81 const double activeTime = calculateActiveTime(activeDuration, newLocalTi me, parentPhase, phase, m_specified); | 82 const double activeTime = calculateActiveTime(activeDuration, newLocalTi me, parentPhase, phase, m_specified); |
| 82 const double startOffset = m_specified.iterationStart * iterationDuratio n; | 83 const double startOffset = m_specified.iterationStart * iterationDuratio n; |
| 83 const double scaledActiveTime = calculateScaledActiveTime(activeDuration , activeTime, startOffset, m_specified); | 84 const double scaledActiveTime = calculateScaledActiveTime(activeDuration , activeTime, startOffset, m_specified); |
| 84 const double iterationTime = calculateIterationTime(iterationDuration, r epeatedDuration, scaledActiveTime, startOffset, m_specified); | 85 const double iterationTime = calculateIterationTime(iterationDuration, r epeatedDuration, scaledActiveTime, startOffset, m_specified); |
| 85 | 86 |
| 86 currentIteration = calculateCurrentIteration(iterationDuration, iteratio nTime, scaledActiveTime, m_specified); | 87 currentIteration = calculateCurrentIteration(iterationDuration, iteratio nTime, scaledActiveTime, m_specified); |
| 87 timeFraction = calculateTransformedTime(currentIteration, iterationDurat ion, iterationTime, m_specified); | 88 timeFraction = calculateTransformedTime(currentIteration, iterationDurat ion, iterationTime, m_specified); |
| 88 } | 89 } |
| 89 | |
| 90 const double lastIteration = m_calculated.currentIteration; | |
| 91 m_calculated.currentIteration = currentIteration; | |
| 92 m_calculated.activeDuration = activeDuration; | 90 m_calculated.activeDuration = activeDuration; |
| 93 m_calculated.timeFraction = timeFraction; | 91 m_calculated.timeFraction = timeFraction; |
| 94 | 92 |
| 93 const bool newIsInPlay = phase == PhaseActive && (!m_parent || m_parent->isI nPlay()); | |
| 94 const bool newIsCurrent = phase == PhaseBefore || newIsInPlay || (m_parent & & m_parent->isCurrent()); | |
| 95 | |
| 95 const bool wasInEffect = m_calculated.isInEffect; | 96 const bool wasInEffect = m_calculated.isInEffect; |
| 96 const bool wasInPlay = m_calculated.isInPlay; | |
| 97 m_calculated.isInEffect = !isNull(activeTime); | 97 m_calculated.isInEffect = !isNull(activeTime); |
| 98 m_calculated.isInPlay = phase == PhaseActive && (!m_parent || m_parent->isIn Play()); | |
| 99 m_calculated.isCurrent = phase == PhaseBefore || isInPlay() || (m_parent && m_parent->isCurrent()); | |
| 100 | 98 |
| 101 // This logic is specific to CSS events and assumes that all animations | 99 // This logic is specific to CSS events and assumes that all animations |
| 102 // start after the DocumentTimeline has started. | 100 // start after the DocumentTimeline has started. |
| 103 if (m_eventDelegate && (isInPlay() != wasInPlay || (isInPlay() && lastIterat ion != currentIteration))) | 101 |
| 104 m_eventDelegate->onEventCondition(wasInPlay, isInPlay(), lastIteration, currentIteration); | 102 // If this is the first sample, fake the values for the previous sample to |
| 103 // avoid spurious events. | |
| 104 const double lastIteration = m_isFirstSample ? currentIteration : m_calculat ed.currentIteration; | |
| 105 const bool wasInPlay = m_isFirstSample ? newIsInPlay : m_calculated.isInPlay ; | |
| 106 const bool wasCurrent = m_isFirstSample ? newIsCurrent : m_calculated.isCurr ent; | |
| 107 m_isFirstSample = false; | |
| 108 | |
| 109 m_calculated.currentIteration = currentIteration; | |
| 110 m_calculated.isInPlay = newIsInPlay; | |
| 111 m_calculated.isCurrent = newIsCurrent; | |
| 112 | |
| 113 if (m_eventDelegate && (isInPlay() != wasInPlay || isCurrent() != wasCurrent || (wasInPlay && isInPlay() && lastIteration != currentIteration))) | |
|
dstockwell
2013/08/21 02:29:44
This is getting complicated. I wonder if instead o
dstockwell
2013/08/21 04:37:36
Oops, I guess that's: None -> (Active | After) = s
| |
| 114 m_eventDelegate->onEventCondition(wasInPlay, isInPlay(), wasCurrent, isC urrent(), lastIteration, currentIteration); | |
| 105 | 115 |
| 106 // FIXME: This probably shouldn't be recursive. | 116 // FIXME: This probably shouldn't be recursive. |
| 107 updateChildrenAndEffects(wasInEffect); | 117 updateChildrenAndEffects(wasInEffect); |
| 108 } | 118 } |
| 109 | 119 |
| 110 TimedItem::CalculatedTiming::CalculatedTiming() | |
| 111 : activeDuration(nullValue()) | |
| 112 , currentIteration(nullValue()) | |
| 113 , timeFraction(nullValue()) | |
| 114 , isCurrent(false) | |
| 115 , isInEffect(false) | |
| 116 , isInPlay(false) | |
| 117 { | |
| 118 } | |
| 119 | |
| 120 } // namespace WebCore | 120 } // namespace WebCore |
| OLD | NEW |