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

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

Issue 1841143002: Add enum class |WebEditingCommandType| for EditorCommand (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introducing |codePointCompareIgnoringASCIICase()| Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/StringImpl.cpp
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.cpp b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
index 558beb8a3be377e288f0895970462db0298f62f9..3027cacff98f9806d75a3235fb42030f02361b19 100644
--- a/third_party/WebKit/Source/wtf/text/StringImpl.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
@@ -2303,6 +2303,42 @@ bool equalIgnoringASCIICase(const StringImpl* a, const LChar* b)
return equalSubstringIgnoringASCIICase(a, 0, b, length);
}
+template<typename CharacterType1, typename CharacterType2>
+int codePointCompareIgnoringASCIICase(unsigned l1, unsigned l2, const CharacterType1* c1, const CharacterType2* c2)
+{
+ const unsigned lmin = l1 < l2 ? l1 : l2;
+ unsigned pos = 0;
+ while (pos < lmin && toASCIILower(*c1) == toASCIILower(*c2)) {
+ ++c1;
+ ++c2;
+ ++pos;
+ }
+
+ if (pos < lmin)
+ return (toASCIILower(c1[0]) > toASCIILower(c2[0])) ? 1 : -1;
+
+ if (l1 == l2)
+ return 0;
+
+ return (l1 > l2) ? 1 : -1;
+}
+
+int codePointCompareIgnoringASCIICase(const StringImpl* string1, const LChar* string2)
+{
+ unsigned length1 = string1 ? string1->length() : 0;
+ size_t length2 = string2 ? strlen(reinterpret_cast<const char*>(string2)) : 0;
+
+ if (!string1)
+ return length2 > 0 ? -1 : 0;
+
+ if (!string2)
+ return length1 > 0 ? 1 : 0;
+
+ if (string1->is8Bit())
+ return codePointCompareIgnoringASCIICase(length1, length2, string1->characters8(), string2);
+ return codePointCompareIgnoringASCIICase(length1, length2, string1->characters16(), string2);
+}
+
size_t StringImpl::sizeInBytes() const
{
size_t size = length();
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698