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

Unified Diff: third_party/WebKit/Source/core/svg/SVGLengthContext.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/svg/SVGLengthContext.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp b/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp
index 0c3b282c29c6b6a9b00e140ca5417183e8be3b5d..f553158421f727b1c1c0d0772fdae44da33a1052 100644
--- a/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp
@@ -183,48 +183,47 @@ 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:
- return 0;
- case LengthTypePX:
- case LengthTypeNumber:
+ case CSSPrimitiveValue::UnitType::Pixels:
+ case CSSPrimitiveValue::UnitType::Number:
+ case CSSPrimitiveValue::UnitType::UserUnits:
userUnits = value;
break;
- case LengthTypePercentage: {
+ case CSSPrimitiveValue::UnitType::Percentage: {
FloatSize viewportSize;
if (!determineViewport(viewportSize))
return 0;
userUnits = value * dimensionForLengthMode(mode, viewportSize) / 100;
break;
}
- case LengthTypeEMS:
+ case CSSPrimitiveValue::UnitType::Ems:
userUnits = convertValueFromEMSToUserUnits(computedStyleForLengthResolving(m_context), value);
break;
- case LengthTypeEXS:
+ case CSSPrimitiveValue::UnitType::Exs:
userUnits = convertValueFromEXSToUserUnits(value);
break;
- case LengthTypeCM:
+ case CSSPrimitiveValue::UnitType::Centimeters:
userUnits = value * cssPixelsPerCentimeter;
break;
- case LengthTypeMM:
+ case CSSPrimitiveValue::UnitType::Millimeters:
userUnits = value * cssPixelsPerMillimeter;
break;
- case LengthTypeIN:
+ case CSSPrimitiveValue::UnitType::Inches:
userUnits = value * cssPixelsPerInch;
break;
- case LengthTypePT:
+ case CSSPrimitiveValue::UnitType::Points:
userUnits = value * cssPixelsPerPoint;
break;
- case LengthTypePC:
+ case CSSPrimitiveValue::UnitType::Picas:
userUnits = value * cssPixelsPerPica;
break;
- case LengthTypeREMS:
+ case CSSPrimitiveValue::UnitType::Rems:
userUnits = convertValueFromEMSToUserUnits(rootElementStyle(m_context), value);
break;
- case LengthTypeCHS:
+ case CSSPrimitiveValue::UnitType::Chs:
userUnits = convertValueFromCHSToUserUnits(value);
break;
default:
@@ -238,14 +237,14 @@ 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:
- return 0;
- case LengthTypeNumber:
+ case CSSPrimitiveValue::UnitType::Pixels:
+ case CSSPrimitiveValue::UnitType::Number:
+ case CSSPrimitiveValue::UnitType::UserUnits:
return value;
- case LengthTypePercentage: {
+ case CSSPrimitiveValue::UnitType::Percentage: {
FloatSize viewportSize;
if (!determineViewport(viewportSize))
return 0;
@@ -256,26 +255,26 @@ float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mod
// Good for accuracy but could eventually be changed.
return value * 100 / dimension;
}
- case LengthTypeEMS:
+ case CSSPrimitiveValue::UnitType::Ems:
return convertValueFromUserUnitsToEMS(computedStyleForLengthResolving(m_context), value);
- case LengthTypeEXS:
+ case CSSPrimitiveValue::UnitType::Exs:
return convertValueFromUserUnitsToEXS(value);
- case LengthTypeREMS:
+ case CSSPrimitiveValue::UnitType::Rems:
return convertValueFromUserUnitsToEMS(rootElementStyle(m_context), value);
- case LengthTypeCHS:
+ case CSSPrimitiveValue::UnitType::Chs:
return convertValueFromUserUnitsToCHS(value);
- case LengthTypePX:
- return value;
- case LengthTypeCM:
+ case CSSPrimitiveValue::UnitType::Centimeters:
return value / cssPixelsPerCentimeter;
- case LengthTypeMM:
+ case CSSPrimitiveValue::UnitType::Millimeters:
return value / cssPixelsPerMillimeter;
- case LengthTypeIN:
+ case CSSPrimitiveValue::UnitType::Inches:
return value / cssPixelsPerInch;
- case LengthTypePT:
+ case CSSPrimitiveValue::UnitType::Points:
return value / cssPixelsPerPoint;
- case LengthTypePC:
+ case CSSPrimitiveValue::UnitType::Picas:
return value / cssPixelsPerPica;
+ default:
+ break;
}
ASSERT_NOT_REACHED();
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGLengthContext.h ('k') | third_party/WebKit/Source/core/svg/SVGLengthList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698