Commit b1dc59f8 authored by sashab@chromium.org's avatar sashab@chromium.org

Made all const methods on CSSPrimitiveValue have the const keyword

Updated all const methods on CSSPrimitiveValue to actually use the
const keyword. This is needed for later work that calls methods on const
references of CSSPrimitiveValue.

BUG=523893

Review URL: https://codereview.chromium.org/1314783002

git-svn-id: svn://svn.chromium.org/blink/trunk@201290 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 91963aac
...@@ -467,7 +467,7 @@ void CSSPrimitiveValue::cleanup() ...@@ -467,7 +467,7 @@ void CSSPrimitiveValue::cleanup()
} }
} }
double CSSPrimitiveValue::computeSeconds() double CSSPrimitiveValue::computeSeconds() const
{ {
ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime)); ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime));
UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->typeWithCalcResolved() : type(); UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->typeWithCalcResolved() : type();
...@@ -498,42 +498,42 @@ double CSSPrimitiveValue::computeDegrees() const ...@@ -498,42 +498,42 @@ double CSSPrimitiveValue::computeDegrees() const
} }
} }
template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
{ {
return roundForImpreciseConversion<int>(computeLengthDouble(conversionData)); return roundForImpreciseConversion<int>(computeLengthDouble(conversionData));
} }
template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
{ {
return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionData)); return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionData));
} }
template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
{ {
return Length(clampToCSSLengthRange(computeLengthDouble(conversionData)), Fixed); return Length(clampToCSSLengthRange(computeLengthDouble(conversionData)), Fixed);
} }
template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
{ {
return roundForImpreciseConversion<short>(computeLengthDouble(conversionData)); return roundForImpreciseConversion<short>(computeLengthDouble(conversionData));
} }
template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
{ {
return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conversionData)); return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conversionData));
} }
template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
{ {
return static_cast<float>(computeLengthDouble(conversionData)); return static_cast<float>(computeLengthDouble(conversionData));
} }
template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
{ {
return computeLengthDouble(conversionData); return computeLengthDouble(conversionData);
} }
double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& conversionData) double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& conversionData) const
{ {
// The logic in this function is duplicated in MediaValues::computeLength // The logic in this function is duplicated in MediaValues::computeLength
// because MediaValues::computeLength needs nearly identical logic, but we haven't found a way to make // because MediaValues::computeLength needs nearly identical logic, but we haven't found a way to make
...@@ -682,7 +682,7 @@ double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(UnitType unitTyp ...@@ -682,7 +682,7 @@ double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(UnitType unitTyp
return factor; return factor;
} }
Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conversionData) Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conversionData) const
{ {
if (isLength()) if (isLength())
return computeLength<Length>(conversionData); return computeLength<Length>(conversionData);
......
...@@ -254,13 +254,13 @@ public: ...@@ -254,13 +254,13 @@ public:
UnitType typeWithCalcResolved() const; UnitType typeWithCalcResolved() const;
double computeDegrees() const; double computeDegrees() const;
double computeSeconds(); double computeSeconds() const;
// Computes a length in pixels, resolving relative lengths // Computes a length in pixels, resolving relative lengths
template<typename T> T computeLength(const CSSToLengthConversionData&); template<typename T> T computeLength(const CSSToLengthConversionData&) const;
// Converts to a Length (Fixed, Percent or Calculated) // Converts to a Length (Fixed, Percent or Calculated)
Length convertToLength(const CSSToLengthConversionData&); Length convertToLength(const CSSToLengthConversionData&) const;
double getDoubleValue() const; double getDoubleValue() const;
float getFloatValue() const { return getValue<float>(); } float getFloatValue() const { return getValue<float>(); }
...@@ -287,7 +287,7 @@ public: ...@@ -287,7 +287,7 @@ public:
static const char* unitTypeToString(UnitType); static const char* unitTypeToString(UnitType);
String customCSSText() const; String customCSSText() const;
bool isQuirkValue() { return m_isQuirkValue; } bool isQuirkValue() const { return m_isQuirkValue; }
bool equals(const CSSPrimitiveValue&) const; bool equals(const CSSPrimitiveValue&) const;
...@@ -335,7 +335,7 @@ private: ...@@ -335,7 +335,7 @@ private:
void init(PassRefPtrWillBeRawPtr<CSSBasicShape>); void init(PassRefPtrWillBeRawPtr<CSSBasicShape>);
void init(PassRefPtrWillBeRawPtr<CSSCalcValue>); void init(PassRefPtrWillBeRawPtr<CSSCalcValue>);
double computeLengthDouble(const CSSToLengthConversionData&); double computeLengthDouble(const CSSToLengthConversionData&) const;
inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitType); } inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitType); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment