| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/animation/KeyframeEffectReadOnly.h" | 5 #include "core/animation/KeyframeEffectReadOnly.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/animation/Animation.h" | 9 #include "core/animation/Animation.h" |
| 10 #include "core/animation/CompositorAnimations.h" | 10 #include "core/animation/CompositorAnimations.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 void KeyframeEffectReadOnly::specifiedTimingChanged() { | 124 void KeyframeEffectReadOnly::specifiedTimingChanged() { |
| 125 if (animation()) { | 125 if (animation()) { |
| 126 // FIXME: Needs to consider groups when added. | 126 // FIXME: Needs to consider groups when added. |
| 127 DCHECK_EQ(animation()->effect(), this); | 127 DCHECK_EQ(animation()->effect(), this); |
| 128 animation()->setCompositorPending(true); | 128 animation()->setCompositorPending(true); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 static AnimationStack& ensureAnimationStack(Element* element) { | 132 static EffectStack& ensureEffectStack(Element* element) { |
| 133 return element->ensureElementAnimations().animationStack(); | 133 return element->ensureElementAnimations().effectStack(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool KeyframeEffectReadOnly::hasMultipleTransformProperties() const { | 136 bool KeyframeEffectReadOnly::hasMultipleTransformProperties() const { |
| 137 if (!m_target->computedStyle()) | 137 if (!m_target->computedStyle()) |
| 138 return false; | 138 return false; |
| 139 | 139 |
| 140 unsigned transformPropertyCount = 0; | 140 unsigned transformPropertyCount = 0; |
| 141 if (m_target->computedStyle()->hasTransformOperations()) | 141 if (m_target->computedStyle()->hasTransformOperations()) |
| 142 transformPropertyCount++; | 142 transformPropertyCount++; |
| 143 if (m_target->computedStyle()->rotate()) | 143 if (m_target->computedStyle()->rotate()) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 iterationDuration(), | 188 iterationDuration(), |
| 189 m_sampledEffect->mutableInterpolations()); | 189 m_sampledEffect->mutableInterpolations()); |
| 190 } else { | 190 } else { |
| 191 Vector<RefPtr<Interpolation>> interpolations; | 191 Vector<RefPtr<Interpolation>> interpolations; |
| 192 m_model->sample(clampTo<int>(iteration, 0), progress(), iterationDuration(), | 192 m_model->sample(clampTo<int>(iteration, 0), progress(), iterationDuration(), |
| 193 interpolations); | 193 interpolations); |
| 194 if (!interpolations.isEmpty()) { | 194 if (!interpolations.isEmpty()) { |
| 195 SampledEffect* sampledEffect = SampledEffect::create(this); | 195 SampledEffect* sampledEffect = SampledEffect::create(this); |
| 196 sampledEffect->mutableInterpolations().swap(interpolations); | 196 sampledEffect->mutableInterpolations().swap(interpolations); |
| 197 m_sampledEffect = sampledEffect; | 197 m_sampledEffect = sampledEffect; |
| 198 ensureAnimationStack(m_target).add(sampledEffect); | 198 ensureEffectStack(m_target).add(sampledEffect); |
| 199 changed = true; | 199 changed = true; |
| 200 } else { | 200 } else { |
| 201 return; | 201 return; |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 if (changed) { | 205 if (changed) { |
| 206 m_target->setNeedsAnimationStyleRecalc(); | 206 m_target->setNeedsAnimationStyleRecalc(); |
| 207 if (RuntimeEnabledFeatures::webAnimationsSVGEnabled() && | 207 if (RuntimeEnabledFeatures::webAnimationsSVGEnabled() && |
| 208 m_target->isSVGElement()) | 208 m_target->isSVGElement()) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // when its parent goes out of effect. We have no way of knowing when | 266 // when its parent goes out of effect. We have no way of knowing when |
| 267 // that will be, however, so the parent will need to supply it. | 267 // that will be, however, so the parent will need to supply it. |
| 268 return forwards ? std::numeric_limits<double>::infinity() | 268 return forwards ? std::numeric_limits<double>::infinity() |
| 269 : localTime - afterTime; | 269 : localTime - afterTime; |
| 270 default: | 270 default: |
| 271 NOTREACHED(); | 271 NOTREACHED(); |
| 272 return std::numeric_limits<double>::infinity(); | 272 return std::numeric_limits<double>::infinity(); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 void KeyframeEffectReadOnly::notifySampledEffectRemovedFromAnimationStack() { | 276 void KeyframeEffectReadOnly::notifySampledEffectRemovedFromEffectStack() { |
| 277 m_sampledEffect = nullptr; | 277 m_sampledEffect = nullptr; |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool KeyframeEffectReadOnly::isCandidateForAnimationOnCompositor( | 280 bool KeyframeEffectReadOnly::isCandidateForAnimationOnCompositor( |
| 281 double animationPlaybackRate) const { | 281 double animationPlaybackRate) const { |
| 282 // Do not put transforms on compositor if more than one of them are defined | 282 // Do not put transforms on compositor if more than one of them are defined |
| 283 // in computed style because they need to be explicitly ordered | 283 // in computed style because they need to be explicitly ordered |
| 284 if (!model() || !m_target || | 284 if (!model() || !m_target || |
| 285 (m_target->computedStyle() && m_target->computedStyle()->hasOffset()) || | 285 (m_target->computedStyle() && m_target->computedStyle()->hasOffset()) || |
| 286 hasMultipleTransformProperties()) | 286 hasMultipleTransformProperties()) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 370 } |
| 371 | 371 |
| 372 DEFINE_TRACE(KeyframeEffectReadOnly) { | 372 DEFINE_TRACE(KeyframeEffectReadOnly) { |
| 373 visitor->trace(m_target); | 373 visitor->trace(m_target); |
| 374 visitor->trace(m_model); | 374 visitor->trace(m_model); |
| 375 visitor->trace(m_sampledEffect); | 375 visitor->trace(m_sampledEffect); |
| 376 AnimationEffectReadOnly::trace(visitor); | 376 AnimationEffectReadOnly::trace(visitor); |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace blink | 379 } // namespace blink |
| OLD | NEW |