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

Side by Side Diff: Source/core/css/CSSCalculationValue.h

Issue 813233002: Animation: Fix loss of type information when interpolating value of 0 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix second accumulateLength method Created 6 years 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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSCalcExpressionNode); 69 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSCalcExpressionNode);
70 public: 70 public:
71 enum Type { 71 enum Type {
72 CssCalcPrimitiveValue = 1, 72 CssCalcPrimitiveValue = 1,
73 CssCalcBinaryOperation 73 CssCalcBinaryOperation
74 }; 74 };
75 75
76 virtual bool isZero() const = 0; 76 virtual bool isZero() const = 0;
77 virtual double doubleValue() const = 0; 77 virtual double doubleValue() const = 0;
78 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0; 78 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0;
79 virtual void accumulateLengthArray(CSSLengthArray&, double multiplier) const = 0; 79 virtual void accumulateLengthArray(CSSLengthArray&, CSSLengthTypeArray&, dou ble multiplier) const = 0;
80 virtual void accumulatePixelsAndPercent(const CSSToLengthConversionData&, Pi xelsAndPercent&, float multiplier = 1) const = 0; 80 virtual void accumulatePixelsAndPercent(const CSSToLengthConversionData&, Pi xelsAndPercent&, float multiplier = 1) const = 0;
81 virtual String customCSSText() const = 0; 81 virtual String customCSSText() const = 0;
82 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat egory == other.m_category && m_isInteger == other.m_isInteger; } 82 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat egory == other.m_category && m_isInteger == other.m_isInteger; }
83 virtual Type type() const = 0; 83 virtual Type type() const = 0;
84 84
85 CalculationCategory category() const { return m_category; } 85 CalculationCategory category() const { return m_category; }
86 virtual CSSPrimitiveValue::UnitType primitiveType() const = 0; 86 virtual CSSPrimitiveValue::UnitType primitiveType() const = 0;
87 bool isInteger() const { return m_isInteger; } 87 bool isInteger() const { return m_isInteger; }
88 88
89 virtual void trace(Visitor*) { } 89 virtual void trace(Visitor*) { }
(...skipping 24 matching lines...) Expand all
114 PixelsAndPercent value(0, 0); 114 PixelsAndPercent value(0, 0);
115 m_expression->accumulatePixelsAndPercent(conversionData, value); 115 m_expression->accumulatePixelsAndPercent(conversionData, value);
116 return CalculationValue::create(value, m_nonNegative ? ValueRangeNonNega tive : ValueRangeAll); 116 return CalculationValue::create(value, m_nonNegative ? ValueRangeNonNega tive : ValueRangeAll);
117 } 117 }
118 CalculationCategory category() const { return m_expression->category(); } 118 CalculationCategory category() const { return m_expression->category(); }
119 bool isInt() const { return m_expression->isInteger(); } 119 bool isInt() const { return m_expression->isInteger(); }
120 double doubleValue() const; 120 double doubleValue() const;
121 bool isNegative() const { return m_expression->doubleValue() < 0; } 121 bool isNegative() const { return m_expression->doubleValue() < 0; }
122 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat ive : ValueRangeAll; } 122 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat ive : ValueRangeAll; }
123 double computeLengthPx(const CSSToLengthConversionData&) const; 123 double computeLengthPx(const CSSToLengthConversionData&) const;
124 void accumulateLengthArray(CSSLengthArray& lengthArray, double multiplier) c onst { m_expression->accumulateLengthArray(lengthArray, multiplier); } 124 void accumulateLengthArray(CSSLengthArray& lengthArray, CSSLengthTypeArray& lengthTypeArray, double multiplier) const { m_expression->accumulateLengthArray( lengthArray, lengthTypeArray, multiplier); }
125 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } 125 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); }
126 126
127 String customCSSText() const; 127 String customCSSText() const;
128 bool equals(const CSSCalcValue&) const; 128 bool equals(const CSSCalcValue&) const;
129 129
130 void traceAfterDispatch(Visitor*); 130 void traceAfterDispatch(Visitor*);
131 131
132 private: 132 private:
133 CSSCalcValue(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, Value Range range) 133 CSSCalcValue(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, Value Range range)
134 : CSSValue(CalculationClass) 134 : CSSValue(CalculationClass)
135 , m_expression(expression) 135 , m_expression(expression)
136 , m_nonNegative(range == ValueRangeNonNegative) 136 , m_nonNegative(range == ValueRangeNonNegative)
137 { 137 {
138 } 138 }
139 139
140 double clampToPermittedRange(double) const; 140 double clampToPermittedRange(double) const;
141 141
142 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression; 142 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression;
143 const bool m_nonNegative; 143 const bool m_nonNegative;
144 }; 144 };
145 145
146 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue()); 146 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue());
147 147
148 } // namespace blink 148 } // namespace blink
149 149
150 150
151 #endif // CSSCalculationValue_h 151 #endif // CSSCalculationValue_h
OLDNEW
« no previous file with comments | « Source/core/animation/LengthStyleInterpolationTest.cpp ('k') | Source/core/css/CSSCalculationValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698