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

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

Issue 1319343004: Add property parser code path based on CSSParserTokenRange (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 3 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 | « Source/core/css/parser/CSSParserToken.h ('k') | Source/core/css/parser/CSSParserValues.cpp » ('j') | 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 "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSParserToken.h" 6 #include "core/css/parser/CSSParserToken.h"
7 7
8 #include "core/css/CSSMarkup.h" 8 #include "core/css/CSSMarkup.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"
(...skipping 15 matching lines...) Expand all
26 , m_delimiter(c) 26 , m_delimiter(c)
27 { 27 {
28 ASSERT(m_type == DelimiterToken); 28 ASSERT(m_type == DelimiterToken);
29 } 29 }
30 30
31 CSSParserToken::CSSParserToken(CSSParserTokenType type, CSSParserString value, B lockType blockType) 31 CSSParserToken::CSSParserToken(CSSParserTokenType type, CSSParserString value, B lockType blockType)
32 : m_type(type) 32 : m_type(type)
33 , m_blockType(blockType) 33 , m_blockType(blockType)
34 { 34 {
35 initValueFromCSSParserString(value); 35 initValueFromCSSParserString(value);
36 m_id = -1;
36 } 37 }
37 38
38 CSSParserToken::CSSParserToken(CSSParserTokenType type, double numericValue, Num ericValueType numericValueType, NumericSign sign) 39 CSSParserToken::CSSParserToken(CSSParserTokenType type, double numericValue, Num ericValueType numericValueType, NumericSign sign)
39 : m_type(type) 40 : m_type(type)
40 , m_blockType(NotBlock) 41 , m_blockType(NotBlock)
41 , m_numericValueType(numericValueType) 42 , m_numericValueType(numericValueType)
42 , m_numericSign(sign) 43 , m_numericSign(sign)
43 , m_unit(static_cast<unsigned>(CSSPrimitiveValue::UnitType::Number)) 44 , m_unit(static_cast<unsigned>(CSSPrimitiveValue::UnitType::Number))
44 , m_numericValue(numericValue) 45 , m_numericValue(numericValue)
45 { 46 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ASSERT(m_type == NumberToken || m_type == PercentageToken || m_type == Dimen sionToken); 104 ASSERT(m_type == NumberToken || m_type == PercentageToken || m_type == Dimen sionToken);
104 return m_numericValue; 105 return m_numericValue;
105 } 106 }
106 107
107 CSSPropertyID CSSParserToken::parseAsUnresolvedCSSPropertyID() const 108 CSSPropertyID CSSParserToken::parseAsUnresolvedCSSPropertyID() const
108 { 109 {
109 ASSERT(m_type == IdentToken); 110 ASSERT(m_type == IdentToken);
110 return unresolvedCSSPropertyID(value()); 111 return unresolvedCSSPropertyID(value());
111 } 112 }
112 113
114 CSSValueID CSSParserToken::id() const
115 {
116 if (m_type != IdentToken)
117 return CSSValueInvalid;
118 if (m_id < 0)
119 m_id = cssValueKeywordID(value());
120 return static_cast<CSSValueID>(m_id);
121 }
122
123 CSSValueID CSSParserToken::functionId() const
124 {
125 if (m_type != FunctionToken)
126 return CSSValueInvalid;
127 if (m_id < 0)
128 m_id = cssValueKeywordID(value());
129 return static_cast<CSSValueID>(m_id);
130 }
131
113 void CSSParserToken::serialize(StringBuilder& builder) const 132 void CSSParserToken::serialize(StringBuilder& builder) const
114 { 133 {
115 // This is currently only used for @supports CSSOM. To keep our implementati on 134 // This is currently only used for @supports CSSOM. To keep our implementati on
116 // simple we handle some of the edge cases incorrectly (see comments below). 135 // simple we handle some of the edge cases incorrectly (see comments below).
117 switch (type()) { 136 switch (type()) {
118 case IdentToken: 137 case IdentToken:
119 serializeIdentifier(value(), builder); 138 serializeIdentifier(value(), builder);
120 break; 139 break;
121 case FunctionToken: 140 case FunctionToken:
122 serializeIdentifier(value(), builder); 141 serializeIdentifier(value(), builder);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 return builder.append('}'); 216 return builder.append('}');
198 217
199 case EOFToken: 218 case EOFToken:
200 case CommentToken: 219 case CommentToken:
201 ASSERT_NOT_REACHED(); 220 ASSERT_NOT_REACHED();
202 return; 221 return;
203 } 222 }
204 } 223 }
205 224
206 } // namespace blink 225 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSParserToken.h ('k') | Source/core/css/parser/CSSParserValues.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698