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

Unified Diff: third_party/WebKit/Source/core/animation/TransitionInterpolation.cpp

Issue 2650133002: Add TransitionInterpolation class for CSS Transition refactor (Closed)
Patch Set: lint Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/core/animation/TransitionInterpolation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/animation/TransitionInterpolation.cpp
diff --git a/third_party/WebKit/Source/core/animation/TransitionInterpolation.cpp b/third_party/WebKit/Source/core/animation/TransitionInterpolation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7bb4384b6b19be7b61f0aff0c2a53170ea778794
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/TransitionInterpolation.cpp
@@ -0,0 +1,67 @@
+// Copyright 2017 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 "core/animation/TransitionInterpolation.h"
+
+#include "core/animation/CSSInterpolationTypesMap.h"
+#include "core/animation/InterpolationEnvironment.h"
+#include "core/animation/InterpolationType.h"
+#include "core/css/resolver/StyleResolverState.h"
+
+namespace blink {
+
+void TransitionInterpolation::interpolate(int iteration, double fraction) {
+ if (m_cachedFraction != fraction || m_cachedIteration != iteration) {
+ if (fraction != 0 && fraction != 1) {
+ m_merge.startInterpolableValue->interpolate(
+ *m_merge.endInterpolableValue, fraction, *m_cachedInterpolableValue);
+ }
+ m_cachedIteration = iteration;
+ m_cachedFraction = fraction;
+ }
+}
+
+const InterpolableValue& TransitionInterpolation::currentInterpolableValue()
+ const {
+ if (m_cachedFraction == 0) {
+ return *m_start.interpolableValue;
+ }
+ if (m_cachedFraction == 1) {
+ return *m_end.interpolableValue;
+ }
+ return *m_cachedInterpolableValue;
+}
+
+NonInterpolableValue* TransitionInterpolation::currentNonInterpolableValue()
+ const {
+ if (m_cachedFraction == 0) {
+ return m_start.nonInterpolableValue.get();
+ }
+ if (m_cachedFraction == 1) {
+ return m_end.nonInterpolableValue.get();
+ }
+ return m_merge.nonInterpolableValue.get();
+}
+
+void TransitionInterpolation::apply(StyleResolverState& state) const {
+ CSSInterpolationTypesMap map(state.document().propertyRegistry());
+ InterpolationEnvironment environment(map, state);
+ m_type.apply(currentInterpolableValue(), currentNonInterpolableValue(),
+ environment);
+}
+
+std::unique_ptr<TypedInterpolationValue>
+TransitionInterpolation::getInterpolatedValue() const {
+ return TypedInterpolationValue::create(m_type,
+ currentInterpolableValue().clone(),
+ currentNonInterpolableValue());
+}
+
+RefPtr<AnimatableValue>
+TransitionInterpolation::getInterpolatedCompositorValue() const {
+ return AnimatableValue::interpolate(m_compositorStart.get(),
+ m_compositorEnd.get(), m_cachedFraction);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/animation/TransitionInterpolation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698