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

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: 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
« 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 effaf43168f31f34598aba819483a4db8969647f..7379c1f049dc84a1dd6d77c195ffa276c3c5d245 100644
--- a/Source/core/animation/LengthStyleInterpolation.cpp
+++ b/Source/core/animation/LengthStyleInterpolation.cpp
@@ -10,13 +10,24 @@
namespace blink {
-bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value)
+bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value, CSSPropertyID id)
alancutter (OOO until 2018) 2015/03/05 23:38:49 Nit: I think we should name our CSSPropertyID vari
Eric Willigers 2015/03/07 23:58:21 Done.
{
if (value.isPrimitiveValue()) {
const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(value);
if (primitiveValue.cssCalcValue())
return true;
+ if (primitiveValue.isValueID()) {
alancutter (OOO until 2018) 2015/03/05 23:38:49 You should only enter this branch if the property
Eric Willigers 2015/03/07 23:58:21 Acknowledged.
+ CSSValueID valueID = primitiveValue.getValueID();
+
+ // border-*-width column-rule-width, outline-width support thin, medium, thick.
+ return valueID == CSSValueThin
+ || valueID == CSSValueMedium
+ || valueID == CSSValueThick
+ || (id == CSSPropertyLetterSpacing && valueID == CSSValueNormal)
+ || (id == CSSPropertyPerspective && valueID == CSSValueNone);
alancutter (OOO until 2018) 2015/03/05 23:38:50 The properties should be called out in code, a com
Eric Willigers 2015/03/07 23:58:22 Done.
+ }
+
CSSPrimitiveValue::LengthUnitType type;
// Only returns true if the type is a primitive length unit.
return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primitiveType(), type);
@@ -24,12 +35,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));
- OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList::create(2);
- OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount);
- OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount);
alancutter (OOO until 2018) 2015/03/05 23:38:50 Do these need to move? I think the original placem
Eric Willigers 2015/03/07 23:58:22 Acknowledged.
+ ASSERT(canCreateFrom(value, id));
const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value);
@@ -39,13 +47,31 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab
arrayOfValues.append(0);
arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount);
- primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes);
+ if (primitive.isValueID()) {
+ CSSValueID valueID = primitive.getValueID();
+
+ arrayOfTypes.set(0);
+ if (valueID == CSSValueThin)
+ arrayOfValues[0] = 1;
alancutter (OOO until 2018) 2015/03/05 23:38:50 Don't index by 0, use CSSPrimitiveValue::UnitTypeP
Eric Willigers 2015/03/07 23:58:21 Done.
+ if (valueID == CSSValueMedium)
+ arrayOfValues[0] = 3;
+ if (valueID == CSSValueThick)
+ arrayOfValues[0] = 5;
+
+ // letter-spacing 'normal' corresponds to 0
+ // perspective 'none' corresponds to 0
+ } else {
+ primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes);
+ }
+ OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount);
+ OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount);
for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i)));
listOfTypes->set(i, InterpolableNumber::create(arrayOfTypes.get(i)));
}
+ OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList::create(2);
listOfValuesAndTypes->set(0, listOfValues.release());
listOfValuesAndTypes->set(1, listOfTypes.release());
« 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