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

Side by Side Diff: Source/core/animation/AnimatableLength.h

Issue 228063006: Remove special cases for viewport units, and add tests for viewport units in calc(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Convert to interpolation test. Created 6 years, 8 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 unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 { 59 {
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 bool usesDefaultInterpolationWith(const AnimatableValue*) const OVER RIDE;
70 69
71 private: 70 private:
72 AnimatableLength(double number, CSSPrimitiveValue::LengthUnitType unitType, CSSPrimitiveValue* cssPrimitiveValue) 71 AnimatableLength(double number, CSSPrimitiveValue::LengthUnitType unitType, CSSPrimitiveValue* cssPrimitiveValue)
73 : m_lengthValue(number) 72 : m_lengthValue(number)
74 , m_lengthUnitType(unitType) 73 , m_lengthUnitType(unitType)
75 , m_cachedCSSPrimitiveValue(cssPrimitiveValue) 74 , m_cachedCSSPrimitiveValue(cssPrimitiveValue)
76 { 75 {
77 ASSERT(!isCalc()); 76 ASSERT(!isCalc());
78 } 77 }
79 AnimatableLength(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> calcExpressio n, CSSPrimitiveValue* cssPrimitiveValue) 78 AnimatableLength(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> calcExpressio n, CSSPrimitiveValue* cssPrimitiveValue)
80 : m_lengthUnitType(CSSPrimitiveValue::UnitTypeCalc) 79 : m_lengthUnitType(CSSPrimitiveValue::UnitTypeCalc)
81 , m_calcExpression(calcExpression) 80 , m_calcExpression(calcExpression)
82 , m_cachedCSSPrimitiveValue(cssPrimitiveValue) 81 , m_cachedCSSPrimitiveValue(cssPrimitiveValue)
83 { 82 {
84 ASSERT(isCalc()); 83 ASSERT(isCalc());
85 ASSERT(m_calcExpression); 84 ASSERT(m_calcExpression);
86 } 85 }
87 virtual AnimatableType type() const OVERRIDE { return TypeLength; } 86 virtual AnimatableType type() const OVERRIDE { return TypeLength; }
88 virtual bool equalTo(const AnimatableValue*) const OVERRIDE; 87 virtual bool equalTo(const AnimatableValue*) const OVERRIDE;
89 88
90 static bool isCalc(CSSPrimitiveValue::LengthUnitType type) { return type == CSSPrimitiveValue::UnitTypeCalc; } 89 static bool isCalc(CSSPrimitiveValue::LengthUnitType type) { return type == CSSPrimitiveValue::UnitTypeCalc; }
91 bool isCalc() const { return isCalc(m_lengthUnitType); } 90 bool isCalc() const { return isCalc(m_lengthUnitType); }
92 91
93 bool isViewportUnit() const
94 {
95 return m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportWidth
96 || m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportHeight
97 || m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportMin
98 || m_lengthUnitType == CSSPrimitiveValue::UnitTypeViewportMax;
99 }
100
101 static PassRefPtrWillBeRawPtr<AnimatableLength> create(const AnimatableLengt h* leftAddend, const AnimatableLength* rightAddend) 92 static PassRefPtrWillBeRawPtr<AnimatableLength> create(const AnimatableLengt h* leftAddend, const AnimatableLength* rightAddend)
102 { 93 {
103 ASSERT(leftAddend && rightAddend); 94 ASSERT(leftAddend && rightAddend);
104 return create(CSSCalcValue::createExpressionNode(leftAddend->toCSSCalcEx pressionNode(), rightAddend->toCSSCalcExpressionNode(), CalcAdd)); 95 return create(CSSCalcValue::createExpressionNode(leftAddend->toCSSCalcEx pressionNode(), rightAddend->toCSSCalcExpressionNode(), CalcAdd));
105 } 96 }
106 97
107 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toCSSPrimitiveValue(NumberRange) c onst; 98 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toCSSPrimitiveValue(NumberRange) c onst;
108 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> toCSSCalcExpressionNode() cons t; 99 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> toCSSCalcExpressionNode() cons t;
109 100
110 PassRefPtrWillBeRawPtr<AnimatableLength> scale(double) const; 101 PassRefPtrWillBeRawPtr<AnimatableLength> scale(double) const;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 135
145 friend class AnimationAnimatableLengthTest; 136 friend class AnimationAnimatableLengthTest;
146 friend class LengthStyleInterpolation; 137 friend class LengthStyleInterpolation;
147 }; 138 };
148 139
149 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableLength, isLength()); 140 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableLength, isLength());
150 141
151 } // namespace WebCore 142 } // namespace WebCore
152 143
153 #endif // AnimatableLength_h 144 #endif // AnimatableLength_h
OLDNEW
« no previous file with comments | « LayoutTests/css3/calc/viewport-unit-expected.html ('k') | Source/core/animation/AnimatableLength.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698