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

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

Issue 811993002: Animation: Implement DoubleStyleInterpolation in StringKeyframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Apply all of Alan and Doug's changes 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/StringKeyframe.cpp
diff --git a/Source/core/animation/StringKeyframe.cpp b/Source/core/animation/StringKeyframe.cpp
index d3ea1e2c6f4cbbe8c418bc3629fd7cdc80478ef1..391dea83e9b1a47eee2713429a14ba28d980930f 100644
--- a/Source/core/animation/StringKeyframe.cpp
+++ b/Source/core/animation/StringKeyframe.cpp
@@ -75,6 +75,15 @@ StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset
ASSERT(!isNull(m_offset));
}
+namespace {
+void setRange(InterpolationRange* range, InterpolationRange setTo)
alancutter (OOO until 2018) 2015/02/06 07:26:12 This should be a reference.
dstockwell 2015/02/06 10:44:47 This is not what I meant. Instead I was suggesting
jadeg 2015/02/09 00:07:13 Done.
+{
+ if (*range == RangeAll)
+ *range = setTo;
+}
+
+} // namespace
+
// 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
{
@@ -97,13 +106,9 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
// FIXME: Generate this giant switch statement.
switch (property) {
case CSSPropertyLineHeight:
- if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyleInterpolation::canCreateFrom(*toCSSValue))
- return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative);
-
if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyleInterpolation::canCreateFrom(*toCSSValue))
return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, CSSPrimitiveValue::CSS_NUMBER, RangeNonNegative);
-
- break;
+ // Fall through
case CSSPropertyBorderBottomWidth:
case CSSPropertyBorderLeftWidth:
case CSSPropertyBorderRightWidth:
@@ -143,7 +148,6 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
// FIXME: Handle keywords e.g. 'none'.
if (property == CSSPropertyPerspective)
fallBackToLegacy = true;
-
// FIXME: Handle keywords e.g. 'smaller', 'larger'.
if (property == CSSPropertyFontSize)
fallBackToLegacy = true;
@@ -155,14 +159,47 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
// FIXME: Handle keywords e.g. 'thick'
if (property == CSSPropertyOutlineWidth)
fallBackToLegacy = true;
-
break;
- case CSSPropertyMotionRotation:
- {
- RefPtrWillBeRawPtr<Interpolation> interpolation = DoubleStyleInterpolation::maybeCreateFromMotionRotation(*fromCSSValue, *toCSSValue, property);
- if (interpolation)
- return interpolation.release();
+ case CSSPropertyFlexGrow:
+ case CSSPropertyFlexShrink:
+ setRange(&range, RangeNonNegative);
+ // Fall through
+ case CSSPropertyWidows:
+ case CSSPropertyOrphans:
+ case CSSPropertyZIndex:
+ setRange(&range, RangeRound);
+ // Fall through
+ case CSSPropertyWebkitColumnCount:
+ setRange(&range, RangeFloor);
dstockwell 2015/02/06 10:44:48 RangeFloor seems wrong, in AnimatedStyleBuilder.cp
jadeg 2015/02/09 00:07:13 Done.
+ // Fall through
+ case CSSPropertyShapeImageThreshold:
+ setRange(&range, RangeZeroToOne);
+ // Fall through
+ case CSSPropertyFillOpacity:
dstockwell 2015/02/06 10:44:48 Flood/Stop/Stroke should be ZeroToOne (as in Anima
jadeg 2015/02/09 00:07:13 Done.
+ case CSSPropertyFloodOpacity:
+ case CSSPropertyOpacity:
+ case CSSPropertyStopOpacity:
+ case CSSPropertyStrokeOpacity:
+ setRange(&range, RangeZeroToLessThanOne);
+ // Fall through
+ case CSSPropertyStrokeMiterlimit:
+ setRange(&range, RangeGreaterThanOrEqualToOne);
+ // Fall through
+ case CSSPropertyZoom:
+ setRange(&range, RangePositive);
+ // Fall through
+ case CSSPropertyWebkitColumnRuleWidth:
dstockwell 2015/02/06 10:44:47 CSSPropertyColumnRuleWidth should be rounded (as i
jadeg 2015/02/09 00:07:13 Done.
+ if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyleInterpolation::canCreateFrom(*toCSSValue)) {
+ if (property == CSSPropertyOpacity)
+ StringKeyframe::PropertySpecificKeyframe::ensureAnimatableValueCaches(property, end, element, *fromCSSValue, *toCSSValue);
+ return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, toCSSPrimitiveValue(fromCSSValue)->primitiveType(), range);
+ }
+ break;
+ case CSSPropertyMotionRotation: {
+ RefPtrWillBeRawPtr<Interpolation> interpolation = DoubleStyleInterpolation::maybeCreateFromMotionRotation(*fromCSSValue, *toCSSValue, property);
+ if (interpolation)
+ return interpolation.release();
break;
}
case CSSPropertyVisibility:
@@ -261,23 +298,15 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue, property);
}
- // 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);
-
- RefPtrWillBeRawPtr<AnimatableValue> to = StyleResolver::createAnimatableValueSnapshot(*element, property, *toCSSValue);
- toStringPropertySpecificKeyframe(end).m_animatableValueCache = to;
+ StringKeyframe::PropertySpecificKeyframe::ensureAnimatableValueCaches(property, end, element, *fromCSSValue, *toCSSValue);
- return LegacyStyleInterpolation::create(m_animatableValueCache.get(), to.release(), property);
+ return LegacyStyleInterpolation::create(m_animatableValueCache.get(), toStringPropertySpecificKeyframe(end).m_animatableValueCache.release(), property);
}
ASSERT(AnimatableValue::usesDefaultInterpolation(
StyleResolver::createAnimatableValueSnapshot(*element, property, *fromCSSValue).get(),
StyleResolver::createAnimatableValueSnapshot(*element, property, *toCSSValue).get()));
-
// FIXME: Remove this once TimingFunction partitioning is implemented for all types.
if (!RuntimeEnabledFeatures::webAnimationsAPITimingFunctionPartitioningEnabled())
return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, property);
@@ -289,6 +318,18 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
}
+// FIXME: Remove the use of AnimatableValues, RenderStyles and Elements here.
+// FIXME: Remove this cache
+void StringKeyframe::PropertySpecificKeyframe::ensureAnimatableValueCaches(CSSPropertyID property, Keyframe::PropertySpecificKeyframe& end, Element* element, CSSValue& fromCSSValue, CSSValue& toCSSValue) const
+{
+ ASSERT(element);
+ if (!m_animatableValueCache)
+ m_animatableValueCache = StyleResolver::createAnimatableValueSnapshot(*element, property, fromCSSValue);
+ RefPtrWillBeRawPtr<AnimatableValue> to = StyleResolver::createAnimatableValueSnapshot(*element, property, toCSSValue);
+ toStringPropertySpecificKeyframe(end).m_animatableValueCache = to;
+}
+
+
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
{
return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, easing, 0, AnimationEffect::CompositeAdd));

Powered by Google App Engine
This is Rietveld 408576698