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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 case AnimationEffect::PhaseBefore: | 82 case AnimationEffect::PhaseBefore: |
| 83 if (fillMode == Timing::FillModeBackwards || fillMode == Timing::FillMod eBoth) | 83 if (fillMode == Timing::FillModeBackwards || fillMode == Timing::FillMod eBoth) |
| 84 return 0; | 84 return 0; |
| 85 return nullValue(); | 85 return nullValue(); |
| 86 case AnimationEffect::PhaseActive: | 86 case AnimationEffect::PhaseActive: |
| 87 if (isActiveInParentPhase(parentPhase, fillMode)) | 87 if (isActiveInParentPhase(parentPhase, fillMode)) |
| 88 return localTime - specified.startDelay; | 88 return localTime - specified.startDelay; |
| 89 return nullValue(); | 89 return nullValue(); |
| 90 case AnimationEffect::PhaseAfter: | 90 case AnimationEffect::PhaseAfter: |
| 91 if (fillMode == Timing::FillModeForwards || fillMode == Timing::FillMode Both) | 91 if (fillMode == Timing::FillModeForwards || fillMode == Timing::FillMode Both) |
| 92 return activeDuration; | 92 return std::max(0.0, std::min(activeDuration, activeDuration + speci fied.endDelay)); |
| 93 return nullValue(); | 93 return nullValue(); |
| 94 case AnimationEffect::PhaseNone: | 94 case AnimationEffect::PhaseNone: |
| 95 ASSERT(isNull(localTime)); | 95 ASSERT(isNull(localTime)); |
| 96 return nullValue(); | 96 return nullValue(); |
| 97 default: | 97 default: |
| 98 NOTREACHED(); | 98 NOTREACHED(); |
| 99 return nullValue(); | 99 return nullValue(); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 118 | 118 |
| 119 return multiplyZeroAlwaysGivesZero(specified.playbackRate < 0 ? activeTime - activeDuration : activeTime, specified.playbackRate) + startOffset; | 119 return multiplyZeroAlwaysGivesZero(specified.playbackRate < 0 ? activeTime - activeDuration : activeTime, specified.playbackRate) + startOffset; |
| 120 } | 120 } |
| 121 | 121 |
| 122 static inline bool endsOnIterationBoundary(double iterationCount, double iterati onStart) | 122 static inline bool endsOnIterationBoundary(double iterationCount, double iterati onStart) |
| 123 { | 123 { |
| 124 ASSERT(std::isfinite(iterationCount)); | 124 ASSERT(std::isfinite(iterationCount)); |
| 125 return !fmod(iterationCount + iterationStart, 1); | 125 return !fmod(iterationCount + iterationStart, 1); |
| 126 } | 126 } |
| 127 | 127 |
| 128 static inline double calculateIterationTime(double iterationDuration, double rep eatedDuration, double scaledActiveTime, double startOffset, const Timing& specif ied) | 128 // TODO(alancutter): Align this function with current Web Animations spec text. |
|
suzyh_UTC10 (ex-contributor)
2016/07/25 00:51:09
Let's start making sure all our TODOs have bugs at
alancutter (OOO until 2018)
2016/07/25 01:44:32
Done.
| |
| 129 static inline double calculateIterationTime(double iterationDuration, double rep eatedDuration, double scaledActiveTime, double startOffset, AnimationEffect::Pha se phase, const Timing& specified) | |
| 129 { | 130 { |
| 130 ASSERT(iterationDuration > 0); | 131 ASSERT(iterationDuration > 0); |
| 131 ASSERT(repeatedDuration == multiplyZeroAlwaysGivesZero(iterationDuration, sp ecified.iterationCount)); | 132 ASSERT(repeatedDuration == multiplyZeroAlwaysGivesZero(iterationDuration, sp ecified.iterationCount)); |
| 132 | 133 |
| 133 if (isNull(scaledActiveTime)) | 134 if (isNull(scaledActiveTime)) |
| 134 return nullValue(); | 135 return nullValue(); |
| 135 | 136 |
| 136 ASSERT(scaledActiveTime >= 0); | 137 ASSERT(scaledActiveTime >= 0); |
| 137 ASSERT(scaledActiveTime <= repeatedDuration + startOffset); | 138 ASSERT(scaledActiveTime <= repeatedDuration + startOffset); |
| 138 | 139 |
| 139 if (!std::isfinite(scaledActiveTime) | 140 if (!std::isfinite(scaledActiveTime) |
| 140 || (scaledActiveTime - startOffset == repeatedDuration && specified.iter ationCount && endsOnIterationBoundary(specified.iterationCount, specified.iterat ionStart))) | 141 || (scaledActiveTime - startOffset == repeatedDuration && specified.iter ationCount && endsOnIterationBoundary(specified.iterationCount, specified.iterat ionStart))) |
| 141 return iterationDuration; | 142 return iterationDuration; |
| 142 | 143 |
| 143 ASSERT(std::isfinite(scaledActiveTime)); | 144 ASSERT(std::isfinite(scaledActiveTime)); |
| 144 return fmod(scaledActiveTime, iterationDuration); | 145 double iterationTime = fmod(scaledActiveTime, iterationDuration); |
| 146 | |
| 147 // This implements step 3 of | |
| 148 // http://w3c.github.io/web-animations/#calculating-the-simple-iteration-pro gress | |
| 149 if (iterationTime == 0 | |
| 150 && phase == AnimationEffect::PhaseAfter | |
| 151 && repeatedDuration != 0 | |
| 152 && scaledActiveTime != 0) | |
| 153 return iterationDuration; | |
| 154 | |
| 155 return iterationTime; | |
| 145 } | 156 } |
| 146 | 157 |
| 147 static inline double calculateCurrentIteration(double iterationDuration, double iterationTime, double scaledActiveTime, const Timing& specified) | 158 static inline double calculateCurrentIteration(double iterationDuration, double iterationTime, double scaledActiveTime, const Timing& specified) |
| 148 { | 159 { |
| 149 ASSERT(iterationDuration > 0); | 160 ASSERT(iterationDuration > 0); |
| 150 ASSERT(isNull(iterationTime) || iterationTime >= 0); | 161 ASSERT(isNull(iterationTime) || iterationTime >= 0); |
| 151 | 162 |
| 152 if (isNull(scaledActiveTime)) | 163 if (isNull(scaledActiveTime)) |
| 153 return nullValue(); | 164 return nullValue(); |
| 154 | 165 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 if (!std::isfinite(iterationDuration)) | 208 if (!std::isfinite(iterationDuration)) |
| 198 return directedTime; | 209 return directedTime; |
| 199 double timeFraction = directedTime / iterationDuration; | 210 double timeFraction = directedTime / iterationDuration; |
| 200 ASSERT(timeFraction >= 0 && timeFraction <= 1); | 211 ASSERT(timeFraction >= 0 && timeFraction <= 1); |
| 201 return multiplyZeroAlwaysGivesZero(iterationDuration, specified.timingFuncti on->evaluate(timeFraction, accuracyForDuration(iterationDuration))); | 212 return multiplyZeroAlwaysGivesZero(iterationDuration, specified.timingFuncti on->evaluate(timeFraction, accuracyForDuration(iterationDuration))); |
| 202 } | 213 } |
| 203 | 214 |
| 204 } // namespace blink | 215 } // namespace blink |
| 205 | 216 |
| 206 #endif | 217 #endif |
| OLD | NEW |