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

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

Issue 23549032: Add toSVGLengthType() and toSVGLengthMode() fuctions, and use it. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGLength.cpp
diff --git a/Source/core/svg/SVGLength.cpp b/Source/core/svg/SVGLength.cpp
index f6ae8a77467dae3ddc726d445dbc02d3af8b1ced..4f78c90264381bde1389d560d74a6db65a6ad23e 100644
--- a/Source/core/svg/SVGLength.cpp
+++ b/Source/core/svg/SVGLength.cpp
@@ -34,6 +34,18 @@
namespace WebCore {
+static inline SVGLengthMode toSVGLengthMode(unsigned short mode)
+{
+ ASSERT(mode >= LengthModeWidth && mode <= LengthModeOther);
+ return static_cast<SVGLengthMode>(mode);
+}
+
+static inline SVGLengthType toSVGLengthType(unsigned short type)
+{
+ ASSERT(type >= LengthTypeUnknown && type <= LengthTypePC);
+ return static_cast<SVGLengthType>(type);
+}
+
static inline unsigned int storeUnit(SVGLengthMode mode, SVGLengthType type)
{
return (mode << 4) | type;
@@ -42,14 +54,14 @@ static inline unsigned int storeUnit(SVGLengthMode mode, SVGLengthType type)
static inline SVGLengthMode extractMode(unsigned int unit)
{
unsigned int mode = unit >> 4;
- return static_cast<SVGLengthMode>(mode);
+ return toSVGLengthMode(mode);
}
static inline SVGLengthType extractType(unsigned int unit)
{
unsigned int mode = unit >> 4;
unsigned int type = unit ^ (mode << 4);
- return static_cast<SVGLengthType>(type);
+ return toSVGLengthType(type);
}
static inline String lengthTypeToString(SVGLengthType type)
@@ -266,7 +278,7 @@ void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, Excepti
return;
}
- m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
+ m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
m_valueInSpecifiedUnits = value;
}
@@ -282,7 +294,7 @@ void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthCont
return;
unsigned int originalUnitAndType = m_unit;
- m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
+ m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
setValue(valueInUserUnits, context, es);
if (!es.hadException())
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698