OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/parser/CSSParserToken.h" | 5 #include "core/css/parser/CSSParserToken.h" |
6 | 6 |
7 #include "core/css/CSSMarkup.h" | 7 #include "core/css/CSSMarkup.h" |
| 8 #include "core/css/CSSPrimitiveValueUnitTrie.h" |
8 #include "core/css/parser/CSSPropertyParser.h" | 9 #include "core/css/parser/CSSPropertyParser.h" |
9 #include "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" |
10 #include "wtf/text/StringBuilder.h" | 11 #include "wtf/text/StringBuilder.h" |
11 #include <limits.h> | 12 #include <limits.h> |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 CSSParserToken::CSSParserToken(CSSParserTokenType type, BlockType blockType) | 16 CSSParserToken::CSSParserToken(CSSParserTokenType type, BlockType blockType) |
16 : m_type(type) | 17 : m_type(type) |
17 , m_blockType(blockType) | 18 , m_blockType(blockType) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 , m_hashTokenType(type) | 62 , m_hashTokenType(type) |
62 { | 63 { |
63 initValueFromCSSParserString(value); | 64 initValueFromCSSParserString(value); |
64 } | 65 } |
65 | 66 |
66 void CSSParserToken::convertToDimensionWithUnit(CSSParserString unit) | 67 void CSSParserToken::convertToDimensionWithUnit(CSSParserString unit) |
67 { | 68 { |
68 ASSERT(m_type == NumberToken); | 69 ASSERT(m_type == NumberToken); |
69 m_type = DimensionToken; | 70 m_type = DimensionToken; |
70 initValueFromCSSParserString(unit); | 71 initValueFromCSSParserString(unit); |
71 m_unit = static_cast<unsigned>(CSSPrimitiveValue::fromName(unit)); | 72 |
| 73 if (unit.is8Bit()) |
| 74 m_unit = static_cast<unsigned>(lookupCSSPrimitiveValueUnit(unit.characte
rs8(), unit.length())); |
| 75 else |
| 76 m_unit = static_cast<unsigned>(lookupCSSPrimitiveValueUnit(unit.characte
rs16(), unit.length())); |
72 } | 77 } |
73 | 78 |
74 void CSSParserToken::convertToPercentage() | 79 void CSSParserToken::convertToPercentage() |
75 { | 80 { |
76 ASSERT(m_type == NumberToken); | 81 ASSERT(m_type == NumberToken); |
77 m_type = PercentageToken; | 82 m_type = PercentageToken; |
78 m_unit = static_cast<unsigned>(CSSPrimitiveValue::UnitType::Percentage); | 83 m_unit = static_cast<unsigned>(CSSPrimitiveValue::UnitType::Percentage); |
79 } | 84 } |
80 | 85 |
81 UChar CSSParserToken::delimiter() const | 86 UChar CSSParserToken::delimiter() const |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return builder.append('}'); | 239 return builder.append('}'); |
235 | 240 |
236 case EOFToken: | 241 case EOFToken: |
237 case CommentToken: | 242 case CommentToken: |
238 ASSERT_NOT_REACHED(); | 243 ASSERT_NOT_REACHED(); |
239 return; | 244 return; |
240 } | 245 } |
241 } | 246 } |
242 | 247 |
243 } // namespace blink | 248 } // namespace blink |
OLD | NEW |