| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return adoptRefWillBeNoop(new AnimatableLength(calcExpression, cssPrimit
iveValue)); | 60 return adoptRefWillBeNoop(new AnimatableLength(calcExpression, cssPrimit
iveValue)); |
| 61 } | 61 } |
| 62 PassRefPtrWillBeRawPtr<CSSValue> toCSSValue(NumberRange = AllValues) const; | 62 PassRefPtrWillBeRawPtr<CSSValue> toCSSValue(NumberRange = AllValues) const; |
| 63 Length toLength(const CSSToLengthConversionData&, NumberRange = AllValues) c
onst; | 63 Length toLength(const CSSToLengthConversionData&, NumberRange = AllValues) c
onst; |
| 64 | 64 |
| 65 virtual void trace(Visitor*) OVERRIDE; | 65 virtual void trace(Visitor*) OVERRIDE; |
| 66 | 66 |
| 67 protected: | 67 protected: |
| 68 virtual PassRefPtrWillBeRawPtr<AnimatableValue> interpolateTo(const Animatab
leValue*, double fraction) const OVERRIDE; | 68 virtual PassRefPtrWillBeRawPtr<AnimatableValue> interpolateTo(const Animatab
leValue*, double fraction) const OVERRIDE; |
| 69 virtual PassRefPtrWillBeRawPtr<AnimatableValue> addWith(const AnimatableValu
e*) const OVERRIDE; | 69 virtual PassRefPtrWillBeRawPtr<AnimatableValue> addWith(const AnimatableValu
e*) const OVERRIDE; |
| 70 virtual bool usesDefaultInterpolationWith(const AnimatableValue*) const OVER
RIDE; | |
| 71 | 70 |
| 72 private: | 71 private: |
| 73 AnimatableLength(double number, CSSPrimitiveValue::LengthUnitType unitType,
CSSPrimitiveValue* cssPrimitiveValue) | 72 AnimatableLength(double number, CSSPrimitiveValue::LengthUnitType unitType,
CSSPrimitiveValue* cssPrimitiveValue) |
| 74 : m_lengthValue(number) | 73 : m_lengthValue(number) |
| 75 , m_lengthUnitType(unitType) | 74 , m_lengthUnitType(unitType) |
| 76 , m_cachedCSSPrimitiveValue(cssPrimitiveValue) | 75 , m_cachedCSSPrimitiveValue(cssPrimitiveValue) |
| 77 { | 76 { |
| 78 ASSERT(!isCalc()); | 77 ASSERT(!isCalc()); |
| 79 } | 78 } |
| 80 AnimatableLength(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> calcExpressio
n, CSSPrimitiveValue* cssPrimitiveValue) | 79 AnimatableLength(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> calcExpressio
n, CSSPrimitiveValue* cssPrimitiveValue) |
| 81 : m_lengthUnitType(CSSPrimitiveValue::UnitTypeCalc) | 80 : m_lengthUnitType(CSSPrimitiveValue::UnitTypeCalc) |
| 82 , m_calcExpression(calcExpression) | 81 , m_calcExpression(calcExpression) |
| 83 , m_cachedCSSPrimitiveValue(cssPrimitiveValue) | 82 , m_cachedCSSPrimitiveValue(cssPrimitiveValue) |
| 84 { | 83 { |
| 85 ASSERT(isCalc()); | 84 ASSERT(isCalc()); |
| 86 ASSERT(m_calcExpression); | 85 ASSERT(m_calcExpression); |
| 87 } | 86 } |
| 88 virtual AnimatableType type() const OVERRIDE { return TypeLength; } | 87 virtual AnimatableType type() const OVERRIDE { return TypeLength; } |
| 89 virtual bool equalTo(const AnimatableValue*) const OVERRIDE; | 88 virtual bool equalTo(const AnimatableValue*) const OVERRIDE; |
| 90 | 89 |
| 91 static bool isCalc(CSSPrimitiveValue::LengthUnitType type) { return type ==
CSSPrimitiveValue::UnitTypeCalc; } | 90 static bool isCalc(CSSPrimitiveValue::LengthUnitType type) { return type ==
CSSPrimitiveValue::UnitTypeCalc; } |
| 92 bool isCalc() const { return isCalc(m_lengthUnitType); } | 91 bool isCalc() const { return isCalc(m_lengthUnitType); } |
| 93 | 92 |
| 94 bool isViewportUnit() const | |
| 95 { | |
| 96 return m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportWidth | |
| 97 || m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportHeight | |
| 98 || m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportMin | |
| 99 || m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportMax; | |
| 100 } | |
| 101 | |
| 102 static PassRefPtrWillBeRawPtr<AnimatableLength> create(const AnimatableLengt
h* leftAddend, const AnimatableLength* rightAddend) | 93 static PassRefPtrWillBeRawPtr<AnimatableLength> create(const AnimatableLengt
h* leftAddend, const AnimatableLength* rightAddend) |
| 103 { | 94 { |
| 104 ASSERT(leftAddend && rightAddend); | 95 ASSERT(leftAddend && rightAddend); |
| 105 return create(CSSCalcValue::createExpressionNode(leftAddend->toCSSCalcEx
pressionNode(), rightAddend->toCSSCalcExpressionNode(), CalcAdd)); | 96 return create(CSSCalcValue::createExpressionNode(leftAddend->toCSSCalcEx
pressionNode(), rightAddend->toCSSCalcExpressionNode(), CalcAdd)); |
| 106 } | 97 } |
| 107 | 98 |
| 108 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toCSSPrimitiveValue(NumberRange) c
onst; | 99 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toCSSPrimitiveValue(NumberRange) c
onst; |
| 109 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> toCSSCalcExpressionNode() cons
t; | 100 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> toCSSCalcExpressionNode() cons
t; |
| 110 | 101 |
| 111 PassRefPtrWillBeRawPtr<AnimatableLength> scale(double) const; | 102 PassRefPtrWillBeRawPtr<AnimatableLength> scale(double) const; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 136 |
| 146 friend class AnimationAnimatableLengthTest; | 137 friend class AnimationAnimatableLengthTest; |
| 147 friend class LengthStyleInterpolation; | 138 friend class LengthStyleInterpolation; |
| 148 }; | 139 }; |
| 149 | 140 |
| 150 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableLength, isLength()); | 141 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableLength, isLength()); |
| 151 | 142 |
| 152 } // namespace WebCore | 143 } // namespace WebCore |
| 153 | 144 |
| 154 #endif // AnimatableLength_h | 145 #endif // AnimatableLength_h |
| OLD | NEW |