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

Unified Diff: third_party/WebKit/Source/wtf/text/StringImpl.h

Issue 1499933003: Use ASCII case-insensitive matching for attribute selectors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WTF -> StringTest Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/text/StringImpl.h
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.h b/third_party/WebKit/Source/wtf/text/StringImpl.h
index d93f6d2df50c89e268b5c9a73a2f02f666063488..f30ec2af721b2f93a7d801cdd1d2091ff7276758 100644
--- a/third_party/WebKit/Source/wtf/text/StringImpl.h
+++ b/third_party/WebKit/Source/wtf/text/StringImpl.h
@@ -52,7 +52,7 @@ struct SubstringTranslator;
struct UCharBufferTranslator;
template<typename> class RetainPtr;
-enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
+enum TextCaseSensitivity { TextCaseSensitive, TextCaseASCIIInsensitive, TextCaseInsensitive };
enum StripBehavior { StripExtraWhiteSpace, DoNotStripWhiteSpace };
@@ -374,6 +374,7 @@ public:
size_t findIgnoringCase(const LChar*, unsigned index = 0);
ALWAYS_INLINE size_t findIgnoringCase(const char* s, unsigned index = 0) { return findIgnoringCase(reinterpret_cast<const LChar*>(s), index); }
size_t findIgnoringCase(StringImpl*, unsigned index = 0);
+ size_t findIgnoringASCIICase(StringImpl*, unsigned index = 0);
size_t findNextLineStart(unsigned index = UINT_MAX);
@@ -386,11 +387,13 @@ public:
bool startsWith(const char*, unsigned matchLength) const;
bool startsWith(const StringImpl*) const;
bool startsWithIgnoringCase(const StringImpl*) const;
+ bool startsWithIgnoringASCIICase(const StringImpl*) const;
bool endsWith(UChar) const;
bool endsWith(const char*, unsigned matchLength) const;
bool endsWith(const StringImpl*) const;
bool endsWithIgnoringCase(const StringImpl*) const;
+ bool endsWithIgnoringASCIICase(const StringImpl*) const;
PassRefPtr<StringImpl> replace(UChar, UChar);
PassRefPtr<StringImpl> replace(UChar, StringImpl*);
@@ -506,20 +509,19 @@ inline bool equalIgnoringASCIICase(const CharacterTypeA* a, const CharacterTypeB
}
template<typename CharacterTypeA, typename CharacterTypeB>
-bool startsWithIgnoringASCIICase(const CharacterTypeA& reference, const CharacterTypeB& prefix)
+inline bool equalIgnoringASCIICase(const CharacterTypeA& a, const CharacterTypeB& b)
{
- unsigned prefixLength = prefix.length();
- if (prefixLength > reference.length())
+ unsigned length = b.length();
+ if (a.length() != length)
return false;
-
- if (reference.is8Bit()) {
- if (prefix.is8Bit())
- return equalIgnoringASCIICase(reference.characters8(), prefix.characters8(), prefixLength);
- return equalIgnoringASCIICase(reference.characters8(), prefix.characters16(), prefixLength);
- }
- if (prefix.is8Bit())
- return equalIgnoringASCIICase(reference.characters16(), prefix.characters8(), prefixLength);
- return equalIgnoringASCIICase(reference.characters16(), prefix.characters16(), prefixLength);
+ if (a.is8Bit()) {
+ if (b.is8Bit())
+ return equalIgnoringASCIICase(a.characters8(), b.characters8(), length);
+ return equalIgnoringASCIICase(a.characters8(), b.characters16(), length);
+ }
+ if (b.is8Bit())
+ return equalIgnoringASCIICase(a.characters16(), b.characters8(), length);
+ return equalIgnoringASCIICase(a.characters16(), b.characters16(), length);
}
template<typename CharacterType>
@@ -769,6 +771,7 @@ using WTF::equal;
using WTF::equalNonNull;
using WTF::TextCaseSensitivity;
using WTF::TextCaseSensitive;
+using WTF::TextCaseASCIIInsensitive;
using WTF::TextCaseInsensitive;
#endif
« no previous file with comments | « third_party/WebKit/Source/core/css/SelectorChecker.cpp ('k') | third_party/WebKit/Source/wtf/text/StringImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698