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

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

Issue 863863004: Implemented additive animations for length (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More comprehensive non-negative length layout tests Created 5 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
Index: Source/core/animation/InterpolationFactory.cpp
diff --git a/Source/core/animation/StringKeyframe.cpp b/Source/core/animation/InterpolationFactory.cpp
similarity index 71%
copy from Source/core/animation/StringKeyframe.cpp
copy to Source/core/animation/InterpolationFactory.cpp
index 806e9a9e60803ad905e60024ad44e0a55abd0117..9f147ffcf1543c06a05a5bf1cb9e1404912361b4 100644
--- a/Source/core/animation/StringKeyframe.cpp
+++ b/Source/core/animation/InterpolationFactory.cpp
@@ -1,9 +1,9 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2015 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/StringKeyframe.h"
+#include "core/animation/InterpolationFactory.h"
#include "core/animation/ColorStyleInterpolation.h"
#include "core/animation/ConstantStyleInterpolation.h"
@@ -18,68 +18,21 @@
#include "core/animation/SVGLengthStyleInterpolation.h"
#include "core/animation/ShadowStyleInterpolation.h"
#include "core/animation/VisibilityStyleInterpolation.h"
-#include "core/animation/css/CSSAnimations.h"
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/resolver/StyleResolver.h"
-#include "core/layout/style/LayoutStyle.h"
namespace blink {
-StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom)
- : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing)
- , m_propertySet(copyFrom.m_propertySet->mutableCopy())
+PassRefPtrWillBeRawPtr<Interpolation> InterpolationFactory::maybeCreateInterpolation(
+ CSSPropertyID property,
+ CSSValue* fromCSSValue,
+ CSSValue* toCSSValue,
+ AnimationEffect::CompositeOperation fromComposite,
+ AnimationEffect::CompositeOperation toComposite,
+ RefPtrWillBeRawPtr<AnimatableValue>* fromAnimatableValueCache,
+ RefPtrWillBeRawPtr<AnimatableValue>* toAnimatableValueCache,
+ Element* element)
{
-}
-
-void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& value, StyleSheetContents* styleSheetContents)
-{
- ASSERT(property != CSSPropertyInvalid);
- if (CSSAnimations::isAllowedAnimation(property))
- m_propertySet->setProperty(property, value, false, styleSheetContents);
-}
-
-PropertySet StringKeyframe::properties() const
-{
- // This is not used in time-critical code, so we probably don't need to
- // worry about caching this result.
- PropertySet properties;
- for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i)
- properties.add(m_propertySet->propertyAt(i).id());
- return properties;
-}
-
-PassRefPtrWillBeRawPtr<Keyframe> StringKeyframe::clone() const
-{
- return adoptRefWillBeNoop(new StringKeyframe(*this));
-}
-PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpecificKeyframe(CSSPropertyID property) const
-{
- return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), &easing(), propertyValue(property), composite()));
-}
-
-void StringKeyframe::trace(Visitor* visitor)
-{
- visitor->trace(m_propertySet);
- Keyframe::trace(visitor);
-}
-
-StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::CompositeOperation op)
- : Keyframe::PropertySpecificKeyframe(offset, easing, op)
- , m_value(value)
-{ }
-
-StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value)
- : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace)
- , m_value(value)
-{
- ASSERT(!isNull(m_offset));
-}
-
-// FIXME: Refactor this into a generic piece that lives in InterpolationEffect, and a template parameter specific converter.
-PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::maybeCreateInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe& end, Element* element) const
-{
- CSSValue* fromCSSValue = m_value.get();
- CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value();
InterpolationRange range = RangeAll;
bool fallBackToLegacy = false;
@@ -88,7 +41,7 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
if (!CSSPropertyMetadata::isAnimatableProperty(property)) {
if (fromCSSValue == toCSSValue)
- return ConstantStyleInterpolation::create(fromCSSValue, property);
+ return ConstantStyleInterpolation::create(fromCSSValue, property, fromComposite, toComposite);
return nullptr;
}
@@ -142,7 +95,7 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
case CSSPropertyVerticalAlign:
case CSSPropertyWordSpacing:
if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyleInterpolation::canCreateFrom(*toCSSValue))
- return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, range);
+ return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, range, fromComposite, toComposite);
// FIXME: Handle keywords e.g. 'none'.
if (property == CSSPropertyPerspective)
@@ -280,22 +233,25 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
|| toCSSValue->isUnsetValue() || toCSSValue->isInheritedValue() || toCSSValue->isInitialValue())
fallBackToLegacy = true;
+ ASSERT(element);
if (fallBackToLegacy) {
+ ASSERT(fromAnimatableValueCache);
+ ASSERT(toAnimatableValueCache);
+
if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(*fromCSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(*toCSSValue)) {
// FIXME: Handle these cases outside of DeferredLegacyStyleInterpolation.
return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue, property);
}
- // FIXME: Remove the use of AnimatableValues, LayoutStyles and Elements here.
+ // 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);
+ if (!*fromAnimatableValueCache)
+ *fromAnimatableValueCache = StyleResolver::createAnimatableValueSnapshot(*element, property, *fromCSSValue);
RefPtrWillBeRawPtr<AnimatableValue> to = StyleResolver::createAnimatableValueSnapshot(*element, property, *toCSSValue);
- toStringPropertySpecificKeyframe(end).m_animatableValueCache = to;
+ *toAnimatableValueCache = to;
- return LegacyStyleInterpolation::create(m_animatableValueCache.get(), to.release(), property);
+ return LegacyStyleInterpolation::create((*fromAnimatableValueCache).get(), to.release(), property);
}
ASSERT(AnimatableValue::usesDefaultInterpolation(
@@ -303,26 +259,24 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
StyleResolver::createAnimatableValueSnapshot(*element, property, *toCSSValue).get()));
return nullptr;
-
}
-PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
+PassRefPtrWillBeRawPtr<Interpolation> InterpolationFactory::createConstantInterpolation(
+ CSSPropertyID property,
+ CSSValue* value,
+ AnimationEffect::CompositeOperation fromComposite,
+ AnimationEffect::CompositeOperation toComposite)
{
- return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, easing, 0, AnimationEffect::CompositeAdd));
-}
+ RefPtrWillBeRawPtr<Interpolation> interpolation = InterpolationFactory::maybeCreateInterpolation(
+ property,
+ value,
+ value,
+ fromComposite,
+ toComposite);
-PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::PropertySpecificKeyframe::cloneWithOffset(double offset) const
-{
- Keyframe::PropertySpecificKeyframe* theClone = new PropertySpecificKeyframe(offset, m_easing, m_value.get());
- toStringPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatableValueCache;
- return adoptPtrWillBeNoop(theClone);
-}
+ ASSERT(interpolation);
-void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor)
-{
- visitor->trace(m_value);
- visitor->trace(m_animatableValueCache);
- Keyframe::PropertySpecificKeyframe::trace(visitor);
+ return interpolation.release();
}
}

Powered by Google App Engine
This is Rietveld 408576698