| 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 "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 Loading... |
| 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 Loading... |
| 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 && m_type != FunctionToken) |
| 117 return CSSValueInvalid; |
| 118 if (m_id < 0) |
| 119 m_id = cssValueKeywordID(value()); |
| 120 return static_cast<CSSValueID>(m_id); |
| 121 } |
| 122 |
| 113 void CSSParserToken::serialize(StringBuilder& builder) const | 123 void CSSParserToken::serialize(StringBuilder& builder) const |
| 114 { | 124 { |
| 115 // This is currently only used for @supports CSSOM. To keep our implementati
on | 125 // 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). | 126 // simple we handle some of the edge cases incorrectly (see comments below). |
| 117 switch (type()) { | 127 switch (type()) { |
| 118 case IdentToken: | 128 case IdentToken: |
| 119 serializeIdentifier(value(), builder); | 129 serializeIdentifier(value(), builder); |
| 120 break; | 130 break; |
| 121 case FunctionToken: | 131 case FunctionToken: |
| 122 serializeIdentifier(value(), builder); | 132 serializeIdentifier(value(), builder); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return builder.append('}'); | 207 return builder.append('}'); |
| 198 | 208 |
| 199 case EOFToken: | 209 case EOFToken: |
| 200 case CommentToken: | 210 case CommentToken: |
| 201 ASSERT_NOT_REACHED(); | 211 ASSERT_NOT_REACHED(); |
| 202 return; | 212 return; |
| 203 } | 213 } |
| 204 } | 214 } |
| 205 | 215 |
| 206 } // namespace blink | 216 } // namespace blink |
| OLD | NEW |