Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/LengthStyleInterpolation.h" | 6 #include "core/animation/LengthStyleInterpolation.h" |
| 7 | 7 |
| 8 #include "core/css/CSSCalculationValue.h" | 8 #include "core/css/CSSCalculationValue.h" |
| 9 #include "core/css/resolver/StyleBuilder.h" | 9 #include "core/css/resolver/StyleBuilder.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value) | 13 bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value, CSSPropertyI D 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.
| |
| 14 { | 14 { |
| 15 if (value.isPrimitiveValue()) { | 15 if (value.isPrimitiveValue()) { |
| 16 const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(val ue); | 16 const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(val ue); |
| 17 if (primitiveValue.cssCalcValue()) | 17 if (primitiveValue.cssCalcValue()) |
| 18 return true; | 18 return true; |
| 19 | 19 |
| 20 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.
| |
| 21 CSSValueID valueID = primitiveValue.getValueID(); | |
| 22 | |
| 23 // border-*-width column-rule-width, outline-width support thin, med ium, thick. | |
| 24 return valueID == CSSValueThin | |
| 25 || valueID == CSSValueMedium | |
| 26 || valueID == CSSValueThick | |
| 27 || (id == CSSPropertyLetterSpacing && valueID == CSSValueNormal) | |
| 28 || (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.
| |
| 29 } | |
| 30 | |
| 20 CSSPrimitiveValue::LengthUnitType type; | 31 CSSPrimitiveValue::LengthUnitType type; |
| 21 // Only returns true if the type is a primitive length unit. | 32 // Only returns true if the type is a primitive length unit. |
| 22 return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primit iveType(), type); | 33 return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primit iveType(), type); |
| 23 } | 34 } |
| 24 return value.isCalcValue(); | 35 return value.isCalcValue(); |
| 25 } | 36 } |
| 26 | 37 |
| 27 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab leValue(const CSSValue& value) | 38 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthStyleInterpolation::toInterpolab leValue(const CSSValue& value, CSSPropertyID id) |
| 28 { | 39 { |
| 29 ASSERT(canCreateFrom(value)); | 40 ASSERT(canCreateFrom(value, id)); |
| 30 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList ::create(2); | |
| 31 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create (CSSPrimitiveValue::LengthUnitTypeCount); | |
| 32 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.
| |
| 33 | 41 |
| 34 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); | 42 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); |
| 35 | 43 |
| 36 CSSLengthArray arrayOfValues; | 44 CSSLengthArray arrayOfValues; |
| 37 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes; | 45 CSSPrimitiveValue::CSSLengthTypeArray arrayOfTypes; |
| 38 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) | 46 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) |
| 39 arrayOfValues.append(0); | 47 arrayOfValues.append(0); |
| 40 | 48 |
| 41 arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount); | 49 arrayOfTypes.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount); |
| 42 primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes); | 50 if (primitive.isValueID()) { |
| 51 CSSValueID valueID = primitive.getValueID(); | |
| 43 | 52 |
| 53 arrayOfTypes.set(0); | |
| 54 if (valueID == CSSValueThin) | |
| 55 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.
| |
| 56 if (valueID == CSSValueMedium) | |
| 57 arrayOfValues[0] = 3; | |
| 58 if (valueID == CSSValueThick) | |
| 59 arrayOfValues[0] = 5; | |
| 60 | |
| 61 // letter-spacing 'normal' corresponds to 0 | |
| 62 // perspective 'none' corresponds to 0 | |
| 63 } else { | |
| 64 primitive.accumulateLengthArray(arrayOfValues, arrayOfTypes); | |
| 65 } | |
| 66 | |
| 67 OwnPtrWillBeRawPtr<InterpolableList> listOfValues = InterpolableList::create (CSSPrimitiveValue::LengthUnitTypeCount); | |
| 68 OwnPtrWillBeRawPtr<InterpolableList> listOfTypes = InterpolableList::create( CSSPrimitiveValue::LengthUnitTypeCount); | |
| 44 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { | 69 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| 45 listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i))); | 70 listOfValues->set(i, InterpolableNumber::create(arrayOfValues.at(i))); |
| 46 listOfTypes->set(i, InterpolableNumber::create(arrayOfTypes.get(i))); | 71 listOfTypes->set(i, InterpolableNumber::create(arrayOfTypes.get(i))); |
| 47 } | 72 } |
| 48 | 73 |
| 74 OwnPtrWillBeRawPtr<InterpolableList> listOfValuesAndTypes = InterpolableList ::create(2); | |
| 49 listOfValuesAndTypes->set(0, listOfValues.release()); | 75 listOfValuesAndTypes->set(0, listOfValues.release()); |
| 50 listOfValuesAndTypes->set(1, listOfTypes.release()); | 76 listOfValuesAndTypes->set(1, listOfTypes.release()); |
| 51 | 77 |
| 52 return listOfValuesAndTypes.release(); | 78 return listOfValuesAndTypes.release(); |
| 53 } | 79 } |
| 54 | 80 |
| 55 namespace { | 81 namespace { |
| 56 | 82 |
| 57 static CSSPrimitiveValue::UnitType toUnitType(int lengthUnitType) | 83 static CSSPrimitiveValue::UnitType toUnitType(int lengthUnitType) |
| 58 { | 84 { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 { | 145 { |
| 120 StyleBuilder::applyProperty(m_id, state, fromInterpolableValue(*m_cachedValu e.get(), m_range).get()); | 146 StyleBuilder::applyProperty(m_id, state, fromInterpolableValue(*m_cachedValu e.get(), m_range).get()); |
| 121 } | 147 } |
| 122 | 148 |
| 123 void LengthStyleInterpolation::trace(Visitor* visitor) | 149 void LengthStyleInterpolation::trace(Visitor* visitor) |
| 124 { | 150 { |
| 125 StyleInterpolation::trace(visitor); | 151 StyleInterpolation::trace(visitor); |
| 126 } | 152 } |
| 127 | 153 |
| 128 } | 154 } |
| OLD | NEW |