| Index: Source/core/css/parser/CSSToken.cpp | 
| diff --git a/Source/core/css/parser/CSSToken.cpp b/Source/core/css/parser/CSSToken.cpp | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..eff9d194af5f386d8ba2becb1ec648b68286fe9f | 
| --- /dev/null | 
| +++ b/Source/core/css/parser/CSSToken.cpp | 
| @@ -0,0 +1,124 @@ | 
| +/* | 
| + * Copyright (C) 2013 Google Inc. All rights reserved. | 
| + * | 
| + * Redistribution and use in source and binary forms, with or without | 
| + * modification, are permitted provided that the following conditions are | 
| + * met: | 
| + * | 
| + *     * Redistributions of source code must retain the above copyright | 
| + * notice, this list of conditions and the following disclaimer. | 
| + *     * Redistributions in binary form must reproduce the above | 
| + * copyright notice, this list of conditions and the following disclaimer | 
| + * in the documentation and/or other materials provided with the | 
| + * distribution. | 
| + *     * Neither the name of Google Inc. nor the names of its | 
| + * contributors may be used to endorse or promote products derived from | 
| + * this software without specific prior written permission. | 
| + * | 
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
| + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| + */ | 
| + | 
| +#include "config.h" | 
| +#include "core/css/parser/CSSToken.h" | 
| + | 
| +#include "wtf/HashMap.h" | 
| +#include "wtf/text/StringHash.h" | 
| + | 
| +namespace WebCore { | 
| + | 
| +typedef HashMap<String, CSSPrimitiveValue::UnitTypes> UnitTable; | 
| + | 
| +UnitTable createUnitTable() | 
| +{ | 
| +    UnitTable table; | 
| +    table.set(String("em"), CSSPrimitiveValue::CSS_EMS); | 
| +    table.set(String("ex"), CSSPrimitiveValue::CSS_EXS); | 
| +    table.set(String("px"), CSSPrimitiveValue::CSS_PX); | 
| +    table.set(String("cm"), CSSPrimitiveValue::CSS_CM); | 
| +    table.set(String("mm"), CSSPrimitiveValue::CSS_MM); | 
| +    table.set(String("in"), CSSPrimitiveValue::CSS_IN); | 
| +    table.set(String("pt"), CSSPrimitiveValue::CSS_PT); | 
| +    table.set(String("pc"), CSSPrimitiveValue::CSS_PC); | 
| +    table.set(String("deg"), CSSPrimitiveValue::CSS_DEG); | 
| +    table.set(String("rad"), CSSPrimitiveValue::CSS_RAD); | 
| +    table.set(String("grad"), CSSPrimitiveValue::CSS_GRAD); | 
| +    table.set(String("ms"), CSSPrimitiveValue::CSS_MS); | 
| +    table.set(String("s"), CSSPrimitiveValue::CSS_S); | 
| +    table.set(String("hz"), CSSPrimitiveValue::CSS_HZ); | 
| +    table.set(String("khz"), CSSPrimitiveValue::CSS_KHZ); | 
| +    table.set(String("dpi"), CSSPrimitiveValue::CSS_DPI); | 
| +    table.set(String("dpcm"), CSSPrimitiveValue::CSS_DPCM); | 
| +    table.set(String("dppx"), CSSPrimitiveValue::CSS_DPPX); | 
| +    table.set(String("vw"), CSSPrimitiveValue::CSS_VW); | 
| +    table.set(String("vh"), CSSPrimitiveValue::CSS_VH); | 
| +    table.set(String("vmax"), CSSPrimitiveValue::CSS_VMIN); | 
| +    table.set(String("vmin"), CSSPrimitiveValue::CSS_VMAX); | 
| +    return table; | 
| +} | 
| + | 
| +static UnitTable* getUnitTable() | 
| +{ | 
| +    // Allocating to avoid exit time desctructor | 
| +    static UnitTable* unitTable = new UnitTable(createUnitTable()); | 
| +    return unitTable; | 
| +} | 
| + | 
| +CSSToken::CSSToken(CSSTokenType type) | 
| +    : m_type(type) | 
| +    , m_delimiter(0) | 
| +    , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | 
| +{ | 
| +} | 
| + | 
| +// Just a helper used for Delim tokens. | 
| +CSSToken::CSSToken(CSSTokenType type, UChar c) | 
| +    : m_type(type) | 
| +    , m_delimiter(c) | 
| +    , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | 
| +{ | 
| +    ASSERT(m_type == DelimToken); | 
| +} | 
| + | 
| +CSSToken::CSSToken(CSSTokenType type, String value) | 
| +    : m_type(type) | 
| +    , m_value(value) | 
| +    , m_delimiter(0) | 
| +    , m_unit(CSSPrimitiveValue::CSS_UNKNOWN) | 
| +{ | 
| +} | 
| + | 
| +CSSToken::CSSToken(CSSTokenType type, double numericValue, NumericValueType numericValueType) | 
| +    : m_type(type) | 
| +    , m_delimiter(0) | 
| +    , m_numericValueType(numericValueType) | 
| +    , m_numericValue(numericValue) | 
| +    , m_unit(CSSPrimitiveValue::CSS_NUMBER) | 
| +{ | 
| +    ASSERT(type == NumberToken); | 
| +} | 
| + | 
| +void CSSToken::convertToDimensionWithUnit(String unit) | 
| +{ | 
| +    ASSERT(m_type == NumberToken); | 
| +    m_type = DimensionToken; | 
| +    m_unit = getUnitTable()->get(unit.lower()); | 
| +} | 
| + | 
| +void CSSToken::convertToPercentage() | 
| +{ | 
| +    ASSERT(m_type == NumberToken); | 
| +    m_type = PercentageToken; | 
| +    m_unit = CSSPrimitiveValue::CSS_PERCENTAGE; | 
| +} | 
| + | 
| +} // namespace WebCore | 
|  |