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

Unified Diff: Source/core/animation/StringKeyframe.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/StringKeyframe.cpp
diff --git a/Source/core/animation/StringKeyframe.cpp b/Source/core/animation/StringKeyframe.cpp
index 806e9a9e60803ad905e60024ad44e0a55abd0117..2ba0b1bd52c6879a8ac9dbf43f18bda44d6117f6 100644
--- a/Source/core/animation/StringKeyframe.cpp
+++ b/Source/core/animation/StringKeyframe.cpp
@@ -5,19 +5,7 @@
#include "config.h"
#include "core/animation/StringKeyframe.h"
-#include "core/animation/ColorStyleInterpolation.h"
-#include "core/animation/ConstantStyleInterpolation.h"
-#include "core/animation/DeferredLegacyStyleInterpolation.h"
-#include "core/animation/DoubleStyleInterpolation.h"
-#include "core/animation/ImageStyleInterpolation.h"
-#include "core/animation/LegacyStyleInterpolation.h"
-#include "core/animation/LengthBoxStyleInterpolation.h"
-#include "core/animation/LengthPairStyleInterpolation.h"
-#include "core/animation/LengthStyleInterpolation.h"
-#include "core/animation/ListStyleInterpolation.h"
-#include "core/animation/SVGLengthStyleInterpolation.h"
-#include "core/animation/ShadowStyleInterpolation.h"
-#include "core/animation/VisibilityStyleInterpolation.h"
+#include "core/animation/InterpolationFactory.h"
#include "core/animation/css/CSSAnimations.h"
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/resolver/StyleResolver.h"
@@ -80,230 +68,8 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
{
CSSValue* fromCSSValue = m_value.get();
CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value();
- InterpolationRange range = RangeAll;
- bool fallBackToLegacy = false;
-
- // FIXME: Remove this flag once we can rely on legacy's behaviour being correct.
- bool forceDefaultInterpolation = false;
-
- if (!CSSPropertyMetadata::isAnimatableProperty(property)) {
- if (fromCSSValue == toCSSValue)
- return ConstantStyleInterpolation::create(fromCSSValue, property);
-
- return nullptr;
- }
-
- // 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;
- case CSSPropertyBorderBottomWidth:
- case CSSPropertyBorderLeftWidth:
- case CSSPropertyBorderRightWidth:
- case CSSPropertyBorderTopWidth:
- case CSSPropertyFlexBasis:
- case CSSPropertyFontSize:
- case CSSPropertyHeight:
- case CSSPropertyMaxHeight:
- case CSSPropertyMaxWidth:
- case CSSPropertyMinHeight:
- case CSSPropertyMinWidth:
- case CSSPropertyMotionPosition:
- case CSSPropertyOutlineWidth:
- case CSSPropertyPaddingBottom:
- case CSSPropertyPaddingLeft:
- case CSSPropertyPaddingRight:
- case CSSPropertyPaddingTop:
- case CSSPropertyPerspective:
- case CSSPropertyShapeMargin:
- case CSSPropertyWebkitBorderHorizontalSpacing:
- case CSSPropertyWebkitBorderVerticalSpacing:
- case CSSPropertyWebkitColumnGap:
- case CSSPropertyWebkitColumnWidth:
- case CSSPropertyWidth:
- range = RangeNonNegative;
- // Fall through
- case CSSPropertyBottom:
- case CSSPropertyLeft:
- case CSSPropertyLetterSpacing:
- case CSSPropertyMarginBottom:
- case CSSPropertyMarginLeft:
- case CSSPropertyMarginRight:
- case CSSPropertyMarginTop:
- case CSSPropertyOutlineOffset:
- case CSSPropertyRight:
- case CSSPropertyTop:
- case CSSPropertyVerticalAlign:
- case CSSPropertyWordSpacing:
- if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyleInterpolation::canCreateFrom(*toCSSValue))
- return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, range);
-
- // FIXME: Handle keywords e.g. 'none'.
- if (property == CSSPropertyPerspective)
- fallBackToLegacy = true;
-
- // FIXME: Handle keywords e.g. 'smaller', 'larger'.
- if (property == CSSPropertyFontSize)
- fallBackToLegacy = true;
-
- // FIXME: Handle keywords e.g. 'normal'
- if (property == CSSPropertyLetterSpacing)
- fallBackToLegacy = true;
-
- // 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();
-
- break;
- }
- case CSSPropertyVisibility:
- if (VisibilityStyleInterpolation::canCreateFrom(*fromCSSValue) && VisibilityStyleInterpolation::canCreateFrom(*toCSSValue) && (VisibilityStyleInterpolation::isVisible(*fromCSSValue) || VisibilityStyleInterpolation::isVisible(*toCSSValue)))
- return VisibilityStyleInterpolation::create(*fromCSSValue, *toCSSValue, property);
-
- break;
-
- case CSSPropertyBackgroundColor:
- case CSSPropertyBorderBottomColor:
- case CSSPropertyBorderLeftColor:
- case CSSPropertyBorderRightColor:
- case CSSPropertyBorderTopColor:
- case CSSPropertyColor:
- case CSSPropertyFloodColor:
- case CSSPropertyLightingColor:
- case CSSPropertyOutlineColor:
- case CSSPropertyStopColor:
- case CSSPropertyTextDecorationColor:
- case CSSPropertyWebkitColumnRuleColor:
- case CSSPropertyWebkitTextStrokeColor:
- {
- RefPtrWillBeRawPtr<Interpolation> interpolation = ColorStyleInterpolation::maybeCreateFromColor(*fromCSSValue, *toCSSValue, property);
- if (interpolation)
- return interpolation.release();
-
- // Current color should use LegacyStyleInterpolation
- if (ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*fromCSSValue, *toCSSValue))
- fallBackToLegacy = true;
-
- break;
- }
-
- case CSSPropertyBorderImageSource:
- case CSSPropertyListStyleImage:
- case CSSPropertyWebkitMaskBoxImageSource:
- if (ImageStyleInterpolation::canCreateFrom(*fromCSSValue) && ImageStyleInterpolation::canCreateFrom(*toCSSValue))
- return ImageStyleInterpolation::create(*fromCSSValue, *toCSSValue, property);
-
- // FIXME: Handle gradients.
- fallBackToLegacy = true;
- break;
- case CSSPropertyBorderBottomLeftRadius:
- case CSSPropertyBorderBottomRightRadius:
- case CSSPropertyBorderTopLeftRadius:
- case CSSPropertyBorderTopRightRadius:
- range = RangeNonNegative;
- // Fall through
- case CSSPropertyObjectPosition:
- if (LengthPairStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthPairStyleInterpolation::canCreateFrom(*toCSSValue))
- return LengthPairStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, range);
- break;
-
- case CSSPropertyPerspectiveOrigin:
- case CSSPropertyTransformOrigin: {
- RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation<LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property, range);
- if (interpolation)
- return interpolation.release();
- break;
- }
-
- case CSSPropertyBoxShadow:
- case CSSPropertyTextShadow:
- case CSSPropertyWebkitBoxShadow: {
- RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation<ShadowStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property);
- if (interpolation)
- return interpolation.release();
-
- // FIXME: AnimatableShadow incorrectly animates between inset and non-inset values so it will never indicate it needs default interpolation
- if (ShadowStyleInterpolation::usesDefaultStyleInterpolation(*fromCSSValue, *toCSSValue)) {
- forceDefaultInterpolation = true;
- break;
- }
-
- // FIXME: Handle interpolation from/to none, unspecified color values
- fallBackToLegacy = true;
-
- break;
- }
-
- case CSSPropertyWebkitMaskBoxImageSlice:
- if (LengthBoxStyleInterpolation::matchingFill(*toCSSValue, *fromCSSValue) && LengthBoxStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyleInterpolation::canCreateFrom(*toCSSValue))
- return LengthBoxStyleInterpolation::createFromBorderImageSlice(*fromCSSValue, *toCSSValue, property);
- break;
-
- case CSSPropertyStrokeWidth:
- range = RangeNonNegative;
- // Fall through
- case CSSPropertyBaselineShift:
- case CSSPropertyStrokeDashoffset: {
- RefPtrWillBeRawPtr<Interpolation> interpolation = SVGLengthStyleInterpolation::maybeCreate(*fromCSSValue, *toCSSValue, property, range);
- if (interpolation)
- return interpolation.release();
-
- break;
- }
-
- default:
- // Fall back to LegacyStyleInterpolation.
- fallBackToLegacy = true;
- break;
- }
-
- if (fromCSSValue == toCSSValue)
- return ConstantStyleInterpolation::create(fromCSSValue, property);
-
- if (forceDefaultInterpolation)
- return nullptr;
-
- if (fromCSSValue->isUnsetValue() || fromCSSValue->isInheritedValue() || fromCSSValue->isInitialValue()
- || toCSSValue->isUnsetValue() || toCSSValue->isInheritedValue() || toCSSValue->isInitialValue())
- fallBackToLegacy = true;
-
- if (fallBackToLegacy) {
- 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 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;
-
- return LegacyStyleInterpolation::create(m_animatableValueCache.get(), to.release(), property);
- }
-
- ASSERT(AnimatableValue::usesDefaultInterpolation(
- StyleResolver::createAnimatableValueSnapshot(*element, property, *fromCSSValue).get(),
- StyleResolver::createAnimatableValueSnapshot(*element, property, *toCSSValue).get()));
-
- return nullptr;
+ return InterpolationFactory::maybeCreateInterpolation(property, fromCSSValue, toCSSValue, m_composite, toStringPropertySpecificKeyframe(end).m_composite, &m_animatableValueCache, &toStringPropertySpecificKeyframe(end).m_animatableValueCache, element);
}
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const

Powered by Google App Engine
This is Rietveld 408576698