Index: Source/core/animation/LegacyStyleInterpolation.cpp |
diff --git a/Source/core/animation/LegacyStyleInterpolation.cpp b/Source/core/animation/LegacyStyleInterpolation.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e3556692d94121ddb09a3bd539c9042b06487602 |
--- /dev/null |
+++ b/Source/core/animation/LegacyStyleInterpolation.cpp |
@@ -0,0 +1,42 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/animation/LegacyStyleInterpolation.h" |
+ |
+#include "core/css/resolver/AnimatedStyleBuilder.h" |
+#include "core/css/resolver/StyleResolverState.h" |
+ |
+namespace WebCore { |
+ |
+PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> LegacyStyleInterpolation::create(PassRefPtrWillBeRawPtr<InterpolableValuePromise> start, PassRefPtrWillBeRawPtr<InterpolableValuePromise> end, CSSPropertyID id) |
+{ |
+ RefPtrWillBeRawPtr<AnimatableValue> startValue = start->extractAnimatableValue(); |
+ RefPtrWillBeRawPtr<AnimatableValue> endValue = end->extractAnimatableValue(); |
+ if (startValue && endValue) |
+ return create(startValue, endValue, id); |
+ return adoptRefWillBeNoop(new LegacyStyleInterpolation(start, end, id)); |
+} |
+ |
+void LegacyStyleInterpolation::apply(StyleResolverState& state) const |
+{ |
+ if (m_cachedValue) { |
+ AnimatedStyleBuilder::applyProperty(m_id, state, toInterpolableAnimatableValue(m_cachedValue.get())->value()); |
+ } else { |
+ OwnPtrWillBeRawPtr<InterpolableValue> start = m_startPromise->extract(state, m_id); |
+ OwnPtrWillBeRawPtr<InterpolableValue> end = m_endPromise->extract(state, m_id); |
+ OwnPtrWillBeRawPtr<InterpolableValue> interpolated = start->interpolate(*end, m_cachedFraction); |
+ AnimatedStyleBuilder::applyProperty(m_id, state, toInterpolableAnimatableValue(interpolated.get())->value()); |
+ // We avoid caching to remain responsive outside of our active interval. |
+ } |
+} |
+ |
+void LegacyStyleInterpolation::trace(Visitor* visitor) |
+{ |
+ StyleInterpolation::trace(visitor); |
+ visitor->trace(m_startPromise); |
+ visitor->trace(m_endPromise); |
+} |
+ |
+} |