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

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

Issue 1421533006: Make SVGLength wrap a CSSPrimitiveValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added expectation Created 5 years, 1 month 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: third_party/WebKit/Source/core/animation/LengthSVGInterpolation.cpp
diff --git a/third_party/WebKit/Source/core/animation/LengthSVGInterpolation.cpp b/third_party/WebKit/Source/core/animation/LengthSVGInterpolation.cpp
index f051dfa07ed8cee6e33c0767a73ed6fe99057330..2207525350a9bb49662c19d6c83896361ef0de64 100644
--- a/third_party/WebKit/Source/core/animation/LengthSVGInterpolation.cpp
+++ b/third_party/WebKit/Source/core/animation/LengthSVGInterpolation.cpp
@@ -60,43 +60,52 @@ enum LengthInterpolatedUnit {
LengthInterpolatedCHS,
};
-static const SVGLengthType unitTypes[] = { LengthTypeNumber, LengthTypePercentage, LengthTypeEMS, LengthTypeEXS, LengthTypeREMS, LengthTypeCHS };
+static const CSSPrimitiveValue::UnitType unitTypes[] = {
+ CSSPrimitiveValue::UnitType::Number,
+ CSSPrimitiveValue::UnitType::Percentage,
+ CSSPrimitiveValue::UnitType::Ems,
+ CSSPrimitiveValue::UnitType::Exs,
+ CSSPrimitiveValue::UnitType::Rems,
+ CSSPrimitiveValue::UnitType::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::UnitType::Unknown:
default:
ASSERT_NOT_REACHED();
- case LengthTypePX:
- case LengthTypeNumber:
+ case CSSPrimitiveValue::UnitType::Pixels:
+ case CSSPrimitiveValue::UnitType::Number:
return LengthInterpolatedNumber;
- case LengthTypePercentage:
+ case CSSPrimitiveValue::UnitType::Percentage:
return LengthInterpolatedPercentage;
- case LengthTypeEMS:
+ case CSSPrimitiveValue::UnitType::Ems:
return LengthInterpolatedEMS;
- case LengthTypeEXS:
+ case CSSPrimitiveValue::UnitType::Exs:
return LengthInterpolatedEXS;
- case LengthTypeCM:
+ case CSSPrimitiveValue::UnitType::Centimeters:
value *= cssPixelsPerCentimeter;
return LengthInterpolatedNumber;
- case LengthTypeMM:
+ case CSSPrimitiveValue::UnitType::Millimeters:
value *= cssPixelsPerMillimeter;
return LengthInterpolatedNumber;
- case LengthTypeIN:
+ case CSSPrimitiveValue::UnitType::Inches:
value *= cssPixelsPerInch;
return LengthInterpolatedNumber;
- case LengthTypePT:
+ case CSSPrimitiveValue::UnitType::Points:
value *= cssPixelsPerPoint;
return LengthInterpolatedNumber;
- case LengthTypePC:
+ case CSSPrimitiveValue::UnitType::Picas:
value *= cssPixelsPerPica;
return LengthInterpolatedNumber;
- case LengthTypeREMS:
+ case CSSPrimitiveValue::UnitType::UserUnits:
+ return LengthInterpolatedNumber;
+ case CSSPrimitiveValue::UnitType::Rems:
return LengthInterpolatedREMS;
- case LengthTypeCHS:
+ case CSSPrimitiveValue::UnitType::Chs:
return LengthInterpolatedCHS;
}
}
@@ -109,7 +118,7 @@ PassOwnPtr<InterpolableValue> LengthSVGInterpolation::toInterpolableValue(SVGLen
populateModeData(attribute, ptrModeData);
double value = length->valueInSpecifiedUnits();
- LengthInterpolatedUnit unitType = convertToInterpolatedUnit(length->unitType(), value);
+ LengthInterpolatedUnit unitType = convertToInterpolatedUnit(length->typeWithCalcResolved(), value);
double values[numLengthInterpolatedUnits] = { };
values[unitType] = value;
@@ -126,7 +135,7 @@ PassRefPtrWillBeRawPtr<SVGLength> LengthSVGInterpolation::fromInterpolableValue(
ASSERT(element);
double value = 0;
- SVGLengthType lengthType = LengthTypeNumber;
+ CSSPrimitiveValue::UnitType unitType = CSSPrimitiveValue::UnitType::UserUnits;
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 +147,12 @@ PassRefPtrWillBeRawPtr<SVGLength> LengthSVGInterpolation::fromInterpolableValue(
break;
value = entry;
- lengthType = unitTypes[i];
+ unitType = unitTypes[i];
}
if (unitTypeCount > 1) {
value = 0;
- lengthType = LengthTypeNumber;
+ unitType = CSSPrimitiveValue::UnitType::UserUnits;
// SVGLength does not support calc expressions, so we convert to canonical units.
SVGLengthContext lengthContext(element);
@@ -158,8 +167,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