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

Unified Diff: Source/core/animation/LengthSVGInterpolation.cpp

Issue 1162453002: [svg2] Make SVGLength wrap a CSSPrimitiveValue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review fixes Created 5 years, 7 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/LengthSVGInterpolation.cpp
diff --git a/Source/core/animation/LengthSVGInterpolation.cpp b/Source/core/animation/LengthSVGInterpolation.cpp
index 35e1e3107ca84c16158e943271a138d91f8faca0..1465cf9334cb22a5459efd3cd5dabe91b209198a 100644
--- a/Source/core/animation/LengthSVGInterpolation.cpp
+++ b/Source/core/animation/LengthSVGInterpolation.cpp
@@ -60,43 +60,43 @@ enum LengthInterpolatedUnit {
LengthInterpolatedCHS,
};
-static const SVGLengthType unitTypes[] = { LengthTypeNumber, LengthTypePercentage, LengthTypeEMS, LengthTypeEXS, LengthTypeREMS, LengthTypeCHS };
+static const CSSPrimitiveValue::UnitType unitTypes[] = { CSSPrimitiveValue::CSS_NUMBER, CSSPrimitiveValue::CSS_PERCENTAGE, CSSPrimitiveValue::CSS_EMS, CSSPrimitiveValue::CSS_EXS, CSSPrimitiveValue::CSS_REMS, CSSPrimitiveValue::CSS_CHS };
const size_t numLengthInterpolatedUnits = WTF_ARRAY_LENGTH(unitTypes);
-LengthInterpolatedUnit convertToInterpolatedUnit(SVGLengthType lengthType, double& value)
+LengthInterpolatedUnit convertToInterpolatedUnit(CSSPrimitiveValue::UnitType unitType, double& value)
{
- switch (lengthType) {
- case LengthTypeUnknown:
+ switch (unitType) {
+ case CSSPrimitiveValue::CSS_UNKNOWN:
default:
ASSERT_NOT_REACHED();
- case LengthTypePX:
- case LengthTypeNumber:
+ case CSSPrimitiveValue::CSS_PX:
+ case CSSPrimitiveValue::CSS_NUMBER:
return LengthInterpolatedNumber;
- case LengthTypePercentage:
+ case CSSPrimitiveValue::CSS_PERCENTAGE:
return LengthInterpolatedPercentage;
- case LengthTypeEMS:
+ case CSSPrimitiveValue::CSS_EMS:
return LengthInterpolatedEMS;
- case LengthTypeEXS:
+ case CSSPrimitiveValue::CSS_EXS:
return LengthInterpolatedEXS;
- case LengthTypeCM:
+ case CSSPrimitiveValue::CSS_CM:
value *= cssPixelsPerCentimeter;
return LengthInterpolatedNumber;
- case LengthTypeMM:
+ case CSSPrimitiveValue::CSS_MM:
value *= cssPixelsPerMillimeter;
return LengthInterpolatedNumber;
- case LengthTypeIN:
+ case CSSPrimitiveValue::CSS_IN:
value *= cssPixelsPerInch;
return LengthInterpolatedNumber;
- case LengthTypePT:
+ case CSSPrimitiveValue::CSS_PT:
value *= cssPixelsPerPoint;
return LengthInterpolatedNumber;
- case LengthTypePC:
+ case CSSPrimitiveValue::CSS_PC:
value *= cssPixelsPerPica;
return LengthInterpolatedNumber;
- case LengthTypeREMS:
+ case CSSPrimitiveValue::CSS_REMS:
return LengthInterpolatedREMS;
- case LengthTypeCHS:
+ case CSSPrimitiveValue::CSS_CHS:
return LengthInterpolatedCHS;
}
}
@@ -109,7 +109,7 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> LengthSVGInterpolation::toInterpolable
populateModeData(attribute, ptrModeData);
double value = length->valueInSpecifiedUnits();
- LengthInterpolatedUnit unitType = convertToInterpolatedUnit(length->unitType(), value);
+ LengthInterpolatedUnit unitType = convertToInterpolatedUnit(length->primitiveType(), value);
double values[numLengthInterpolatedUnits] = { };
values[unitType] = value;
@@ -126,7 +126,7 @@ PassRefPtrWillBeRawPtr<SVGLength> LengthSVGInterpolation::fromInterpolableValue(
ASSERT(element);
double value = 0;
- SVGLengthType lengthType = LengthTypeNumber;
+ CSSPrimitiveValue::UnitType unitType = CSSPrimitiveValue::CSS_NUMBER;
unsigned unitTypeCount = 0;
// We optimise for the common case where only one unit type is involved.
for (size_t i = 0; i < numLengthInterpolatedUnits; i++) {
@@ -138,12 +138,12 @@ PassRefPtrWillBeRawPtr<SVGLength> LengthSVGInterpolation::fromInterpolableValue(
break;
value = entry;
- lengthType = unitTypes[i];
+ unitType = unitTypes[i];
}
if (unitTypeCount > 1) {
value = 0;
- lengthType = LengthTypeNumber;
+ unitType = CSSPrimitiveValue::CSS_NUMBER;
// SVGLength does not support calc expressions, so we convert to canonical units.
SVGLengthContext lengthContext(element);
@@ -158,8 +158,7 @@ PassRefPtrWillBeRawPtr<SVGLength> LengthSVGInterpolation::fromInterpolableValue(
value = 0;
RefPtrWillBeRawPtr<SVGLength> result = SVGLength::create(modeData.unitMode); // defaults to the length 0
- result->setUnitType(lengthType);
- result->setValueInSpecifiedUnits(value);
+ result->newValueSpecifiedUnits(unitType, value);
return result.release();
}

Powered by Google App Engine
This is Rietveld 408576698