Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Unified Diff: Source/core/animation/LegacyStyleInterpolation.cpp

Issue 273683005: Web Animations API: Deferred computation of interpolated values (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix crashing shadow animation tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698