| 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 "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/parser/CSSPropertyParser.h" | 8 #include "core/css/parser/CSSPropertyParser.h" |
| 9 #include "wtf/HashMap.h" | 9 #include "wtf/HashMap.h" |
| 10 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 || tokenType == StringToken; | 140 || tokenType == StringToken; |
| 141 } | 141 } |
| 142 | 142 |
| 143 CSSParserToken CSSParserToken::copyWithUpdatedString(const CSSParserString& pars
erString) const | 143 CSSParserToken CSSParserToken::copyWithUpdatedString(const CSSParserString& pars
erString) const |
| 144 { | 144 { |
| 145 CSSParserToken copy(*this); | 145 CSSParserToken copy(*this); |
| 146 copy.initValueFromCSSParserString(parserString); | 146 copy.initValueFromCSSParserString(parserString); |
| 147 return copy; | 147 return copy; |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool CSSParserToken::operator==(const CSSParserToken& other) const |
| 151 { |
| 152 if (m_type != other.m_type) |
| 153 return false; |
| 154 switch (m_type) { |
| 155 case DelimiterToken: |
| 156 return delimiter() == other.delimiter(); |
| 157 case HashToken: |
| 158 if (m_hashTokenType != other.m_hashTokenType) |
| 159 return false; |
| 160 // fallthrough |
| 161 case IdentToken: |
| 162 case FunctionToken: |
| 163 case StringToken: |
| 164 case UrlToken: |
| 165 return m_valueDataCharRaw == other.m_valueDataCharRaw && m_valueLength =
= other.m_valueLength && m_valueIs8Bit == other.m_valueIs8Bit; |
| 166 case DimensionToken: |
| 167 if (m_valueDataCharRaw != other.m_valueDataCharRaw || m_valueLength != o
ther.m_valueLength || m_valueIs8Bit != other.m_valueIs8Bit) |
| 168 return false; |
| 169 // fallthrough |
| 170 case NumberToken: |
| 171 case PercentageToken: |
| 172 return m_numericSign == other.m_numericSign && m_numericValue == other.m
_numericValue && m_numericValueType == other.m_numericValueType; |
| 173 case UnicodeRangeToken: |
| 174 return m_unicodeRange.start == other.m_unicodeRange.start && m_unicodeRa
nge.end == other.m_unicodeRange.end; |
| 175 default: |
| 176 return true; |
| 177 } |
| 178 } |
| 179 |
| 150 void CSSParserToken::serialize(StringBuilder& builder) const | 180 void CSSParserToken::serialize(StringBuilder& builder) const |
| 151 { | 181 { |
| 152 // This is currently only used for @supports CSSOM. To keep our implementati
on | 182 // This is currently only used for @supports CSSOM. To keep our implementati
on |
| 153 // simple we handle some of the edge cases incorrectly (see comments below). | 183 // simple we handle some of the edge cases incorrectly (see comments below). |
| 154 switch (type()) { | 184 switch (type()) { |
| 155 case IdentToken: | 185 case IdentToken: |
| 156 serializeIdentifier(value(), builder); | 186 serializeIdentifier(value(), builder); |
| 157 break; | 187 break; |
| 158 case FunctionToken: | 188 case FunctionToken: |
| 159 serializeIdentifier(value(), builder); | 189 serializeIdentifier(value(), builder); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 return builder.append('}'); | 264 return builder.append('}'); |
| 235 | 265 |
| 236 case EOFToken: | 266 case EOFToken: |
| 237 case CommentToken: | 267 case CommentToken: |
| 238 ASSERT_NOT_REACHED(); | 268 ASSERT_NOT_REACHED(); |
| 239 return; | 269 return; |
| 240 } | 270 } |
| 241 } | 271 } |
| 242 | 272 |
| 243 } // namespace blink | 273 } // namespace blink |
| OLD | NEW |