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

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

Issue 1394343003: Web Animations: Remove CSS dependence from InterpolationType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_specialCase0and1
Patch Set: NIVs Created 5 years, 2 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/InvalidatableStyleInterpolation.cpp
diff --git a/third_party/WebKit/Source/core/animation/InvalidatableStyleInterpolation.cpp b/third_party/WebKit/Source/core/animation/InvalidatableStyleInterpolation.cpp
index 599539f18cbad4d9f40ec985df18fbbddd916ccf..11d5be21003d4722552b1bb22e8d9a7181d62e2a 100644
--- a/third_party/WebKit/Source/core/animation/InvalidatableStyleInterpolation.cpp
+++ b/third_party/WebKit/Source/core/animation/InvalidatableStyleInterpolation.cpp
@@ -5,6 +5,7 @@
#include "config.h"
#include "core/animation/InvalidatableStyleInterpolation.h"
+#include "core/animation/InterpolationEnvironment.h"
#include "core/animation/StringKeyframe.h"
#include "core/css/resolver/StyleResolverState.h"
@@ -24,13 +25,13 @@ void InvalidatableStyleInterpolation::interpolate(int, double fraction)
// We defer the interpolation to ensureValidInterpolation() if m_cachedPairConversion is null.
}
-PassOwnPtr<PairwisePrimitiveInterpolation> InvalidatableStyleInterpolation::maybeConvertPairwise(const StyleResolverState* state, const UnderlyingValue& underlyingValue) const
+PassOwnPtr<PairwisePrimitiveInterpolation> InvalidatableStyleInterpolation::maybeConvertPairwise(const InterpolationEnvironment* environment, const UnderlyingValue& underlyingValue) const
{
ASSERT(m_currentFraction != 0 && m_currentFraction != 1);
for (const auto& interpolationType : m_interpolationTypes) {
if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && (!underlyingValue || underlyingValue->type() != *interpolationType))
continue;
- OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = interpolationType->maybeConvertPairwise(*m_startKeyframe, *m_endKeyframe, state, underlyingValue, m_conversionCheckers);
+ OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = interpolationType->maybeConvertPairwise(*m_startKeyframe, *m_endKeyframe, environment, underlyingValue, m_conversionCheckers);
if (pairwiseConversion) {
ASSERT(pairwiseConversion->type() == *interpolationType);
return pairwiseConversion.release();
@@ -39,14 +40,14 @@ PassOwnPtr<PairwisePrimitiveInterpolation> InvalidatableStyleInterpolation::mayb
return nullptr;
}
-PassOwnPtr<InterpolationValue> InvalidatableStyleInterpolation::convertSingleKeyframe(const CSSPropertySpecificKeyframe& keyframe, const StyleResolverState& state, const UnderlyingValue& underlyingValue) const
+PassOwnPtr<InterpolationValue> InvalidatableStyleInterpolation::convertSingleKeyframe(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment& environment, const UnderlyingValue& underlyingValue) const
{
if (keyframe.isNeutral() && !underlyingValue)
return nullptr;
for (const auto& interpolationType : m_interpolationTypes) {
if (keyframe.isNeutral() && underlyingValue->type() != *interpolationType)
continue;
- OwnPtr<InterpolationValue> result = interpolationType->maybeConvertSingle(keyframe, &state, underlyingValue, m_conversionCheckers);
+ OwnPtr<InterpolationValue> result = interpolationType->maybeConvertSingle(keyframe, &environment, underlyingValue, m_conversionCheckers);
if (result) {
ASSERT(result->type() == *interpolationType);
return result.release();
@@ -56,10 +57,10 @@ PassOwnPtr<InterpolationValue> InvalidatableStyleInterpolation::convertSingleKey
return nullptr;
}
-PassOwnPtr<InterpolationValue> InvalidatableStyleInterpolation::maybeConvertUnderlyingValue(const StyleResolverState& state) const
+PassOwnPtr<InterpolationValue> InvalidatableStyleInterpolation::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
{
for (const auto& interpolationType : m_interpolationTypes) {
- OwnPtr<InterpolationValue> result = interpolationType->maybeConvertUnderlyingValue(state);
+ OwnPtr<InterpolationValue> result = interpolationType->maybeConvertUnderlyingValue(environment);
if (result)
return result.release();
}
@@ -84,7 +85,7 @@ void InvalidatableStyleInterpolation::clearCache() const
m_cachedValue.clear();
}
-bool InvalidatableStyleInterpolation::isCacheValid(const StyleResolverState& state, const UnderlyingValue& underlyingValue) const
+bool InvalidatableStyleInterpolation::isCacheValid(const InterpolationEnvironment& environment, const UnderlyingValue& underlyingValue) const
{
if (!m_isCached)
return false;
@@ -96,31 +97,31 @@ bool InvalidatableStyleInterpolation::isCacheValid(const StyleResolverState& sta
return false;
}
for (const auto& checker : m_conversionCheckers) {
- if (!checker->isValid(state, underlyingValue))
+ if (!checker->isValid(environment, underlyingValue))
return false;
}
return true;
}
-const InterpolationValue* InvalidatableStyleInterpolation::ensureValidInterpolation(const StyleResolverState& state, const UnderlyingValue& underlyingValue) const
+const InterpolationValue* InvalidatableStyleInterpolation::ensureValidInterpolation(const InterpolationEnvironment& environment, const UnderlyingValue& underlyingValue) const
{
ASSERT(!std::isnan(m_currentFraction));
- if (isCacheValid(state, underlyingValue))
+ if (isCacheValid(environment, underlyingValue))
return m_cachedValue.get();
clearCache();
if (m_currentFraction == 0) {
- m_cachedValue = convertSingleKeyframe(*m_startKeyframe, state, underlyingValue);
+ m_cachedValue = convertSingleKeyframe(*m_startKeyframe, environment, underlyingValue);
} else if (m_currentFraction == 1) {
- m_cachedValue = convertSingleKeyframe(*m_endKeyframe, state, underlyingValue);
+ m_cachedValue = convertSingleKeyframe(*m_endKeyframe, environment, underlyingValue);
} else {
- OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = maybeConvertPairwise(&state, underlyingValue);
+ OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = maybeConvertPairwise(&environment, underlyingValue);
if (pairwiseConversion) {
m_cachedValue = pairwiseConversion->initialValue();
m_cachedPairConversion = pairwiseConversion.release();
} else {
m_cachedPairConversion = FlipPrimitiveInterpolation::create(
- convertSingleKeyframe(*m_startKeyframe, state, underlyingValue),
- convertSingleKeyframe(*m_endKeyframe, state, underlyingValue));
+ convertSingleKeyframe(*m_startKeyframe, environment, underlyingValue),
+ convertSingleKeyframe(*m_endKeyframe, environment, underlyingValue));
}
m_cachedPairConversion->interpolateValue(m_currentFraction, m_cachedValue);
}
@@ -128,13 +129,17 @@ const InterpolationValue* InvalidatableStyleInterpolation::ensureValidInterpolat
return m_cachedValue.get();
}
-void InvalidatableStyleInterpolation::setFlagIfInheritUsed(StyleResolverState& state) const
+void InvalidatableStyleInterpolation::setFlagIfInheritUsed(InterpolationEnvironment& environment) const
{
- if (!state.parentStyle())
+ if (!property().isCSSProperty())
return;
- if ((m_startKeyframe->value() && m_startKeyframe->value()->isInheritedValue())
- || (m_endKeyframe->value() && m_endKeyframe->value()->isInheritedValue())) {
- state.parentStyle()->setHasExplicitlyInheritedProperties();
+ if (!environment.state().parentStyle())
+ return;
+ const CSSValue* startValue = toCSSPropertySpecificKeyframe(m_startKeyframe)->value();
+ const CSSValue* endValue = toCSSPropertySpecificKeyframe(m_endKeyframe)->value();
+ if ((startValue && startValue->isInheritedValue())
+ || (endValue && endValue->isInheritedValue())) {
+ environment.state().parentStyle()->setHasExplicitlyInheritedProperties();
}
}
@@ -147,7 +152,7 @@ double InvalidatableStyleInterpolation::underlyingFraction() const
return m_cachedPairConversion->interpolateUnderlyingFraction(m_startKeyframe->underlyingFraction(), m_endKeyframe->underlyingFraction(), m_currentFraction);
}
-void InvalidatableStyleInterpolation::applyStack(const ActiveInterpolations& interpolations, StyleResolverState& state)
+void InvalidatableStyleInterpolation::applyStack(const ActiveInterpolations& interpolations, InterpolationEnvironment& environment)
{
ASSERT(!interpolations.isEmpty());
size_t startingIndex = 0;
@@ -156,14 +161,14 @@ void InvalidatableStyleInterpolation::applyStack(const ActiveInterpolations& int
UnderlyingValue underlyingValue;
const InvalidatableStyleInterpolation& firstInterpolation = toInvalidatableStyleInterpolation(*interpolations.at(startingIndex));
if (firstInterpolation.dependsOnUnderlyingValue()) {
- underlyingValue.set(firstInterpolation.maybeConvertUnderlyingValue(state));
+ underlyingValue.set(firstInterpolation.maybeConvertUnderlyingValue(environment));
} else {
- const InterpolationValue* firstValue = firstInterpolation.ensureValidInterpolation(state, UnderlyingValue());
+ const InterpolationValue* firstValue = firstInterpolation.ensureValidInterpolation(environment, UnderlyingValue());
// Fast path for replace interpolations that are the only one to apply.
if (interpolations.size() == 1) {
if (firstValue) {
- firstInterpolation.setFlagIfInheritUsed(state);
- firstValue->type().apply(firstValue->interpolableValue(), firstValue->nonInterpolableValue(), state);
+ firstInterpolation.setFlagIfInheritUsed(environment);
+ firstValue->type().apply(firstValue->interpolableValue(), firstValue->nonInterpolableValue(), environment);
}
return;
}
@@ -176,11 +181,11 @@ void InvalidatableStyleInterpolation::applyStack(const ActiveInterpolations& int
for (size_t i = startingIndex; i < interpolations.size(); i++) {
const InvalidatableStyleInterpolation& currentInterpolation = toInvalidatableStyleInterpolation(*interpolations.at(i));
ASSERT(currentInterpolation.dependsOnUnderlyingValue());
- const InterpolationValue* currentValue = currentInterpolation.ensureValidInterpolation(state, underlyingValue);
+ const InterpolationValue* currentValue = currentInterpolation.ensureValidInterpolation(environment, underlyingValue);
if (!currentValue)
continue;
shouldApply = true;
- currentInterpolation.setFlagIfInheritUsed(state);
+ currentInterpolation.setFlagIfInheritUsed(environment);
double underlyingFraction = currentInterpolation.underlyingFraction();
if (underlyingFraction == 0 || !underlyingValue || underlyingValue->type() != currentValue->type())
underlyingValue.set(currentValue);
@@ -189,7 +194,7 @@ void InvalidatableStyleInterpolation::applyStack(const ActiveInterpolations& int
}
if (shouldApply && underlyingValue)
- underlyingValue->type().apply(underlyingValue->interpolableValue(), underlyingValue->nonInterpolableValue(), state);
+ underlyingValue->type().apply(underlyingValue->interpolableValue(), underlyingValue->nonInterpolableValue(), environment);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698