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

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

Issue 1967073003: Make CSSParserToken::operator== perform a full string equality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. Created 4 years, 7 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
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/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
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::valueDataCharRawEqual(const CSSParserToken& other) const
151 {
152 if (m_valueLength != other.m_valueLength)
153 return false;
154
155 if (m_valueDataCharRaw == other.m_valueDataCharRaw && m_valueIs8Bit == other .m_valueIs8Bit)
156 return true;
157
158 if (m_valueIs8Bit) {
159 return other.m_valueIs8Bit ?
160 equal(static_cast<const LChar*>(m_valueDataCharRaw), static_cast<con st LChar*>(other.m_valueDataCharRaw), m_valueLength) :
161 equal(static_cast<const LChar*>(m_valueDataCharRaw), static_cast<con st UChar*>(other.m_valueDataCharRaw), m_valueLength);
162 } else {
163 return other.m_valueIs8Bit ?
164 equal(static_cast<const UChar*>(m_valueDataCharRaw), static_cast<con st LChar*>(other.m_valueDataCharRaw), m_valueLength) :
165 equal(static_cast<const UChar*>(m_valueDataCharRaw), static_cast<con st UChar*>(other.m_valueDataCharRaw), m_valueLength);
166 }
167 }
168
150 bool CSSParserToken::operator==(const CSSParserToken& other) const 169 bool CSSParserToken::operator==(const CSSParserToken& other) const
151 { 170 {
152 if (m_type != other.m_type) 171 if (m_type != other.m_type)
153 return false; 172 return false;
154 switch (m_type) { 173 switch (m_type) {
155 case DelimiterToken: 174 case DelimiterToken:
156 return delimiter() == other.delimiter(); 175 return delimiter() == other.delimiter();
157 case HashToken: 176 case HashToken:
158 if (m_hashTokenType != other.m_hashTokenType) 177 if (m_hashTokenType != other.m_hashTokenType)
159 return false; 178 return false;
160 // fallthrough 179 // fallthrough
161 case IdentToken: 180 case IdentToken:
162 case FunctionToken: 181 case FunctionToken:
163 case StringToken: 182 case StringToken:
164 case UrlToken: 183 case UrlToken:
165 return m_valueDataCharRaw == other.m_valueDataCharRaw && m_valueLength = = other.m_valueLength && m_valueIs8Bit == other.m_valueIs8Bit; 184 return valueDataCharRawEqual(other);
166 case DimensionToken: 185 case DimensionToken:
167 if (m_valueDataCharRaw != other.m_valueDataCharRaw || m_valueLength != o ther.m_valueLength || m_valueIs8Bit != other.m_valueIs8Bit) 186 if (!valueDataCharRawEqual(other))
168 return false; 187 return false;
169 // fallthrough 188 // fallthrough
170 case NumberToken: 189 case NumberToken:
171 case PercentageToken: 190 case PercentageToken:
172 return m_numericSign == other.m_numericSign && m_numericValue == other.m _numericValue && m_numericValueType == other.m_numericValueType; 191 return m_numericSign == other.m_numericSign && m_numericValue == other.m _numericValue && m_numericValueType == other.m_numericValueType;
173 case UnicodeRangeToken: 192 case UnicodeRangeToken:
174 return m_unicodeRange.start == other.m_unicodeRange.start && m_unicodeRa nge.end == other.m_unicodeRange.end; 193 return m_unicodeRange.start == other.m_unicodeRange.start && m_unicodeRa nge.end == other.m_unicodeRange.end;
175 default: 194 default:
176 return true; 195 return true;
177 } 196 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return builder.append('}'); 283 return builder.append('}');
265 284
266 case EOFToken: 285 case EOFToken:
267 case CommentToken: 286 case CommentToken:
268 ASSERT_NOT_REACHED(); 287 ASSERT_NOT_REACHED();
269 return; 288 return;
270 } 289 }
271 } 290 }
272 291
273 } // namespace blink 292 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698