Index: Source/core/svg/SVGLengthContext.cpp |
diff --git a/Source/core/svg/SVGLengthContext.cpp b/Source/core/svg/SVGLengthContext.cpp |
index 0464f26affd2d14ada7b70961359f5f142525276..22c7d580dce1f7b6ad11b329d4f800c804024fa3 100644 |
--- a/Source/core/svg/SVGLengthContext.cpp |
+++ b/Source/core/svg/SVGLengthContext.cpp |
@@ -220,6 +220,9 @@ float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, |
case LengthTypeREMS: |
userUnits = convertValueFromEMSToUserUnits(rootElementStyle(m_context), value); |
break; |
+ case LengthTypeCHS: |
+ userUnits = convertValueFromCHSToUserUnits(value); |
+ break; |
default: |
ASSERT_NOT_REACHED(); |
break; |
@@ -252,6 +255,8 @@ float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mod |
return convertValueFromUserUnitsToEXS(value); |
case LengthTypeREMS: |
return convertValueFromUserUnitsToEMS(rootElementStyle(m_context), value); |
+ case LengthTypeCHS: |
+ return convertValueFromUserUnitsToCHS(value); |
case LengthTypePX: |
return value; |
case LengthTypeCM: |
@@ -270,6 +275,28 @@ float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mod |
return 0; |
} |
+float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const |
+{ |
+ const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
+ if (!style) |
+ return 0; |
+ |
+ float zeroWidth = style->fontMetrics().zeroWidth(); |
+ if (!zeroWidth) |
+ return 0; |
+ |
+ return value / zeroWidth; |
+} |
+ |
+float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const |
+{ |
+ const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
+ if (!style) |
+ return 0; |
+ |
+ return value * style->fontMetrics().zeroWidth(); |
+} |
+ |
float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const |
{ |
const ComputedStyle* style = computedStyleForLengthResolving(m_context); |