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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSParserToken.cpp

Issue 1938343002: Generate a series of nested switch statements to parse CSSPrimitiveValue units. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make all values appear in the .in file Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return builder.append('}'); 269 return builder.append('}');
265 270
266 case EOFToken: 271 case EOFToken:
267 case CommentToken: 272 case CommentToken:
268 ASSERT_NOT_REACHED(); 273 ASSERT_NOT_REACHED();
269 return; 274 return;
270 } 275 }
271 } 276 }
272 277
273 } // namespace blink 278 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698