Diff
Modified: trunk/Source/WTF/ChangeLog (198018 => 198019)
--- trunk/Source/WTF/ChangeLog 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Source/WTF/ChangeLog 2016-03-11 15:10:18 UTC (rev 198019)
@@ -1,3 +1,25 @@
+2016-03-11 Youenn Fablet <[email protected]>
+
+ WTF should have a similar function as equalLettersIgnoringASCIICase to match beginning of strings
+ https://bugs.webkit.org/show_bug.cgi?id=153419
+
+ Reviewed by Darin Adler.
+
+ Introducing startsWithLettersIgnoringASCIICase, to check the beginning of a string.
+ Moving some code from WTF::equalLettersIgnoringASCIICaseCommonWithoutLength in
+ WTF::hasPrefixWithLettersIgnoringASCIICaseCommon to enable reuse in
+ WTF::startsWithLettersIgnoringASCIICaseCommon.
+
+ * wtf/text/StringCommon.h:
+ (WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
+ (WTF::equalLettersIgnoringASCIICaseCommonWithoutLength):
+ (WTF::startsWithLettersIgnoringASCIICaseCommonWithoutLength):
+ (WTF::startsWithLettersIgnoringASCIICaseCommon):
+ * wtf/text/StringImpl.h:
+ (WTF::startsWithLettersIgnoringASCIICase):
+ * wtf/text/WTFString.h:
+ (WTF::startsWithLettersIgnoringASCIICase):
+
2016-03-10 Frederic Wang <[email protected]>
[GTK] Add support for WOFF2
Modified: trunk/Source/WTF/wtf/text/StringCommon.h (198018 => 198019)
--- trunk/Source/WTF/wtf/text/StringCommon.h 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Source/WTF/wtf/text/StringCommon.h 2016-03-11 15:10:18 UTC (rev 198019)
@@ -590,22 +590,39 @@
return charactersLength == lowercaseLettersStringLength && equalLettersIgnoringASCIICase(characters, lowercaseLetters, lowercaseLettersStringLength);
}
-// This is intentionally not marked inline because it's used often and is not speed-critical enough to want it inlined everywhere.
-template<typename StringClass> bool equalLettersIgnoringASCIICaseCommonWithoutLength(const StringClass& string, const char* lowercaseLetters)
+template<typename StringClass> bool inline hasPrefixWithLettersIgnoringASCIICaseCommon(const StringClass& string, const char* lowercaseLetters, unsigned length)
{
#if !ASSERT_DISABLED
ASSERT(*lowercaseLetters);
for (const char* letter = lowercaseLetters; *letter; ++letter)
ASSERT(toASCIILowerUnchecked(*letter) == *letter);
#endif
- unsigned length = string.length();
- if (length != strlen(lowercaseLetters))
- return false;
+ ASSERT(string.length() >= length);
+
if (string.is8Bit())
return equalLettersIgnoringASCIICase(string.characters8(), lowercaseLetters, length);
return equalLettersIgnoringASCIICase(string.characters16(), lowercaseLetters, length);
}
+// This is intentionally not marked inline because it's used often and is not speed-critical enough to want it inlined everywhere.
+template<typename StringClass> bool equalLettersIgnoringASCIICaseCommonWithoutLength(const StringClass& string, const char* lowercaseLetters)
+{
+ unsigned length = string.length();
+ if (length != strlen(lowercaseLetters))
+ return false;
+ return hasPrefixWithLettersIgnoringASCIICaseCommon(string, lowercaseLetters, length);
+}
+
+template<typename StringClass> bool startsWithLettersIgnoringASCIICaseCommonWithoutLength(const StringClass& string, const char* lowercaseLetters)
+{
+ size_t prefixLength = strlen(lowercaseLetters);
+ if (!prefixLength)
+ return true;
+ if (string.length() < prefixLength)
+ return false;
+ return hasPrefixWithLettersIgnoringASCIICaseCommon(string, lowercaseLetters, prefixLength);
+}
+
template<typename StringClass, unsigned length> inline bool equalLettersIgnoringASCIICaseCommon(const StringClass& string, const char (&lowercaseLetters)[length])
{
// Don't actually use the length; we are choosing code size over speed.
@@ -614,8 +631,14 @@
return equalLettersIgnoringASCIICaseCommonWithoutLength(string, pointer);
}
+template<typename StringClass, unsigned length> inline bool startsWithLettersIgnoringASCIICaseCommon(const StringClass& string, const char (&lowercaseLetters)[length])
+{
+ const char* pointer = lowercaseLetters;
+ return startsWithLettersIgnoringASCIICaseCommonWithoutLength(string, pointer);
}
+}
+
using WTF::equalIgnoringASCIICase;
using WTF::equalLettersIgnoringASCIICase;
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (198018 => 198019)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2016-03-11 15:10:18 UTC (rev 198019)
@@ -1181,6 +1181,16 @@
return a && equalIgnoringASCIICase(*a, b);
}
+template<unsigned length> inline bool startsWithLettersIgnoringASCIICase(const StringImpl& string, const char (&lowercaseLetters)[length])
+{
+ return startsWithLettersIgnoringASCIICaseCommon(string, lowercaseLetters);
+}
+
+template<unsigned length> inline bool startsWithLettersIgnoringASCIICase(const StringImpl* string, const char (&lowercaseLetters)[length])
+{
+ return string && startsWithLettersIgnoringASCIICase(*string, lowercaseLetters);
+}
+
template<unsigned length> inline bool equalLettersIgnoringASCIICase(const StringImpl& string, const char (&lowercaseLetters)[length])
{
return equalLettersIgnoringASCIICaseCommon(string, lowercaseLetters);
Modified: trunk/Source/WTF/wtf/text/WTFString.h (198018 => 198019)
--- trunk/Source/WTF/wtf/text/WTFString.h 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2016-03-11 15:10:18 UTC (rev 198019)
@@ -503,6 +503,7 @@
bool equalIgnoringASCIICase(const String&, const char*);
template<unsigned length> bool equalLettersIgnoringASCIICase(const String&, const char (&lowercaseLetters)[length]);
+template<unsigned length> bool startsWithLettersIgnoringASCIICase(const String&, const char (&lowercaseLetters)[length]);
inline bool equalIgnoringNullity(const String& a, const String& b) { return equalIgnoringNullity(a.impl(), b.impl()); }
template<size_t inlineCapacity> inline bool equalIgnoringNullity(const Vector<UChar, inlineCapacity>& a, const String& b) { return equalIgnoringNullity(a, b.impl()); }
@@ -726,8 +727,13 @@
return equalIgnoringASCIICase(a.impl(), b);
}
+template<unsigned length> inline bool startsWithLettersIgnoringASCIICase(const String& string, const char (&lowercaseLetters)[length])
+{
+ return startsWithLettersIgnoringASCIICase(string.impl(), lowercaseLetters);
}
+}
+
using WTF::CString;
using WTF::KeepTrailingZeros;
using WTF::String;
Modified: trunk/Source/WebCore/ChangeLog (198018 => 198019)
--- trunk/Source/WebCore/ChangeLog 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Source/WebCore/ChangeLog 2016-03-11 15:10:18 UTC (rev 198019)
@@ -1,5 +1,17 @@
2016-03-11 Youenn Fablet <[email protected]>
+ WTF should have a similar function as equalLettersIgnoringASCIICase to match beginning of strings
+ https://bugs.webkit.org/show_bug.cgi?id=153419
+
+ Reviewed by Darin Adler.
+
+ Covered by added unint tests.
+
+ * Modules/fetch/FetchHeaders.cpp:
+ (WebCore::isForbiddenHeaderName): Using startsWithLettersIgnoringASCIICase.
+
+2016-03-11 Youenn Fablet <[email protected]>
+
[Fetch API] Use DeferredWrapper directly in FetchBody promise handling
https://bugs.webkit.org/show_bug.cgi?id=155291
Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp (198018 => 198019)
--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp 2016-03-11 15:10:18 UTC (rev 198019)
@@ -67,7 +67,7 @@
break;
}
}
- return name.startsWithIgnoringASCIICase(ASCIILiteral("Sec-")) || name.startsWithIgnoringASCIICase(ASCIILiteral("Proxy-"));
+ return startsWithLettersIgnoringASCIICase(name, "sec-") || startsWithLettersIgnoringASCIICase(name, "proxy-");
}
static bool isForbiddenResponseHeaderName(const String& name)
Modified: trunk/Tools/ChangeLog (198018 => 198019)
--- trunk/Tools/ChangeLog 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Tools/ChangeLog 2016-03-11 15:10:18 UTC (rev 198019)
@@ -1,3 +1,14 @@
+2016-03-11 Youenn Fablet <[email protected]>
+
+ WTF should have a similar function as equalLettersIgnoringASCIICase to match beginning of strings
+ https://bugs.webkit.org/show_bug.cgi?id=153419
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/Tests/WTF/StringOperators.cpp:
+ (TestWebKitAPI::TEST): Adding test case for startsWithLettersIgnoringASCIICase.
+
+
2016-03-10 Simon Fraser <[email protected]>
Font antialiasing (smoothing) changes when elements are rendered into compositing layers
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp (198018 => 198019)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp 2016-03-11 14:45:14 UTC (rev 198018)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp 2016-03-11 15:10:18 UTC (rev 198019)
@@ -424,6 +424,21 @@
ASSERT_FALSE(empty->startsWithIgnoringASCIICase(*reference.get()));
}
+TEST(WTF, StartsWithLettersIgnoringASCIICase)
+{
+ String string("Test tEST");
+ ASSERT_TRUE(startsWithLettersIgnoringASCIICase(string, "test t"));
+ ASSERT_TRUE(startsWithLettersIgnoringASCIICase(string, "test te"));
+ ASSERT_TRUE(startsWithLettersIgnoringASCIICase(string, "test test"));
+ ASSERT_FALSE(startsWithLettersIgnoringASCIICase(string, "test tex"));
+
+ ASSERT_TRUE(startsWithLettersIgnoringASCIICase(string, ""));
+ ASSERT_TRUE(startsWithLettersIgnoringASCIICase(String(""), ""));
+
+ ASSERT_FALSE(startsWithLettersIgnoringASCIICase(String(), "t"));
+ ASSERT_FALSE(startsWithLettersIgnoringASCIICase(String(), ""));
+}
+
TEST(WTF, StringImplEndsWithIgnoringASCIICaseBasic)
{
RefPtr<StringImpl> reference = stringFromUTF8("XÉCbA");