OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 CSSPrimitiveValue* primitiveValue = WebCore::toCSSPrimitiveValue(value); | 45 CSSPrimitiveValue* primitiveValue = WebCore::toCSSPrimitiveValue(value); |
46 const CSSCalcValue* calcValue = primitiveValue->cssCalcValue(); | 46 const CSSCalcValue* calcValue = primitiveValue->cssCalcValue(); |
47 if (calcValue) | 47 if (calcValue) |
48 return create(calcValue->expressionNode(), primitiveValue); | 48 return create(calcValue->expressionNode(), primitiveValue); |
49 NumberUnitType unitType = primitiveUnitToNumberType(primitiveValue->prim
itiveType()); | 49 NumberUnitType unitType = primitiveUnitToNumberType(primitiveValue->prim
itiveType()); |
50 ASSERT(unitType != UnitTypeInvalid); | 50 ASSERT(unitType != UnitTypeInvalid); |
51 const double scale = CSSPrimitiveValue::conversionToCanonicalUnitsScaleF
actor(primitiveValue->primitiveType()); | 51 const double scale = CSSPrimitiveValue::conversionToCanonicalUnitsScaleF
actor(primitiveValue->primitiveType()); |
52 return create(primitiveValue->getDoubleValue() * scale, unitType, primit
iveValue); | 52 return create(primitiveValue->getDoubleValue() * scale, unitType, primit
iveValue); |
53 } | 53 } |
54 | 54 |
55 if (value->isCalculationValue()) | 55 if (value->isCalcValue()) |
56 return create(toCSSCalcValue(value)->expressionNode()); | 56 return create(toCSSCalcValue(value)->expressionNode()); |
57 | 57 |
58 ASSERT_NOT_REACHED(); | 58 ASSERT_NOT_REACHED(); |
59 return 0; | 59 return 0; |
60 } | 60 } |
61 | 61 |
62 PassRefPtr<AnimatableNumber> AnimatableNumber::create(const AnimatableNumber* le
ftAddend, const AnimatableNumber* rightAddend) | 62 PassRefPtr<AnimatableNumber> AnimatableNumber::create(const AnimatableNumber* le
ftAddend, const AnimatableNumber* rightAddend) |
63 { | 63 { |
64 ASSERT(leftAddend); | 64 ASSERT(leftAddend); |
65 ASSERT(rightAddend); | 65 ASSERT(rightAddend); |
66 | 66 |
67 if (!leftAddend->m_isCalc && !rightAddend->m_isCalc && leftAddend->m_unitTyp
e == rightAddend->m_unitType) | 67 if (!leftAddend->m_isCalc && !rightAddend->m_isCalc && leftAddend->m_unitTyp
e == rightAddend->m_unitType) |
68 return create(leftAddend->m_number + rightAddend->m_number, leftAddend->
m_unitType); | 68 return create(leftAddend->m_number + rightAddend->m_number, leftAddend->
m_unitType); |
69 return create(CSSCalcValue::createExpressionNode(leftAddend->toCSSCalcExpres
sionNode(), rightAddend->toCSSCalcExpressionNode(), CalcAdd)); | 69 return create(CSSCalcValue::createExpressionNode(leftAddend->toCSSCalcExpres
sionNode(), rightAddend->toCSSCalcExpressionNode(), CalcAdd)); |
70 } | 70 } |
71 | 71 |
72 bool AnimatableNumber::canCreateFrom(const CSSValue* value) | 72 bool AnimatableNumber::canCreateFrom(const CSSValue* value) |
73 { | 73 { |
74 ASSERT(value); | 74 ASSERT(value); |
75 if (value->isPrimitiveValue()) { | 75 if (value->isPrimitiveValue()) { |
76 const CSSPrimitiveValue* primitiveValue = WebCore::toCSSPrimitiveValue(v
alue); | 76 const CSSPrimitiveValue* primitiveValue = WebCore::toCSSPrimitiveValue(v
alue); |
77 if (primitiveValue->cssCalcValue()) | 77 if (primitiveValue->cssCalcValue()) |
78 return true; | 78 return true; |
79 return primitiveUnitToNumberType(primitiveValue->primitiveType()) != Uni
tTypeInvalid; | 79 return primitiveUnitToNumberType(primitiveValue->primitiveType()) != Uni
tTypeInvalid; |
80 } | 80 } |
81 return value->isCalculationValue(); | 81 return value->isCalcValue(); |
82 } | 82 } |
83 | 83 |
84 PassRefPtr<CSSValue> AnimatableNumber::toCSSValue(NumberRange range) const | 84 PassRefPtr<CSSValue> AnimatableNumber::toCSSValue(NumberRange range) const |
85 { | 85 { |
86 return toCSSPrimitiveValue(range); | 86 return toCSSPrimitiveValue(range); |
87 } | 87 } |
88 | 88 |
89 double AnimatableNumber::toDouble() const | 89 double AnimatableNumber::toDouble() const |
90 { | 90 { |
91 ASSERT(m_unitType == UnitTypeNumber); | 91 ASSERT(m_unitType == UnitTypeNumber); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 case UnitTypeResolution: | 242 case UnitTypeResolution: |
243 return CSSPrimitiveValue::CSS_DPPX; | 243 return CSSPrimitiveValue::CSS_DPPX; |
244 case UnitTypeInvalid: | 244 case UnitTypeInvalid: |
245 return CSSPrimitiveValue::CSS_UNKNOWN; | 245 return CSSPrimitiveValue::CSS_UNKNOWN; |
246 } | 246 } |
247 ASSERT_NOT_REACHED(); | 247 ASSERT_NOT_REACHED(); |
248 return CSSPrimitiveValue::CSS_UNKNOWN; | 248 return CSSPrimitiveValue::CSS_UNKNOWN; |
249 } | 249 } |
250 | 250 |
251 } // namespace WebCore | 251 } // namespace WebCore |
OLD | NEW |