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

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

Issue 2002383002: Avoid string allocation when parsing CSSPrimitiveValue::UnitType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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/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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return builder.append('}'); 288 return builder.append('}');
284 289
285 case EOFToken: 290 case EOFToken:
286 case CommentToken: 291 case CommentToken:
287 ASSERT_NOT_REACHED(); 292 ASSERT_NOT_REACHED();
288 return; 293 return;
289 } 294 }
290 } 295 }
291 296
292 } // namespace blink 297 } // 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