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

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

Issue 851693007: Prepare for responsive CSS animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Attempt to re-snapshot only if needed Created 5 years, 11 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/StringKeyframe.cpp
diff --git a/Source/core/animation/StringKeyframe.cpp b/Source/core/animation/StringKeyframe.cpp
index 0a51b9f18ef14669f7f3b34b5cd5a5f8e970a2ba..fdac06cbbacf3233b707f8d704f5ad4e5ddcb7f1 100644
--- a/Source/core/animation/StringKeyframe.cpp
+++ b/Source/core/animation/StringKeyframe.cpp
@@ -16,6 +16,7 @@
#include "core/animation/LengthPoint3DStyleInterpolation.h"
#include "core/animation/LengthStyleInterpolation.h"
#include "core/animation/VisibilityStyleInterpolation.h"
+#include "core/animation/css/CSSAnimatableValueFactory.h"
#include "core/animation/css/CSSAnimations.h"
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/resolver/StyleResolver.h"
@@ -26,6 +27,7 @@ namespace blink {
StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom)
: Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing)
, m_propertySet(copyFrom.m_propertySet->mutableCopy())
+ , m_cachedAnimatableValues(copyFrom.m_cachedAnimatableValues)
{
}
@@ -36,6 +38,20 @@ void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
m_propertySet->setProperty(property, value, false, styleSheetContents);
}
+void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtr<CSSValue> value)
+{
+ ASSERT(property != CSSPropertyInvalid);
+ if (CSSAnimations::isAllowedAnimation(property))
+ m_propertySet->setProperty(property, value, false); // FIXME: handle !important
+}
+
+void StringKeyframe::setPropertyAnimatableValue(CSSPropertyID property, PassRefPtr<AnimatableValue> value)
+{
+ ASSERT(property != CSSPropertyInvalid);
+ if (CSSAnimations::isAllowedAnimation(property))
+ m_cachedAnimatableValues.set(property, value);
+}
+
PropertySet StringKeyframe::properties() const
{
// This is not used in time-critical code, so we probably don't need to
@@ -52,7 +68,10 @@ PassRefPtrWillBeRawPtr<Keyframe> StringKeyframe::clone() const
}
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpecificKeyframe(CSSPropertyID property) const
{
- return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), &easing(), propertyValue(property), composite()));
+ auto animatableValue = m_cachedAnimatableValues.find(property);
+ if (animatableValue == m_cachedAnimatableValues.end())
+ return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), &easing(), propertyValue(property), composite()));
+ return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), &easing(), propertyValue(property), composite(), animatableValue->value));
}
void StringKeyframe::trace(Visitor* visitor)
@@ -61,9 +80,10 @@ void StringKeyframe::trace(Visitor* visitor)
Keyframe::trace(visitor);
}
-StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::CompositeOperation op)
+StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::CompositeOperation op, PassRefPtr<AnimatableValue> valueCache)
Timothy Loh 2015/01/20 05:29:32 valueCache sounds like a cache of multiple values.
shend 2015/01/20 23:13:03 Done.
: Keyframe::PropertySpecificKeyframe(offset, easing, op)
, m_value(value)
+ , m_animatableValueCache(valueCache)
{ }
StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value)
@@ -79,6 +99,10 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end)->value();
ValueRange range = ValueRangeAll;
+ // FIXME: Remove this check once neutral keyframes are implemented in StringKeyframes.
+ if (!fromCSSValue || !toCSSValue)
+ return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue, property);
+
if (!CSSPropertyMetadata::isAnimatableProperty(property))
return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, property);
@@ -197,6 +221,7 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(*fromCSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(*toCSSValue))
return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue, property);
+ ASSERT(element);
if (useDefaultStyleInterpolation) {
ASSERT(AnimatableValue::usesDefaultInterpolation(
StyleResolver::createAnimatableValueSnapshot(*element, property, *fromCSSValue).get(),
@@ -206,7 +231,6 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
// FIXME: Remove the use of AnimatableValues, RenderStyles and Elements here.
// FIXME: Remove this cache
- ASSERT(element);
if (!m_animatableValueCache)
m_animatableValueCache = StyleResolver::createAnimatableValueSnapshot(*element, property, *fromCSSValue);

Powered by Google App Engine
This is Rietveld 408576698