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

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

Issue 2236193002: WIP: Implement CSS transitions on top of InterpolationTypes instead of AnimatableValues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_environmentStyle
Patch Set: Created 4 years, 4 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: third_party/WebKit/Source/core/animation/KeyframeInterpolation.cpp
diff --git a/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp b/third_party/WebKit/Source/core/animation/KeyframeInterpolation.cpp
similarity index 72%
rename from third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp
rename to third_party/WebKit/Source/core/animation/KeyframeInterpolation.cpp
index 7f1b47cf075b3b69e3ec055e37f57e78165e52df..7c4265c539933a99d47a16c800074d260404ed22 100644
--- a/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp
+++ b/third_party/WebKit/Source/core/animation/KeyframeInterpolation.cpp
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/animation/InvalidatableInterpolation.h"
+#include "core/animation/KeyframeInterpolation.h"
#include "core/animation/InterpolationEnvironment.h"
#include "core/animation/StringKeyframe.h"
@@ -11,40 +11,35 @@
namespace blink {
-void InvalidatableInterpolation::interpolate(int, double fraction)
+void KeyframeInterpolation::interpolateImpl()
{
- if (fraction == m_currentFraction)
- return;
+ DCHECK(m_previousFraction != m_currentFraction);
- if (m_currentFraction == 0 || m_currentFraction == 1 || fraction == 0 || fraction == 1)
+ if (m_previousFraction == 0 || m_previousFraction == 1 || m_currentFraction == 0 || m_currentFraction == 1)
clearCache();
- m_currentFraction = fraction;
+ m_previousFraction = m_currentFraction;
if (m_isCached && m_cachedPairConversion)
- m_cachedPairConversion->interpolateValue(fraction, m_cachedValue);
+ m_cachedPairConversion->interpolateValue(m_currentFraction, m_cachedValue);
// We defer the interpolation to ensureValidInterpolation() if m_cachedPairConversion is null.
}
-std::unique_ptr<PairwisePrimitiveInterpolation> InvalidatableInterpolation::maybeConvertPairwise(const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
+std::unique_ptr<PairwisePrimitiveInterpolation> KeyframeInterpolation::maybeConvertPairwise(const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
{
- ASSERT(m_currentFraction != 0 && m_currentFraction != 1);
+ DCHECK(m_currentFraction != 0 && m_currentFraction != 1);
for (const auto& interpolationType : m_interpolationTypes) {
if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && (!underlyingValueOwner || underlyingValueOwner.type() != *interpolationType))
continue;
ConversionCheckers conversionCheckers;
PairwiseInterpolationValue result = interpolationType->maybeConvertPairwise(*m_startKeyframe, *m_endKeyframe, environment, underlyingValueOwner.value(), conversionCheckers);
addConversionCheckers(*interpolationType, conversionCheckers);
- if (result) {
- return PairwisePrimitiveInterpolation::create(*interpolationType,
- std::move(result.startInterpolableValue),
- std::move(result.endInterpolableValue),
- result.nonInterpolableValue.release());
- }
+ if (result)
+ return PairwisePrimitiveInterpolation::create(*interpolationType, std::move(result));
}
return nullptr;
}
-std::unique_ptr<TypedInterpolationValue> InvalidatableInterpolation::convertSingleKeyframe(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
+std::unique_ptr<TypedInterpolationValue> KeyframeInterpolation::convertSingleKeyframe(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
{
if (keyframe.isNeutral() && !underlyingValueOwner)
return nullptr;
@@ -55,13 +50,13 @@ std::unique_ptr<TypedInterpolationValue> InvalidatableInterpolation::convertSing
InterpolationValue result = interpolationType->maybeConvertSingle(keyframe, environment, underlyingValueOwner.value(), conversionCheckers);
addConversionCheckers(*interpolationType, conversionCheckers);
if (result)
- return TypedInterpolationValue::create(*interpolationType, std::move(result.interpolableValue), result.nonInterpolableValue.release());
+ return TypedInterpolationValue::create(*interpolationType, std::move(result));
}
- ASSERT(keyframe.isNeutral());
+ DCHECK(keyframe.isNeutral());
return nullptr;
}
-void InvalidatableInterpolation::addConversionCheckers(const InterpolationType& type, ConversionCheckers& conversionCheckers) const
+void KeyframeInterpolation::addConversionCheckers(const InterpolationType& type, ConversionCheckers& conversionCheckers) const
{
for (size_t i = 0; i < conversionCheckers.size(); i++) {
conversionCheckers[i]->setType(type);
@@ -69,27 +64,27 @@ void InvalidatableInterpolation::addConversionCheckers(const InterpolationType&
}
}
-std::unique_ptr<TypedInterpolationValue> InvalidatableInterpolation::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
+std::unique_ptr<TypedInterpolationValue> KeyframeInterpolation::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
{
for (const auto& interpolationType : m_interpolationTypes) {
InterpolationValue result = interpolationType->maybeConvertUnderlyingValue(environment);
if (result)
- return TypedInterpolationValue::create(*interpolationType, std::move(result.interpolableValue), result.nonInterpolableValue.release());
+ return TypedInterpolationValue::create(*interpolationType, std::move(result));
}
return nullptr;
}
-bool InvalidatableInterpolation::dependsOnUnderlyingValue() const
+bool KeyframeInterpolation::dependsOnUnderlyingValue() const
{
return (m_startKeyframe->underlyingFraction() != 0 && m_currentFraction != 1) || (m_endKeyframe->underlyingFraction() != 0 && m_currentFraction != 0);
}
-bool InvalidatableInterpolation::isNeutralKeyframeActive() const
+bool KeyframeInterpolation::isNeutralKeyframeActive() const
{
return (m_startKeyframe->isNeutral() && m_currentFraction != 1) || (m_endKeyframe->isNeutral() && m_currentFraction != 0);
}
-void InvalidatableInterpolation::clearCache() const
+void KeyframeInterpolation::clearCache() const
{
m_isCached = false;
m_cachedPairConversion.reset();
@@ -97,7 +92,7 @@ void InvalidatableInterpolation::clearCache() const
m_cachedValue.reset();
}
-bool InvalidatableInterpolation::isCacheValid(const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
+bool KeyframeInterpolation::isCacheValid(const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
{
if (!m_isCached)
return false;
@@ -115,9 +110,9 @@ bool InvalidatableInterpolation::isCacheValid(const InterpolationEnvironment& en
return true;
}
-const TypedInterpolationValue* InvalidatableInterpolation::ensureValidInterpolation(const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
+const TypedInterpolationValue* KeyframeInterpolation::ensureValidInterpolation(const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
{
- ASSERT(!std::isnan(m_currentFraction));
+ DCHECK(!std::isnan(m_currentFraction));
if (isCacheValid(environment, underlyingValueOwner))
return m_cachedValue.get();
clearCache();
@@ -141,7 +136,7 @@ const TypedInterpolationValue* InvalidatableInterpolation::ensureValidInterpolat
return m_cachedValue.get();
}
-void InvalidatableInterpolation::setFlagIfInheritUsed(InterpolationEnvironment& environment) const
+void KeyframeInterpolation::setFlagIfInheritUsed(InterpolationEnvironment& environment) const
{
if (!m_property.isCSSProperty() && !m_property.isPresentationAttribute())
return;
@@ -155,7 +150,7 @@ void InvalidatableInterpolation::setFlagIfInheritUsed(InterpolationEnvironment&
}
}
-double InvalidatableInterpolation::underlyingFraction() const
+double KeyframeInterpolation::underlyingFraction() const
{
if (m_currentFraction == 0)
return m_startKeyframe->underlyingFraction();
@@ -164,14 +159,14 @@ double InvalidatableInterpolation::underlyingFraction() const
return m_cachedPairConversion->interpolateUnderlyingFraction(m_startKeyframe->underlyingFraction(), m_endKeyframe->underlyingFraction(), m_currentFraction);
}
-void InvalidatableInterpolation::applyStack(const ActiveInterpolations& interpolations, InterpolationEnvironment& environment)
+void KeyframeInterpolation::applyStack(const ActiveInterpolations& interpolations, InterpolationEnvironment& environment)
{
- ASSERT(!interpolations.isEmpty());
+ DCHECK(!interpolations.isEmpty());
size_t startingIndex = 0;
// Compute the underlying value to composite onto.
UnderlyingValueOwner underlyingValueOwner;
- const InvalidatableInterpolation& firstInterpolation = toInvalidatableInterpolation(*interpolations.at(startingIndex));
+ const KeyframeInterpolation& firstInterpolation = toKeyframeInterpolation(*interpolations.at(startingIndex));
if (firstInterpolation.dependsOnUnderlyingValue()) {
underlyingValueOwner.set(firstInterpolation.maybeConvertUnderlyingValue(environment));
} else {
@@ -191,8 +186,8 @@ void InvalidatableInterpolation::applyStack(const ActiveInterpolations& interpol
// Composite interpolations onto the underlying value.
bool shouldApply = false;
for (size_t i = startingIndex; i < interpolations.size(); i++) {
- const InvalidatableInterpolation& currentInterpolation = toInvalidatableInterpolation(*interpolations.at(i));
- ASSERT(currentInterpolation.dependsOnUnderlyingValue());
+ const KeyframeInterpolation& currentInterpolation = toKeyframeInterpolation(*interpolations.at(i));
+ DCHECK(currentInterpolation.dependsOnUnderlyingValue());
const TypedInterpolationValue* currentValue = currentInterpolation.ensureValidInterpolation(environment, underlyingValueOwner);
if (!currentValue)
continue;

Powered by Google App Engine
This is Rietveld 408576698