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

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

Issue 2051313002: Encapsulate the CSSPrimitiveValue UnitType trie bethind a method that takes a StringView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/CSSPrimitiveValue.h"
9 #include "core/css/parser/CSSPropertyParser.h" 9 #include "core/css/parser/CSSPropertyParser.h"
10 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
11 #include "wtf/text/StringBuilder.h" 11 #include "wtf/text/StringBuilder.h"
12 #include <limits.h> 12 #include <limits.h>
13 13
14 namespace blink { 14 namespace blink {
15 15
16 CSSParserToken::CSSParserToken(CSSParserTokenType type, BlockType blockType) 16 CSSParserToken::CSSParserToken(CSSParserTokenType type, BlockType blockType)
17 : m_type(type) 17 : m_type(type)
18 , m_blockType(blockType) 18 , m_blockType(blockType)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 , m_hashTokenType(type) 62 , m_hashTokenType(type)
63 { 63 {
64 initValueFromStringView(value); 64 initValueFromStringView(value);
65 } 65 }
66 66
67 void CSSParserToken::convertToDimensionWithUnit(StringView unit) 67 void CSSParserToken::convertToDimensionWithUnit(StringView unit)
68 { 68 {
69 ASSERT(m_type == NumberToken); 69 ASSERT(m_type == NumberToken);
70 m_type = DimensionToken; 70 m_type = DimensionToken;
71 initValueFromStringView(unit); 71 initValueFromStringView(unit);
72 72 m_unit = static_cast<unsigned>(CSSPrimitiveValue::stringToUnitType(unit));
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()));
77 } 73 }
78 74
79 void CSSParserToken::convertToPercentage() 75 void CSSParserToken::convertToPercentage()
80 { 76 {
81 ASSERT(m_type == NumberToken); 77 ASSERT(m_type == NumberToken);
82 m_type = PercentageToken; 78 m_type = PercentageToken;
83 m_unit = static_cast<unsigned>(CSSPrimitiveValue::UnitType::Percentage); 79 m_unit = static_cast<unsigned>(CSSPrimitiveValue::UnitType::Percentage);
84 } 80 }
85 81
86 UChar CSSParserToken::delimiter() const 82 UChar CSSParserToken::delimiter() const
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return builder.append('}'); 284 return builder.append('}');
289 285
290 case EOFToken: 286 case EOFToken:
291 case CommentToken: 287 case CommentToken:
292 ASSERT_NOT_REACHED(); 288 ASSERT_NOT_REACHED();
293 return; 289 return;
294 } 290 }
295 } 291 }
296 292
297 } // namespace blink 293 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698