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

Unified Diff: Source/core/svg/SVGLengthContext.cpp

Issue 1162453002: [svg2] Make SVGLength wrap a CSSPrimitiveValue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tweak TE 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/svg/SVGLengthContext.cpp
diff --git a/Source/core/svg/SVGLengthContext.cpp b/Source/core/svg/SVGLengthContext.cpp
index 64a81dc98699c57e63e50401072efcbf735cdd86..4085346f42f21be9af82d63b92c603f08e527c16 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -183,48 +183,48 @@ float SVGLengthContext::valueForLength(const Length& length, float zoom, float d
return floatValueForLength(length, dimension * zoom) / zoom;
}
-float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit) const
+float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, CSSPrimitiveValue::UnitType fromUnit) const
{
float userUnits = value;
switch (fromUnit) {
- case LengthTypeUnknown:
+ case CSSPrimitiveValue::CSS_UNKNOWN:
return 0;
- case LengthTypePX:
- case LengthTypeNumber:
+ case CSSPrimitiveValue::CSS_PX:
+ case CSSPrimitiveValue::CSS_NUMBER:
userUnits = value;
break;
- case LengthTypePercentage: {
+ case CSSPrimitiveValue::CSS_PERCENTAGE: {
FloatSize viewportSize;
if (!determineViewport(viewportSize))
return 0;
userUnits = value * dimensionForLengthMode(mode, viewportSize) / 100;
break;
}
- case LengthTypeEMS:
+ case CSSPrimitiveValue::CSS_EMS:
userUnits = convertValueFromEMSToUserUnits(computedStyleForLengthResolving(m_context), value);
break;
- case LengthTypeEXS:
+ case CSSPrimitiveValue::CSS_EXS:
userUnits = convertValueFromEXSToUserUnits(value);
break;
- case LengthTypeCM:
+ case CSSPrimitiveValue::CSS_CM:
userUnits = value * cssPixelsPerCentimeter;
break;
- case LengthTypeMM:
+ case CSSPrimitiveValue::CSS_MM:
userUnits = value * cssPixelsPerMillimeter;
break;
- case LengthTypeIN:
+ case CSSPrimitiveValue::CSS_IN:
userUnits = value * cssPixelsPerInch;
break;
- case LengthTypePT:
+ case CSSPrimitiveValue::CSS_PT:
userUnits = value * cssPixelsPerPoint;
break;
- case LengthTypePC:
+ case CSSPrimitiveValue::CSS_PC:
userUnits = value * cssPixelsPerPica;
break;
- case LengthTypeREMS:
+ case CSSPrimitiveValue::CSS_REMS:
userUnits = convertValueFromEMSToUserUnits(rootElementStyle(m_context), value);
break;
- case LengthTypeCHS:
+ case CSSPrimitiveValue::CSS_CHS:
userUnits = convertValueFromCHSToUserUnits(value);
break;
default:
@@ -238,14 +238,15 @@ float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
return CSSPrimitiveValue::clampToCSSLengthRange(userUnits);
}
-float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mode, SVGLengthType toUnit) const
+float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mode, CSSPrimitiveValue::UnitType toUnit) const
{
switch (toUnit) {
- case LengthTypeUnknown:
+ case CSSPrimitiveValue::CSS_UNKNOWN:
return 0;
- case LengthTypeNumber:
+ case CSSPrimitiveValue::CSS_PX:
+ case CSSPrimitiveValue::CSS_NUMBER:
return value;
- case LengthTypePercentage: {
+ case CSSPrimitiveValue::CSS_PERCENTAGE: {
FloatSize viewportSize;
if (!determineViewport(viewportSize))
return 0;
@@ -256,26 +257,26 @@ float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mod
// Good for accuracy but could eventually be changed.
return value * 100 / dimension;
}
- case LengthTypeEMS:
+ case CSSPrimitiveValue::CSS_EMS:
return convertValueFromUserUnitsToEMS(computedStyleForLengthResolving(m_context), value);
- case LengthTypeEXS:
+ case CSSPrimitiveValue::CSS_EXS:
return convertValueFromUserUnitsToEXS(value);
- case LengthTypeREMS:
+ case CSSPrimitiveValue::CSS_REMS:
return convertValueFromUserUnitsToEMS(rootElementStyle(m_context), value);
- case LengthTypeCHS:
+ case CSSPrimitiveValue::CSS_CHS:
return convertValueFromUserUnitsToCHS(value);
- case LengthTypePX:
- return value;
- case LengthTypeCM:
+ case CSSPrimitiveValue::CSS_CM:
return value / cssPixelsPerCentimeter;
- case LengthTypeMM:
+ case CSSPrimitiveValue::CSS_MM:
return value / cssPixelsPerMillimeter;
- case LengthTypeIN:
+ case CSSPrimitiveValue::CSS_IN:
return value / cssPixelsPerInch;
- case LengthTypePT:
+ case CSSPrimitiveValue::CSS_PT:
return value / cssPixelsPerPoint;
- case LengthTypePC:
+ case CSSPrimitiveValue::CSS_PC:
return value / cssPixelsPerPica;
+ default:
+ break;
}
ASSERT_NOT_REACHED();

Powered by Google App Engine
This is Rietveld 408576698