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

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

Issue 1196913005: Implement animations for Independent CSS Transform Properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove Compositor Animations and add tests for inherit and initial Created 5 years, 6 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/DoubleStyleInterpolation.cpp
diff --git a/Source/core/animation/DoubleStyleInterpolation.cpp b/Source/core/animation/DoubleStyleInterpolation.cpp
index b4eb68d700d47ec30f4ade3f7a31072d3b7a9998..a807f04100186581fa00b568285c3e38f886cdd3 100644
--- a/Source/core/animation/DoubleStyleInterpolation.cpp
+++ b/Source/core/animation/DoubleStyleInterpolation.cpp
@@ -27,39 +27,44 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::doubleToInte
return nullptr;
}
-PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDouble(InterpolableValue* value, bool isNumber, InterpolationRange clamp)
+static double clampToRange(double value, InterpolationRange clamp)
{
- ASSERT(value->isNumber());
- double doubleValue = toInterpolableNumber(value)->value();
-
switch (clamp) {
case RangeAll:
// Do nothing
break;
case RangeZeroToOne:
- doubleValue = clampTo<float>(doubleValue, 0, 1);
+ value = clampTo<float>(value, 0, 1);
Timothy Loh 2015/06/24 01:00:28 Probably looks better if you just return in the in
soonm 2015/06/24 02:53:19 Done.
break;
case RangeOpacityFIXME:
- doubleValue = clampTo<float>(doubleValue, 0, nextafterf(1, 0));
+ value = clampTo<float>(value, 0, nextafterf(1, 0));
break;
case RangeFloor:
- doubleValue = floor(doubleValue);
+ value = floor(value);
break;
case RangeRound:
- doubleValue = round(doubleValue);
+ value = round(value);
break;
case RangeRoundGreaterThanOrEqualToOne:
- doubleValue = clampTo<float>(round(doubleValue), 1);
+ value = clampTo<float>(round(value), 1);
break;
case RangeGreaterThanOrEqualToOne:
- doubleValue = clampTo<float>(doubleValue, 1);
+ value = clampTo<float>(value, 1);
break;
case RangeNonNegative:
- doubleValue = clampTo<float>(doubleValue, 0);
+ value = clampTo<float>(value, 0);
break;
default:
ASSERT_NOT_REACHED();
}
+ return value;
alancutter (OOO until 2018) 2015/06/24 01:17:09 Push this return up into the case statements.
soonm 2015/06/24 02:53:19 Done.
+}
+
+PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDouble(InterpolableValue* value, bool isNumber, InterpolationRange clamp)
+{
+ ASSERT(value->isNumber());
+ double doubleValue = clampToRange(toInterpolableNumber(value)->value(), clamp);
+
if (isNumber)
return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUMBER);
return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG);
@@ -80,6 +85,19 @@ DEFINE_TRACE(DoubleStyleInterpolation)
StyleInterpolation::trace(visitor);
}
+PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::toInterpolableValue(const CSSValue& value, CSSPropertyID property)
+{
+ ASSERT(canCreateFrom(value));
+ return doubleToInterpolableValue(value);
+}
+
+PassRefPtrWillBeRawPtr<CSSPrimitiveValue> DoubleStyleInterpolation::fromInterpolableValue(const InterpolableValue& value, InterpolationRange range)
+{
+ // TODO Get the correct angle or double unit type
alancutter (OOO until 2018) 2015/06/24 01:17:09 There's not enough context in the code to justify
soonm 2015/06/24 02:53:19 Done - Removed
+ double doubleValue = clampToRange(toInterpolableNumber(value).value(), range);
+ return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUMBER);
+}
+
namespace {
bool extractMotionRotation(const CSSValue& value, float* rotation, MotionRotationType* rotationType)

Powered by Google App Engine
This is Rietveld 408576698