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

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

Issue 955863002: Support keywords in LengthStyleInterpolation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: pixels for keyword Created 5 years, 9 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
« no previous file with comments | « Source/core/animation/LengthStyleInterpolation.h ('k') | Source/core/animation/StringKeyframe.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/LengthStyleInterpolation.cpp
diff --git a/Source/core/animation/LengthStyleInterpolation.cpp b/Source/core/animation/LengthStyleInterpolation.cpp
index 0626c2b0e9adaf0f3de707e8960c297b7cd1a0f0..a8398d316bbbb8c1ffdcd42b9f5172a19a07bd8a 100644
--- a/Source/core/animation/LengthStyleInterpolation.cpp
+++ b/Source/core/animation/LengthStyleInterpolation.cpp
@@ -10,13 +10,62 @@
namespace blink {
-bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value)
+namespace {
+
+bool pixelsForKeyword(CSSPropertyID property, CSSValueID valueID, double& result)
+{
+ switch (property) {
+ case CSSPropertyBorderBottomWidth:
+ case CSSPropertyBorderLeftWidth:
+ case CSSPropertyBorderRightWidth:
+ case CSSPropertyBorderTopWidth:
+ case CSSPropertyWebkitColumnRuleWidth:
+ case CSSPropertyOutlineWidth:
+ if (valueID == CSSValueThin) {
+ result = 1;
+ return true;
+ }
+ if (valueID == CSSValueMedium) {
+ result = 3;
+ return true;
+ }
+ if (valueID == CSSValueThick) {
+ result = 5;
+ return true;
+ }
+ return false;
+ case CSSPropertyLetterSpacing:
+ if (valueID == CSSValueNormal) {
+ result = 0;
+ return true;
+ }
+ return false;
+ case CSSPropertyPerspective:
+ if (valueID == CSSValueNone) {
+ result = 0;
alancutter (OOO until 2018) 2015/03/09 00:34:15 Actually we shouldn't be animating perspective: no
Eric Willigers 2015/03/09 02:04:55 Done.
+ return true;
+ }
+ return false;
+ default:
+ return false;
+ }
+}
+
+} // namespace
+
+bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value, CSSPropertyID property)
{
if (value.isPrimitiveValue()) {
const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(value);
if (primitiveValue.cssCalcValue())
return true;
+ if (primitiveValue.isValueID()) {
+ CSSValueID valueID = primitiveValue.getValueID();
+ double pixels;
+ return pixelsForKeyword(property, valueID, pixels);
+ }
+
CSSPrimitiveValue::LengthUnitType type;
// Only returns true if the type is a primitive length unit.
return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primitiveType(), type);
@@ -24,9 +73,9 @@ bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value)
return value.isCalcValue();
}
-PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolableValue(const CSSValue& value)
+PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolableValue(const CSSValue& value, CSSPropertyID id)
{
- ASSERT(canCreateFrom(value));
+ ASSERT(canCreateFrom(value, id));
OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList::create(2);
OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount);
OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount);
@@ -39,7 +88,15 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab
arrayOfValues.append(0);
arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount);
- primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes);
+ if (primitive.isValueID()) {
+ CSSValueID valueID = primitive.getValueID();
+ double pixels;
+ pixelsForKeyword(id, valueID, pixels);
+ arrayOfTypes.set(CSSPrimitiveValue::UnitTypePixels);
+ arrayOfValues[CSSPrimitiveValue::UnitTypePixels] = pixels;
+ } else {
+ primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes);
+ }
for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i)));
« no previous file with comments | « Source/core/animation/LengthStyleInterpolation.h ('k') | Source/core/animation/StringKeyframe.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698