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

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

Issue 1073803002: SVG doesn't recognize ch units. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 8 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
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698