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

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: Changed font-familt from serif to Ahem and align with review comments 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
« Source/core/svg/SVGLength.cpp ('K') | « 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 3bf1f9a27ad61ef7e4abb842f82c4149cb6ceb4b..cf0bff5f1f99ef2d6d1d743f716e16f60f887710 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -172,6 +172,9 @@ float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
case LengthTypeREMS:
userUnits = convertValueFromREMSToUserUnits(value);
break;
+ case LengthTypeCHS:
+ userUnits = convertValueFromCHSToUserUnits(value);
+ break;
default:
ASSERT_NOT_REACHED();
break;
@@ -204,6 +207,8 @@ float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mod
return convertValueFromUserUnitsToEXS(value);
case LengthTypeREMS:
return convertValueFromUserUnitsToREMS(value);
+ case LengthTypeCHS:
+ return convertValueFromUserUnitsToCHS(value);
case LengthTypePX:
return value;
case LengthTypeCM:
@@ -302,6 +307,28 @@ float SVGLengthContext::convertValueFromREMSToUserUnits(float value) const
return value * style->specifiedFontSize();
}
+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);
« Source/core/svg/SVGLength.cpp ('K') | « Source/core/svg/SVGLengthContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698