Commit 425f82b2 authored by yoav@yoav.ws's avatar yoav@yoav.ws

Refactor unitTable access

Following the review of https://codereview.chromium.org/209443002/ , I've changed the unitTable access method to be a static CSSPrimitiveValue::fromName method.

BUG=

Review URL: https://codereview.chromium.org/209443003

git-svn-id: svn://svn.chromium.org/blink/trunk@169802 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 74824950
......@@ -140,10 +140,10 @@ CSSPrimitiveValue::UnitTable createUnitTable()
return table;
}
CSSPrimitiveValue::UnitTable& CSSPrimitiveValue::getUnitTable()
CSSPrimitiveValue::UnitTypes CSSPrimitiveValue::fromName(const String& unit)
{
DEFINE_STATIC_LOCAL(UnitTable, unitTable, (createUnitTable()));
return unitTable;
return unitTable.get(unit.lower());
}
CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(CSSPrimitiveValue::UnitTypes type)
......
......@@ -150,7 +150,7 @@ public:
static UnitCategory unitCategory(CSSPrimitiveValue::UnitTypes);
typedef HashMap<String, CSSPrimitiveValue::UnitTypes> UnitTable;
static UnitTable& getUnitTable();
static UnitTypes fromName(const String& unit);
bool isAngle() const
{
......
......@@ -49,7 +49,7 @@ void MediaQueryToken::convertToDimensionWithUnit(String unit)
{
ASSERT(m_type == NumberToken);
m_type = DimensionToken;
m_unit = CSSPrimitiveValue::getUnitTable().get(unit.lower());
m_unit = CSSPrimitiveValue::fromName(unit);
}
void MediaQueryToken::convertToPercentage()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment