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

Unified Diff: Source/core/animation/AnimatableLength.h

Issue 25082007: Web Animations CSS: Split AnimatableNumber into AnimatableDouble and AnimatableLength (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased onto virtual enum change Created 7 years, 3 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
Index: Source/core/animation/AnimatableLength.h
diff --git a/Source/core/animation/AnimatableNumber.h b/Source/core/animation/AnimatableLength.h
similarity index 70%
rename from Source/core/animation/AnimatableNumber.h
rename to Source/core/animation/AnimatableLength.h
index d8565893a9b74fe9fb19d33c5ff5513c3f2a96ea..6eabddd7ae375492a625715889b3ced3ca72742d 100644
--- a/Source/core/animation/AnimatableNumber.h
+++ b/Source/core/animation/AnimatableLength.h
@@ -28,12 +28,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef AnimatableNumber_h
-#define AnimatableNumber_h
+#ifndef AnimatableLength_h
+#define AnimatableLength_h
#include "core/animation/AnimatableValue.h"
#include "core/css/CSSCalculationValue.h"
#include "core/css/CSSPrimitiveValue.h"
+#include "core/platform/Length.h"
namespace WebCore {
@@ -42,13 +43,9 @@ enum NumberRange {
NonNegativeValues,
};
-// Handles animation of CSSPrimitiveValues that can be represented by doubles including CSSCalcValue.
-// See primitiveUnitToNumberType() for the list of supported units (with the exception of calc).
-// If created from a CSSPrimitiveValue this class will cache it to be returned in toCSSValue().
-class AnimatableNumber : public AnimatableValue {
+class AnimatableLength : public AnimatableValue {
public:
enum NumberUnitType {
- UnitTypeNumber,
UnitTypeLength,
UnitTypeFontSize,
UnitTypeFontXSize,
@@ -58,22 +55,17 @@ public:
UnitTypeViewportHeight,
UnitTypeViewportMin,
UnitTypeViewportMax,
- UnitTypeTime,
- UnitTypeAngle,
- UnitTypeFrequency,
- UnitTypeResolution,
UnitTypeInvalid,
};
- virtual ~AnimatableNumber() { }
+ virtual ~AnimatableLength() { }
static bool canCreateFrom(const CSSValue*);
- static PassRefPtr<AnimatableNumber> create(CSSValue*);
- static PassRefPtr<AnimatableNumber> create(double number, NumberUnitType unitType, CSSPrimitiveValue* cssPrimitiveValue = 0)
+ static PassRefPtr<AnimatableLength> create(CSSValue*);
+ static PassRefPtr<AnimatableLength> create(double number, NumberUnitType unitType, CSSPrimitiveValue* cssPrimitiveValue = 0)
{
- return adoptRef(new AnimatableNumber(number, unitType, cssPrimitiveValue));
+ return adoptRef(new AnimatableLength(number, unitType, cssPrimitiveValue));
}
PassRefPtr<CSSValue> toCSSValue(NumberRange = AllValues) const;
- double toDouble() const;
Length toLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, double zoom, NumberRange = AllValues) const;
protected:
@@ -81,33 +73,32 @@ protected:
virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const OVERRIDE;
private:
- AnimatableNumber(double number, NumberUnitType unitType, CSSPrimitiveValue* cssPrimitiveValue)
- : m_number(number)
+ AnimatableLength(double number, NumberUnitType unitType, CSSPrimitiveValue* cssPrimitiveValue)
+ : m_isCalc(false)
+ , m_number(number)
, m_unitType(unitType)
- , m_isCalc(false)
, m_cachedCSSPrimitiveValue(cssPrimitiveValue)
{
- ASSERT(m_unitType != UnitTypeInvalid);
Timothy Loh 2013/09/30 23:27:59 Why is this line removed?
alancutter (OOO until 2018) 2013/10/01 09:32:24 Mistake. Line put back.
}
- AnimatableNumber(PassRefPtr<CSSCalcExpressionNode> calcExpression, CSSPrimitiveValue* cssPrimitiveValue)
+ AnimatableLength(PassRefPtr<CSSCalcExpressionNode> calcExpression, CSSPrimitiveValue* cssPrimitiveValue)
: m_isCalc(true)
, m_calcExpression(calcExpression)
, m_cachedCSSPrimitiveValue(cssPrimitiveValue)
{
ASSERT(m_calcExpression);
}
- virtual AnimatableType type() const OVERRIDE { return TypeNumber; }
+ virtual AnimatableType type() const OVERRIDE { return TypeLength; }
- static PassRefPtr<AnimatableNumber> create(PassRefPtr<CSSCalcExpressionNode> calcExpression, CSSPrimitiveValue* cssPrimitiveValue = 0)
+ static PassRefPtr<AnimatableLength> create(PassRefPtr<CSSCalcExpressionNode> calcExpression, CSSPrimitiveValue* cssPrimitiveValue = 0)
{
- return adoptRef(new AnimatableNumber(calcExpression, cssPrimitiveValue));
+ return adoptRef(new AnimatableLength(calcExpression, cssPrimitiveValue));
}
- static PassRefPtr<AnimatableNumber> create(const AnimatableNumber* leftAddend, const AnimatableNumber* rightAddend);
+ static PassRefPtr<AnimatableLength> create(const AnimatableLength* leftAddend, const AnimatableLength* rightAddend);
PassRefPtr<CSSPrimitiveValue> toCSSPrimitiveValue(NumberRange) const;
PassRefPtr<CSSCalcExpressionNode> toCSSCalcExpressionNode() const;
- PassRefPtr<AnimatableNumber> scale(double) const;
+ PassRefPtr<AnimatableLength> scale(double) const;
double clampedNumber(NumberRange range) const
{
ASSERT(!m_isCalc);
@@ -116,21 +107,22 @@ private:
static NumberUnitType primitiveUnitToNumberType(unsigned short primitiveUnit);
static unsigned short numberTypeToPrimitiveUnit(NumberUnitType numberType);
+ bool m_isCalc;
+
double m_number;
NumberUnitType m_unitType;
- bool m_isCalc;
RefPtr<CSSCalcExpressionNode> m_calcExpression;
mutable RefPtr<CSSPrimitiveValue> m_cachedCSSPrimitiveValue;
};
-inline const AnimatableNumber* toAnimatableNumber(const AnimatableValue* value)
+inline const AnimatableLength* toAnimatableLength(const AnimatableValue* value)
{
- ASSERT_WITH_SECURITY_IMPLICATION(value && value->isNumber());
- return static_cast<const AnimatableNumber*>(value);
+ ASSERT_WITH_SECURITY_IMPLICATION(value && value->isLength());
+ return static_cast<const AnimatableLength*>(value);
}
} // namespace WebCore
-#endif // AnimatableNumber_h
+#endif // AnimatableLength_h

Powered by Google App Engine
This is Rietveld 408576698