| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if (s.length() != length) | 228 if (s.length() != length) |
| 229 return false; | 229 return false; |
| 230 | 230 |
| 231 if (s.Is8Bit()) | 231 if (s.Is8Bit()) |
| 232 return Equal(s.Characters8(), buffer, length); | 232 return Equal(s.Characters8(), buffer, length); |
| 233 | 233 |
| 234 return Equal(s.Characters16(), buffer, length); | 234 return Equal(s.Characters16(), buffer, length); |
| 235 } | 235 } |
| 236 | 236 |
| 237 template <typename CharType> | 237 template <typename CharType> |
| 238 bool EqualIgnoringCase(const StringBuilder& s, | 238 bool DeprecatedEqualIgnoringCase(const StringBuilder& s, |
| 239 const CharType* buffer, | 239 const CharType* buffer, |
| 240 unsigned length) { | 240 unsigned length) { |
| 241 if (s.length() != length) | 241 if (s.length() != length) |
| 242 return false; | 242 return false; |
| 243 | 243 |
| 244 if (s.Is8Bit()) | 244 if (s.Is8Bit()) |
| 245 return EqualIgnoringCase(s.Characters8(), buffer, length); | 245 return DeprecatedEqualIgnoringCase(s.Characters8(), buffer, length); |
| 246 | 246 |
| 247 return EqualIgnoringCase(s.Characters16(), buffer, length); | 247 return DeprecatedEqualIgnoringCase(s.Characters16(), buffer, length); |
| 248 } | 248 } |
| 249 | 249 |
| 250 // Unicode aware case insensitive string matching. Non-ASCII characters might | 250 // Unicode aware case insensitive string matching. Non-ASCII characters might |
| 251 // match to ASCII characters. This function is rarely used to implement web | 251 // match to ASCII characters. This function is rarely used to implement web |
| 252 // platform features. | 252 // platform features. |
| 253 inline bool EqualIgnoringCase(const StringBuilder& s, const char* string) { | 253 // This function is deprecated. We should introduce EqualIgnoringASCIICase() or |
| 254 return EqualIgnoringCase(s, reinterpret_cast<const LChar*>(string), | 254 // EqualIgnoringUnicodeCase(). See crbug.com/627682 |
| 255 strlen(string)); | 255 inline bool DeprecatedEqualIgnoringCase(const StringBuilder& s, |
| 256 const char* string) { |
| 257 return DeprecatedEqualIgnoringCase(s, reinterpret_cast<const LChar*>(string), |
| 258 strlen(string)); |
| 256 } | 259 } |
| 257 | 260 |
| 258 template <typename StringType> | 261 template <typename StringType> |
| 259 bool Equal(const StringBuilder& a, const StringType& b) { | 262 bool Equal(const StringBuilder& a, const StringType& b) { |
| 260 if (a.length() != b.length()) | 263 if (a.length() != b.length()) |
| 261 return false; | 264 return false; |
| 262 | 265 |
| 263 if (!a.length()) | 266 if (!a.length()) |
| 264 return true; | 267 return true; |
| 265 | 268 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 291 } | 294 } |
| 292 inline bool operator!=(const String& a, const StringBuilder& b) { | 295 inline bool operator!=(const String& a, const StringBuilder& b) { |
| 293 return !Equal(b, a); | 296 return !Equal(b, a); |
| 294 } | 297 } |
| 295 | 298 |
| 296 } // namespace WTF | 299 } // namespace WTF |
| 297 | 300 |
| 298 using WTF::StringBuilder; | 301 using WTF::StringBuilder; |
| 299 | 302 |
| 300 #endif // StringBuilder_h | 303 #endif // StringBuilder_h |
| OLD | NEW |