Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (209398 => 209399)
--- trunk/Source/_javascript_Core/ChangeLog 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-12-06 17:18:20 UTC (rev 209399)
@@ -1,3 +1,21 @@
+2016-12-04 Darin Adler <da...@apple.com>
+
+ Use ASCIICType more, and improve it a little bit
+ https://bugs.webkit.org/show_bug.cgi?id=165360
+
+ Reviewed by Sam Weinig.
+
+ * inspector/InspectorValues.cpp:
+ (Inspector::readHexDigits): Use isASCIIHexDigit.
+ (Inspector::hextoInt): Deleted.
+ (decodeString): Use toASCIIHexValue.
+
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::parseDigit): Use isASCIIDigit, isASCIIUpper, and isASCIILower.
+
+ * runtime/StringPrototype.cpp:
+ (JSC::substituteBackreferencesSlow): Use isASCIIDigit.
+
2016-12-06 Csaba Osztrogonác <o...@webkit.org>
Add storeFence support for ARMv7
Modified: trunk/Source/_javascript_Core/inspector/InspectorValues.cpp (209398 => 209399)
--- trunk/Source/_javascript_Core/inspector/InspectorValues.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/_javascript_Core/inspector/InspectorValues.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -151,8 +151,7 @@
return false;
for (int i = 0; i < digits; ++i) {
- UChar c = *start++;
- if (!(('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')))
+ if (!isASCIIHexDigit(*start++))
return false;
}
@@ -262,19 +261,6 @@
return INVALID_TOKEN;
}
-inline int hexToInt(UChar c)
-{
- if ('0' <= c && c <= '9')
- return c - '0';
- if ('A' <= c && c <= 'F')
- return c - 'A' + 10;
- if ('a' <= c && c <= 'f')
- return c - 'a' + 10;
-
- ASSERT_NOT_REACHED();
- return 0;
-}
-
bool decodeString(const UChar* start, const UChar* end, StringBuilder& output)
{
while (start < end) {
@@ -308,15 +294,11 @@
c = '\v';
break;
case 'x':
- c = (hexToInt(*start) << 4) +
- hexToInt(*(start + 1));
+ c = toASCIIHexValue(start[0], start[1]);
start += 2;
break;
case 'u':
- c = (hexToInt(*start) << 12) +
- (hexToInt(*(start + 1)) << 8) +
- (hexToInt(*(start + 2)) << 4) +
- hexToInt(*(start + 3));
+ c = toASCIIHexValue(start[0], start[1]) << 8 | toASCIIHexValue(start[2], start[3]);
start += 4;
break;
default:
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (209398 => 209399)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -272,11 +272,11 @@
{
int digit = -1;
- if (c >= '0' && c <= '9')
+ if (isASCIIDigit(c))
digit = c - '0';
- else if (c >= 'A' && c <= 'Z')
+ else if (isASCIIUpper(c))
digit = c - 'A' + 10;
- else if (c >= 'a' && c <= 'z')
+ else if (isASCIILower(c))
digit = c - 'a' + 10;
if (digit >= radix)
Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (209398 => 209399)
--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -220,7 +220,7 @@
} else if (ref == '\'') {
backrefStart = ovector[1];
backrefLength = source.length() - backrefStart;
- } else if (reg && ref >= '0' && ref <= '9') {
+ } else if (reg && isASCIIDigit(ref)) {
// 1- and 2-digit back references are allowed
unsigned backrefIndex = ref - '0';
if (backrefIndex > reg->numSubpatterns())
@@ -227,7 +227,7 @@
continue;
if (replacement.length() > i + 2) {
ref = replacement[i + 2];
- if (ref >= '0' && ref <= '9') {
+ if (isASCIIDigit(ref)) {
backrefIndex = 10 * backrefIndex + ref - '0';
if (backrefIndex > reg->numSubpatterns())
backrefIndex = backrefIndex / 10; // Fall back to the 1-digit reference
Modified: trunk/Source/WTF/ChangeLog (209398 => 209399)
--- trunk/Source/WTF/ChangeLog 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/ChangeLog 2016-12-06 17:18:20 UTC (rev 209399)
@@ -1,3 +1,49 @@
+2016-12-04 Darin Adler <da...@apple.com>
+
+ Use ASCIICType more, and improve it a little bit
+ https://bugs.webkit.org/show_bug.cgi?id=165360
+
+ Reviewed by Sam Weinig.
+
+ * wtf/ASCIICType.h: Added declarations of all the functions to the top of the file,
+ so we have a list of what's available, not just a mix of that and the implementation.
+
+ * wtf/HexNumber.h:
+ (WTF::Internal::hexDigitsForMode): Moved lowerHexDigits and upperHexDigits
+ inside this function.
+ (WTF::appendByteAsHex): Use auto.
+ (WTF::placeByteAsHexCompressIfPossible): Ditto.
+ (WTF::placeByteAsHex): Ditto.
+ (WTF::appendUnsignedAsHex): Ditto.
+ (WTF::appendUnsigned64AsHex): Ditto.
+ (WTF::appendUnsignedAsHexFixedSize): Ditto.
+ (WTF::isHexDigit): Deleted.
+ (WTF::uncheckedHexDigit): Deleted.
+ (WTF::hexDigitValue): Deleted.
+ (WTF::uncheckedHexDigitValue): Deleted.
+
+ * wtf/SixCharacterHash.cpp:
+ (WTF::sixCharacterHashStringToInteger): Use isASCIIUpper, isASCIILower, and
+ isASCIIDigit. Also added some FIXMEs; for some reason this function uses
+ RELEASE_ASSERT to abort if the passed-in string is not six characters long,
+ and it's not clear to me why this is so critical to assert.
+ (WTF::integerToSixCharacterHashString): Moved the table inside this function,
+ obviating the need for a macro named TABLE.
+
+ * wtf/dtoa/bignum.cc:
+ (WTF::double_conversion::HexCharValue): Deleted.
+ (WTF::double_conversion::Bignum::AssignHexString): Use toASCIIHexValue.
+ * wtf/dtoa/double-conversion.cc:
+ (WTF::double_conversion::StringToDoubleConverter::StringToDouble): Use isASCIIDigit.
+
+ * wtf/text/StringBuilder.cpp:
+ (WTF::appendQuotedJSONStringInternal): Use upperNibbleToASCIIHexDigit and
+ lowerNibbleToASCIIHexDigit.
+
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::convertToUppercaseWithoutLocale): Use toASCIIUpper.
+ Removed the workaround for a bug that was fixed in Visual Studio 2013.
+
2016-12-05 Joseph Pecoraro <pecor...@apple.com>
REGRESSION(r208985): SafariForWebKitDevelopment Symbol Not Found looking for method with WTF::Optional
Modified: trunk/Source/WTF/wtf/ASCIICType.h (209398 => 209399)
--- trunk/Source/WTF/wtf/ASCIICType.h 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/wtf/ASCIICType.h 2016-12-06 17:18:20 UTC (rev 209399)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2009, 2011, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -44,6 +44,37 @@
namespace WTF {
+template<typename CharacterType> bool isASCII(CharacterType);
+template<typename CharacterType> bool isASCIIAlpha(CharacterType);
+template<typename CharacterType> bool isASCIIAlphanumeric(CharacterType);
+template<typename CharacterType> bool isASCIIBinaryDigit(CharacterType);
+template<typename CharacterType> bool isASCIIDigit(CharacterType);
+template<typename CharacterType> bool isASCIIHexDigit(CharacterType);
+template<typename CharacterType> bool isASCIILower(CharacterType);
+template<typename CharacterType> bool isASCIIOctalDigit(CharacterType);
+template<typename CharacterType> bool isASCIIPrintable(CharacterType);
+template<typename CharacterType> bool isASCIISpace(CharacterType);
+template<typename CharacterType> bool isASCIIUpper(CharacterType);
+
+template<typename CharacterType> CharacterType toASCIILower(CharacterType);
+template<typename CharacterType> CharacterType toASCIIUpper(CharacterType);
+
+template<typename CharacterType> uint8_t toASCIIHexValue(CharacterType);
+template<typename CharacterType> uint8_t toASCIIHexValue(CharacterType firstCharacter, CharacterType secondCharacter);
+
+char lowerNibbleToASCIIHexDigit(uint8_t);
+char upperNibbleToASCIIHexDigit(uint8_t);
+char lowerNibbleToLowercaseASCIIHexDigit(uint8_t);
+char upperNibbleToLowercaseASCIIHexDigit(uint8_t);
+
+template<typename CharacterType> bool isASCIIAlphaCaselessEqual(CharacterType, char expectedASCIILowercaseLetter);
+
+// The toASCIILowerUnchecked function can be used for comparing any input character
+// to a lowercase English character. The isASCIIAlphaCaselessEqual function should
+// be used for regular comparison of ASCII alpha characters, but switch statements
+// in the CSS tokenizer, for example, instead make direct use toASCIILowerUnchecked.
+template<typename CharacterType> CharacterType toASCIILowerUnchecked(CharacterType);
+
const unsigned char asciiCaseFoldTable[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Modified: trunk/Source/WTF/wtf/HexNumber.h (209398 => 209399)
--- trunk/Source/WTF/wtf/HexNumber.h 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/wtf/HexNumber.h 2016-12-06 17:18:20 UTC (rev 209399)
@@ -24,26 +24,23 @@
namespace WTF {
-enum HexConversionMode {
- Lowercase,
- Uppercase
-};
+enum HexConversionMode { Lowercase, Uppercase };
namespace Internal {
-const LChar lowerHexDigits[17] = "0123456789abcdef";
-const LChar upperHexDigits[17] = "0123456789ABCDEF";
inline const LChar* hexDigitsForMode(HexConversionMode mode)
{
- return mode == Lowercase ? lowerHexDigits : upperHexDigits;
+ static const LChar lowercaseHexDigits[17] = "0123456789abcdef";
+ static const LChar uppercaseHexDigits[17] = "0123456789ABCDEF";
+ return mode == Lowercase ? lowercaseHexDigits : uppercaseHexDigits;
}
-}; // namespace Internal
+} // namespace Internal
template<typename T>
inline void appendByteAsHex(unsigned char byte, T& destination, HexConversionMode mode = Uppercase)
{
- const LChar* hexDigits = Internal::hexDigitsForMode(mode);
+ auto* hexDigits = Internal::hexDigitsForMode(mode);
destination.append(hexDigits[byte >> 4]);
destination.append(hexDigits[byte & 0xF]);
}
@@ -51,7 +48,7 @@
template<typename T>
inline void placeByteAsHexCompressIfPossible(unsigned char byte, T& destination, unsigned& index, HexConversionMode mode = Uppercase)
{
- const LChar* hexDigits = Internal::hexDigitsForMode(mode);
+ auto* hexDigits = Internal::hexDigitsForMode(mode);
if (byte >= 0x10)
destination[index++] = hexDigits[byte >> 4];
destination[index++] = hexDigits[byte & 0xF];
@@ -60,7 +57,7 @@
template<typename T>
inline void placeByteAsHex(unsigned char byte, T& destination, HexConversionMode mode = Uppercase)
{
- const LChar* hexDigits = Internal::hexDigitsForMode(mode);
+ auto* hexDigits = Internal::hexDigitsForMode(mode);
*destination++ = hexDigits[byte >> 4];
*destination++ = hexDigits[byte & 0xF];
}
@@ -68,7 +65,7 @@
template<typename T>
inline void appendUnsignedAsHex(unsigned number, T& destination, HexConversionMode mode = Uppercase)
{
- const LChar* hexDigits = Internal::hexDigitsForMode(mode);
+ auto* hexDigits = Internal::hexDigitsForMode(mode);
Vector<LChar, 8> result;
do {
result.append(hexDigits[number % 16]);
@@ -82,7 +79,7 @@
template<typename T>
inline void appendUnsigned64AsHex(uint64_t number, T& destination, HexConversionMode mode = Uppercase)
{
- const LChar* hexDigits = Internal::hexDigitsForMode(mode);
+ auto* hexDigits = Internal::hexDigitsForMode(mode);
Vector<LChar, 8> result;
do {
result.append(hexDigits[number % 16]);
@@ -99,7 +96,7 @@
{
ASSERT(desiredDigits);
- const LChar* hexDigits = Internal::hexDigitsForMode(mode);
+ auto* hexDigits = Internal::hexDigitsForMode(mode);
Vector<LChar, 8> result;
do {
result.append(hexDigits[number % 16]);
@@ -111,54 +108,6 @@
destination.append(result.data(), result.size());
}
-
-inline bool isHexDigit(char c)
-{
- return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
-}
-
-inline char uncheckedHexDigit(int i)
-{
- if (i < 0 || i > 16)
- return '0';
-
- return (i >= 10) ? i - 10 + 'A' : i + '0';
-}
-
-inline bool hexDigitValue(char c, char& result)
-{
- if (c >= '0' && c <= '9') {
- result = c - '0';
- return true;
- }
-
- if (c >= 'A' && c <= 'F') {
- result = c - 'A' + 10;
- return true;
- }
-
- if (c >= 'a' && c <= 'f') {
- result = c - 'a' + 10;
- return true;
- }
-
- return false;
-}
-
-inline int uncheckedHexDigitValue(char c)
-{
- if (c >= '0' && c <= '9')
- return c - '0';
-
- if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
-
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
-
- return 0;
-}
-
} // namespace WTF
using WTF::appendByteAsHex;
@@ -167,7 +116,3 @@
using WTF::placeByteAsHex;
using WTF::placeByteAsHexCompressIfPossible;
using WTF::Lowercase;
-using WTF::isHexDigit;
-using WTF::uncheckedHexDigit;
-using WTF::hexDigitValue;
-using WTF::uncheckedHexDigitValue;
Modified: trunk/Source/WTF/wtf/SixCharacterHash.cpp (209398 => 209399)
--- trunk/Source/WTF/wtf/SixCharacterHash.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/wtf/SixCharacterHash.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -26,46 +26,42 @@
#include "config.h"
#include "SixCharacterHash.h"
-#include <wtf/StdLibExtras.h>
+#include <wtf/ASCIICType.h>
-#include <string.h>
-
namespace WTF {
-#define TABLE ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
-
unsigned sixCharacterHashStringToInteger(const char* string)
{
unsigned hash = 0;
- RELEASE_ASSERT(strlen(string) == 6);
-
for (unsigned i = 0; i < 6; ++i) {
hash *= 62;
unsigned c = string[i];
- if (c >= 'A' && c <= 'Z') {
+ RELEASE_ASSERT(c); // FIXME: Why does this need to be a RELEASE_ASSERT?
+ if (isASCIIUpper(c)) {
hash += c - 'A';
continue;
}
- if (c >= 'a' && c <= 'z') {
+ if (isASCIILower(c)) {
hash += c - 'a' + 26;
continue;
}
- ASSERT(c >= '0' && c <= '9');
+ ASSERT(isASCIIDigit(c));
hash += c - '0' + 26 * 2;
}
-
+
+ RELEASE_ASSERT(string[6]); // FIXME: Why does this need to be a RELEASE_ASSERT?
+
return hash;
}
std::array<char, 7> integerToSixCharacterHashString(unsigned hash)
{
- static_assert(WTF_ARRAY_LENGTH(TABLE) - 1 == 62, "Six character hash table is not 62 characters long.");
-
+ static const char table[63] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
std::array<char, 7> buffer;
unsigned accumulator = hash;
for (unsigned i = 6; i--;) {
- buffer[i] = TABLE[accumulator % 62];
+ buffer[i] = table[accumulator % 62];
accumulator /= 62;
}
buffer[6] = 0;
Modified: trunk/Source/WTF/wtf/dtoa/bignum.cc (209398 => 209399)
--- trunk/Source/WTF/wtf/dtoa/bignum.cc 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/wtf/dtoa/bignum.cc 2016-12-06 17:18:20 UTC (rev 209399)
@@ -29,6 +29,7 @@
#include "bignum.h"
#include "utils.h"
+#include <wtf/ASCIICType.h>
namespace WTF {
@@ -123,15 +124,6 @@
}
- static int HexCharValue(char c) {
- if ('0' <= c && c <= '9') return c - '0';
- if ('a' <= c && c <= 'f') return 10 + c - 'a';
- if ('A' <= c && c <= 'F') return 10 + c - 'A';
- UNREACHABLE();
- return 0; // To make compiler happy.
- }
-
-
void Bignum::AssignHexString(BufferReference<const char> value) {
Zero();
int length = value.length();
@@ -143,7 +135,7 @@
// These bigits are guaranteed to be "full".
Chunk current_bigit = 0;
for (int j = 0; j < kBigitSize / 4; j++) {
- current_bigit += HexCharValue(value[string_index--]) << (j * 4);
+ current_bigit += toASCIIHexValue(value[string_index--]) << (j * 4);
}
bigits_[i] = current_bigit;
}
@@ -152,7 +144,7 @@
Chunk most_significant_bigit = 0; // Could be = 0;
for (int j = 0; j <= string_index; ++j) {
most_significant_bigit <<= 4;
- most_significant_bigit += HexCharValue(value[j]);
+ most_significant_bigit += toASCIIHexValue(value[j]);
}
if (most_significant_bigit != 0) {
bigits_[used_digits_] = most_significant_bigit;
Modified: trunk/Source/WTF/wtf/dtoa/double-conversion.cc (209398 => 209399)
--- trunk/Source/WTF/wtf/dtoa/double-conversion.cc 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/wtf/dtoa/double-conversion.cc 2016-12-06 17:18:20 UTC (rev 209399)
@@ -26,10 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "config.h"
-
-#include <limits.h>
-#include <math.h>
-
#include "double-conversion.h"
#include "bignum-dtoa.h"
@@ -38,6 +34,9 @@
#include "fixed-dtoa.h"
#include "strtod.h"
#include "utils.h"
+#include <limits.h>
+#include <math.h>
+#include <wtf/ASCIICType.h>
namespace WTF {
@@ -483,7 +482,7 @@
}
// Copy significant digits of the integer part (if any) to the buffer.
- while (*current >= '0' && *current <= '9') {
+ while (isASCIIDigit(*current)) {
if (significant_digits < kMaxSignificantDigits) {
ASSERT(buffer_pos < kBufferSize);
buffer[buffer_pos++] = static_cast<char>(*current);
@@ -520,7 +519,7 @@
}
// There is a fractional part.
- while (*current >= '0' && *current <= '9') {
+ while (isASCIIDigit(*current)) {
if (significant_digits < kMaxSignificantDigits) {
ASSERT(buffer_pos < kBufferSize);
buffer[buffer_pos++] = static_cast<char>(*current);
@@ -580,7 +579,7 @@
num = num * 10 + digit;
}
++current;
- } while (current != end && *current >= '0' && *current <= '9');
+ } while (current != end && isASCIIDigit(*current));
exponent += (sign == '-' ? -num : num);
}
Modified: trunk/Source/WTF/wtf/text/StringBuilder.cpp (209398 => 209399)
--- trunk/Source/WTF/wtf/text/StringBuilder.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/wtf/text/StringBuilder.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -418,13 +418,12 @@
break;
default:
ASSERT((*input & 0xFF00) == 0);
- static const char hexDigits[] = "0123456789abcdef";
*output++ = '\\';
*output++ = 'u';
*output++ = '0';
*output++ = '0';
- *output++ = static_cast<LChar>(hexDigits[(*input >> 4) & 0xF]);
- *output++ = static_cast<LChar>(hexDigits[*input & 0xF]);
+ *output++ = upperNibbleToLowercaseASCIIHexDigit(*input);
+ *output++ = lowerNibbleToLowercaseASCIIHexDigit(*input);
break;
}
}
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (209398 => 209399)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -451,14 +451,7 @@
for (int i = 0; i < length; ++i) {
LChar c = m_data8[i];
ored |= c;
-#if CPU(X86) && defined(_MSC_VER) && _MSC_VER >=1700
- // Workaround for an MSVC 2012 x86 optimizer bug. Remove once the bug is fixed.
- // See https://connect.microsoft.com/VisualStudio/feedback/details/780362/optimization-bug-of-range-comparison
- // for more details.
- data8[i] = c >= 'a' && c <= 'z' ? c & ~0x20 : c;
-#else
data8[i] = toASCIIUpper(c);
-#endif
}
if (!(ored & ~0x7F))
return newImpl;
Modified: trunk/Source/WebCore/ChangeLog (209398 => 209399)
--- trunk/Source/WebCore/ChangeLog 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/ChangeLog 2016-12-06 17:18:20 UTC (rev 209399)
@@ -1,3 +1,60 @@
+2016-12-04 Darin Adler <da...@apple.com>
+
+ Use ASCIICType more, and improve it a little bit
+ https://bugs.webkit.org/show_bug.cgi?id=165360
+
+ Reviewed by Sam Weinig.
+
+ * css/CSSGrammar.y.in: Use isASCIIDigit.
+
+ * css/parser/CSSParser.cpp:
+ (WebCore::CSSParser::parseFontFaceUnicodeRange): Use isASCIIHexDigit and
+ toASCIIHexValue.
+ (WebCore::isEqualToCSSIdentifier): Use isASCIILower.
+ * html/FormController.cpp:
+ (WebCore::isNotFormControlTypeCharacter): Use isASCIILower.
+ * html/parser/CSSPreloadScanner.cpp:
+ (WebCore::CSSPreloadScanner::tokenize): Use isASCIIAlpha.
+ * platform/Decimal.cpp:
+ (WebCore::Decimal::fromString): Use isASCIIDigit.
+ * platform/FileSystem.cpp:
+ (WebCore::decodeFromFilename): Use isASCIIHexDigit and toASCIIHexValue.
+ * platform/URL.cpp:
+ (WebCore::isLetterMatchIgnoringCase): Deleted.
+ (WebCore::isSchemeCharacterMatchIgnoringCase): Deleted.
+ (WebCore::assertProtocolIsGood): Use isASCIIUpper.
+ (WebCore::URL::protocolIs): Use isASCIIAlphaCaselessEqual.
+ (WebCore::URL::parse): Ditto.
+ (WebCore::protocolIs): Ditto.
+ (WebCore::protocolIsInHTTPFamily): Ditto.
+ * platform/URLParser.cpp:
+ (WeCore::URLParser::parseIPv4Piece): Use isASCIIDigit.
+
+ * platform/mac/WebCoreNSURLExtras.mm:
+ (WebCore::isRussianDomainNameCharacter): Use isASCIIDigit.
+ (WebCore::allCharactersAllowedByTLDRules): Ditto.
+ (WebCore::dataWithUserTypedString): Use upperNibbleToASCIIHexDigit and
+ lowerNibbleToASCIIHexDigit.
+ (WebCore::dataForURLComponentType): Ditto.
+ (WebCore::createStringWithEscapedUnsafeCharacters): Ditto.
+ (WebCore::userVisibleString): Use isASCIIHexDigit, toASCIIHexValue,
+ upperNibbleToASCIIHexDigit, and lowerNibbleToASCIIHexDigit.
+ (WebCore::isUserVisibleURL): Use isASCIIHexDigit and toASCIIHexValue.
+
+ * platform/network/FormDataBuilder.cpp:
+ (WebCore::FormDataBuilder::encodeStringAsFormData): Use isASCIIAlphanumeric.
+
+ * rendering/mathml/RenderMathMLToken.cpp:
+ (WebCore::mathVariant): Use isASCIIUpper, isASCIILower, and isASCIIDigit.
+
+ * svg/SVGParserUtilities.cpp:
+ (WebCore::genericParseNumber): Use isASCIIDigit.
+ * svg/SVGPathStringSource.cpp:
+ (WebCore::nextCommandHelper): Ditto.
+ * xml/XPathParser.cpp:
+ (WebCore::XPath::Parser::lexNumber): Ditto.
+ (WebCore::XPath::Parser::nextTokenInternal): Ditto.
+
2016-12-06 Ryan Haddad <ryanhad...@apple.com>
Rebaseline bindings tests after r209390.
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp (209398 => 209399)
--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -487,7 +487,7 @@
if (statusCodeString.length() != 3) // Status code must consist of three digits.
return lineLength;
for (int i = 0; i < 3; ++i)
- if (statusCodeString[i] < '0' || statusCodeString[i] > '9') {
+ if (!isASCIIDigit(statusCodeString[i])) {
m_failureReason = makeString("Invalid status code: ", statusCodeString);
return lineLength;
}
Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (209398 => 209399)
--- trunk/Source/WebCore/css/CSSGrammar.y.in 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in 2016-12-06 17:18:20 UTC (rev 209399)
@@ -1217,7 +1217,7 @@
$$->setValue($1, parser->m_context.mode == HTMLQuirksMode);
}
| HEX {
- if ($1[0] >= '0' && $1[0] <= '9')
+ if (isASCIIDigit($1[0]))
$$ = nullptr;
else {
$$ = new CSSParserSelector;
Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (209398 => 209399)
--- trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -7238,12 +7238,8 @@
if (c == '-' || c == '?')
break;
from *= 16;
- if (c >= '0' && c <= '9')
- from += c - '0';
- else if (c >= 'A' && c <= 'F')
- from += 10 + c - 'A';
- else if (c >= 'a' && c <= 'f')
- from += 10 + c - 'a';
+ if (isASCIIHexDigit(c))
+ from += toASCIIHexValue(c);
else {
failed = true;
break;
@@ -7274,12 +7270,8 @@
while (i < length) {
UChar c = rangeString[i];
to *= 16;
- if (c >= '0' && c <= '9')
- to += c - '0';
- else if (c >= 'A' && c <= 'F')
- to += 10 + c - 'A';
- else if (c >= 'a' && c <= 'f')
- to += 10 + c - 'a';
+ if (isASCIIHexDigit(c))
+ to += toASCIIHexValue(c);
else {
failed = true;
break;
@@ -11504,11 +11496,11 @@
{
// Compare an character memory data with a zero terminated string.
do {
- // The input must be part of an identifier if constantChar or constString
+ // The input must be part of an identifier if constantString
// contains '-'. Otherwise toASCIILowerUnchecked('\r') would be equal to '-'.
- ASSERT((*constantString >= 'a' && *constantString <= 'z') || *constantString == '-');
+ ASSERT(isASCIILower(*constantString) || *constantString == '-');
ASSERT(*constantString != '-' || isCSSLetter(*cssString));
- if (toASCIILowerUnchecked(*cssString++) != (*constantString++))
+ if (toASCIILowerUnchecked(*cssString++) != *constantString++)
return false;
} while (*constantString);
return true;
Modified: trunk/Source/WebCore/html/FormController.cpp (209398 => 209399)
--- trunk/Source/WebCore/html/FormController.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/html/FormController.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -195,7 +195,7 @@
static bool isNotFormControlTypeCharacter(UChar ch)
{
- return ch != '-' && (ch > 'z' || ch < 'a');
+ return !(ch == '-' || isASCIILower(ch));
}
std::unique_ptr<SavedFormState> SavedFormState::deserialize(const Vector<String>& stateVector, size_t& index)
Modified: trunk/Source/WebCore/html/parser/CSSPreloadScanner.cpp (209398 => 209399)
--- trunk/Source/WebCore/html/parser/CSSPreloadScanner.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/html/parser/CSSPreloadScanner.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -97,7 +97,7 @@
m_state = Comment;
break;
case RuleStart:
- if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
+ if (isASCIIAlpha(c)) {
m_rule.clear();
m_ruleValue.clear();
m_rule.append(c);
Modified: trunk/Source/WebCore/platform/Decimal.cpp (209398 => 209399)
--- trunk/Source/WebCore/platform/Decimal.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/platform/Decimal.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -728,7 +728,7 @@
const int ch = str[index];
switch (state) {
case StateDigit:
- if (ch >= '0' && ch <= '9') {
+ if (isASCIIDigit(ch)) {
if (numberOfDigits < Precision) {
++numberOfDigits;
accumulator *= 10;
@@ -743,7 +743,7 @@
return nan();
case StateDot:
- if (ch >= '0' && ch <= '9') {
+ if (isASCIIDigit(ch)) {
if (numberOfDigits < Precision) {
++numberOfDigits;
++numberOfDigitsAfterDot;
@@ -757,7 +757,7 @@
FALLTHROUGH;
case StateDotDigit:
- if (ch >= '0' && ch <= '9') {
+ if (isASCIIDigit(ch)) {
if (numberOfDigits < Precision) {
++numberOfDigits;
++numberOfDigitsAfterDot;
@@ -783,7 +783,7 @@
break;
}
- if (ch >= '0' && ch <= '9') {
+ if (isASCIIDigit(ch)) {
exponent = ch - '0';
state = StateEDigit;
break;
@@ -792,7 +792,7 @@
return nan();
case StateEDigit:
- if (ch >= '0' && ch <= '9') {
+ if (isASCIIDigit(ch)) {
exponent *= 10;
exponent += ch - '0';
if (exponent > ExponentMax + Precision) {
@@ -807,7 +807,7 @@
return nan();
case StateESign:
- if (ch >= '0' && ch <= '9') {
+ if (isASCIIDigit(ch)) {
exponent = ch - '0';
state = StateEDigit;
break;
Modified: trunk/Source/WebCore/platform/FileSystem.cpp (209398 => 209399)
--- trunk/Source/WebCore/platform/FileSystem.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/platform/FileSystem.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -151,17 +151,12 @@
return { };
if (inputString[i+1] != '+') {
- char value;
- if (!hexDigitValue(inputString[i + 1], value))
+ if (!isASCIIHexDigit(inputString[i + 1]))
return { };
- LChar character = value << 4;
-
- if (!hexDigitValue(inputString[i + 2], value))
+ if (!isASCIIHexDigit(inputString[i + 2]))
return { };
-
- result.append(character | value);
+ result.append(toASCIIHexValue(inputString[i + 1], inputString[i + 2]));
i += 2;
-
continue;
}
@@ -170,23 +165,16 @@
if (i + 5 >= length)
return { };
- char value;
- if (!hexDigitValue(inputString[i + 2], value))
+ if (!isASCIIHexDigit(inputString[i + 2]))
return { };
- UChar character = value << 12;
-
- if (!hexDigitValue(inputString[i + 3], value))
+ if (!isASCIIHexDigit(inputString[i + 3]))
return { };
- character = character | (value << 8);
-
- if (!hexDigitValue(inputString[i + 4], value))
+ if (!isASCIIHexDigit(inputString[i + 4]))
return { };
- character = character | (value << 4);
-
- if (!hexDigitValue(inputString[i + 5], value))
+ if (!isASCIIHexDigit(inputString[i + 5]))
return { };
- result.append(character | value);
+ result.append(toASCIIHexValue(inputString[i + 2], inputString[i + 3]) << 8 | toASCIIHexValue(inputString[i + 4], inputString[i + 5]));
i += 5;
}
Modified: trunk/Source/WebCore/platform/URL.cpp (209398 => 209399)
--- trunk/Source/WebCore/platform/URL.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/platform/URL.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -55,12 +55,6 @@
static const unsigned invalidPortNumber = 0xFFFF;
-static inline bool isLetterMatchIgnoringCase(UChar character, char lowercaseLetter)
-{
- ASSERT(isASCIILower(lowercaseLetter));
- return (character | 0x20) == lowercaseLetter;
-}
-
static const char wsScheme[] = {'w', 's'};
static const char ftpScheme[] = {'f', 't', 'p'};
static const char ftpPort[] = {'2', '1'};
@@ -73,12 +67,6 @@
static const char gopherScheme[] = {'g', 'o', 'p', 'h', 'e', 'r'};
static const char gopherPort[] = {'7', '0'};
-static inline bool isLetterMatchIgnoringCase(char character, char lowercaseLetter)
-{
- ASSERT(isASCIILower(lowercaseLetter));
- return (character | 0x20) == lowercaseLetter;
-}
-
enum URLCharacterClasses {
// alpha
SchemeFirstChar = 1 << 0,
@@ -356,14 +344,6 @@
static inline bool isBadChar(unsigned char c) { return characterClassTable[c] & BadChar; }
static inline bool isTabNewline(UChar c) { return c <= 0xff && (characterClassTable[c] & TabNewline); }
-static inline bool isSchemeCharacterMatchIgnoringCase(char character, char schemeCharacter)
-{
- ASSERT(isSchemeChar(character));
- ASSERT(schemeCharacter & 0x20);
- ASSERT(isASCIILower(schemeCharacter) || (!isASCIIUpper(schemeCharacter) && isSchemeChar(schemeCharacter)));
- return (character | 0x20) == schemeCharacter;
-}
-
String encodeWithURLEscapeSequences(const String& notEncodedString, PercentEncodeCharacterClass whatToEncode);
// Copies the source to the destination, assuming all the source characters are
@@ -782,6 +762,7 @@
}
#if !USE(CF)
+
String URL::fileSystemPath() const
{
if (!isValid() || !isLocalFile())
@@ -789,6 +770,7 @@
return decodeURLEscapeSequences(path());
}
+
#endif
#ifdef NDEBUG
@@ -801,9 +783,14 @@
static void assertProtocolIsGood(StringView protocol)
{
- for (size_t i = 0; i < protocol.length(); ++i) {
- const char c = protocol[i];
- ASSERT(c > ' ' && c < 0x7F && !(c >= 'A' && c <= 'Z'));
+ // FIXME: We probably don't need this function any more.
+ // The isASCIIAlphaCaselessEqual function asserts that passed-in characters
+ // are ones it can handle; the older code did not and relied on these checks.
+ for (auto character : protocol.codeUnits()) {
+ ASSERT(isASCII(character));
+ ASSERT(character > ' ');
+ ASSERT(!isASCIIUpper(character));
+ ASSERT(toASCIILowerUnchecked(character) == character);
}
}
@@ -853,7 +840,7 @@
// Do the comparison without making a new string object.
for (unsigned i = 0; i < m_schemeEnd; ++i) {
- if (!protocol[i] || !isSchemeCharacterMatchIgnoringCase(m_string[i], protocol[i]))
+ if (!protocol[i] || !isASCIIAlphaCaselessEqual(m_string[i], protocol[i]))
return false;
}
return !protocol[m_schemeEnd]; // We should have consumed all characters in the argument.
@@ -871,7 +858,7 @@
// Do the comparison without making a new string object.
for (unsigned i = 0; i < m_schemeEnd; ++i) {
- if (!isSchemeCharacterMatchIgnoringCase(m_string[i], protocol[i]))
+ if (!isASCIIAlphaCaselessEqual(m_string[i], protocol[i]))
return false;
}
return true;
@@ -1399,6 +1386,7 @@
}
#if PLATFORM(IOS)
+
static bool shouldCanonicalizeScheme = true;
void enableURLSchemeCanonicalization(bool enableSchemeCanonicalization)
@@ -1405,6 +1393,7 @@
{
shouldCanonicalizeScheme = enableSchemeCanonicalization;
}
+
#endif
template<size_t length>
@@ -1537,16 +1526,16 @@
bool hasSecondSlash = hierarchical && url[schemeEnd + 2] == '/';
bool isFile = schemeEnd == 4
- && isLetterMatchIgnoringCase(url[0], 'f')
- && isLetterMatchIgnoringCase(url[1], 'i')
- && isLetterMatchIgnoringCase(url[2], 'l')
- && isLetterMatchIgnoringCase(url[3], 'e');
+ && isASCIIAlphaCaselessEqual(url[0], 'f')
+ && isASCIIAlphaCaselessEqual(url[1], 'i')
+ && isASCIIAlphaCaselessEqual(url[2], 'l')
+ && isASCIIAlphaCaselessEqual(url[3], 'e');
- m_protocolIsInHTTPFamily = isLetterMatchIgnoringCase(url[0], 'h')
- && isLetterMatchIgnoringCase(url[1], 't')
- && isLetterMatchIgnoringCase(url[2], 't')
- && isLetterMatchIgnoringCase(url[3], 'p')
- && (url[4] == ':' || (isLetterMatchIgnoringCase(url[4], 's') && url[5] == ':'));
+ m_protocolIsInHTTPFamily = isASCIIAlphaCaselessEqual(url[0], 'h')
+ && isASCIIAlphaCaselessEqual(url[1], 't')
+ && isASCIIAlphaCaselessEqual(url[2], 't')
+ && isASCIIAlphaCaselessEqual(url[3], 'p')
+ && (url[4] == ':' || (isASCIIAlphaCaselessEqual(url[4], 's') && url[5] == ':'));
if ((hierarchical && hasSecondSlash) || isNonFileHierarchicalScheme(url, schemeEnd)) {
// The part after the scheme is either a net_path or an abs_path whose first path segment is empty.
@@ -1719,15 +1708,15 @@
m_schemeEnd = p - buffer.data();
bool hostIsLocalHost = portEnd - userStart == 9
- && isLetterMatchIgnoringCase(url[userStart], 'l')
- && isLetterMatchIgnoringCase(url[userStart+1], 'o')
- && isLetterMatchIgnoringCase(url[userStart+2], 'c')
- && isLetterMatchIgnoringCase(url[userStart+3], 'a')
- && isLetterMatchIgnoringCase(url[userStart+4], 'l')
- && isLetterMatchIgnoringCase(url[userStart+5], 'h')
- && isLetterMatchIgnoringCase(url[userStart+6], 'o')
- && isLetterMatchIgnoringCase(url[userStart+7], 's')
- && isLetterMatchIgnoringCase(url[userStart+8], 't');
+ && isASCIIAlphaCaselessEqual(url[userStart], 'l')
+ && isASCIIAlphaCaselessEqual(url[userStart+1], 'o')
+ && isASCIIAlphaCaselessEqual(url[userStart+2], 'c')
+ && isASCIIAlphaCaselessEqual(url[userStart+3], 'a')
+ && isASCIIAlphaCaselessEqual(url[userStart+4], 'l')
+ && isASCIIAlphaCaselessEqual(url[userStart+5], 'h')
+ && isASCIIAlphaCaselessEqual(url[userStart+6], 'o')
+ && isASCIIAlphaCaselessEqual(url[userStart+7], 's')
+ && isASCIIAlphaCaselessEqual(url[userStart+8], 't');
// File URLs need a host part unless it is just file:// or file://localhost
bool degenerateFilePath = pathStart == pathEnd && (hostStart == hostEnd || hostIsLocalHost);
@@ -1975,7 +1964,7 @@
for (unsigned i = 0; i < length; ++i) {
if (!protocol[i])
return stringURL[i] == ':';
- if (!isLetterMatchIgnoringCase(stringURL[i], protocol[i]))
+ if (!isASCIIAlphaCaselessEqual(stringURL[i], protocol[i]))
return false;
}
return false;
@@ -2211,7 +2200,7 @@
if (!protocol[j])
return url[i] == ':';
- if (!isLetterMatchIgnoringCase(url[i], protocol[j]))
+ if (!isASCIIAlphaCaselessEqual(url[i], protocol[j]))
return false;
++j;
@@ -2236,10 +2225,12 @@
}
#ifndef NDEBUG
+
void URL::print() const
{
printf("%s\n", m_string.utf8().data());
}
+
#endif
String URL::strippedForUseAsReferrer() const
@@ -2268,11 +2259,11 @@
bool protocolIsInHTTPFamily(const String& url)
{
// Do the comparison without making a new string object.
- return isLetterMatchIgnoringCase(url[0], 'h')
- && isLetterMatchIgnoringCase(url[1], 't')
- && isLetterMatchIgnoringCase(url[2], 't')
- && isLetterMatchIgnoringCase(url[3], 'p')
- && (url[4] == ':' || (isLetterMatchIgnoringCase(url[4], 's') && url[5] == ':'));
+ return isASCIIAlphaCaselessEqual(url[0], 'h')
+ && isASCIIAlphaCaselessEqual(url[1], 't')
+ && isASCIIAlphaCaselessEqual(url[2], 't')
+ && isASCIIAlphaCaselessEqual(url[3], 'p')
+ && (url[4] == ':' || (isASCIIAlphaCaselessEqual(url[4], 's') && url[5] == ':'));
}
const URL& blankURL()
Modified: trunk/Source/WebCore/platform/URLParser.cpp (209398 => 209399)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -2156,7 +2156,7 @@
state = State::Octal;
break;
case State::Decimal:
- if (*iterator < '0' || *iterator > '9')
+ if (!isASCIIDigit(*iterator))
return std::nullopt;
value *= 10;
value += *iterator - '0';
Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm (209398 => 209399)
--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm 2016-12-06 17:18:20 UTC (rev 209399)
@@ -294,7 +294,7 @@
static bool isRussianDomainNameCharacter(UChar ch)
{
// Only modern Russian letters, digits and dashes are allowed.
- return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || (ch >= '0' && ch <= '9') || ch == '-';
+ return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || isASCIIDigit(ch) || ch == '-';
}
static BOOL allCharactersAllowedByTLDRules(const UChar* buffer, int32_t length)
@@ -385,7 +385,7 @@
};
CHECK_RULES_IF_SUFFIX_MATCHES(cyrillicBEL, [](UChar ch) {
// Russian and Byelorussian letters, digits and dashes are allowed.
- return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x0456 || ch == 0x045E || ch == 0x2019 || (ch >= '0' && ch <= '9') || ch == '-';
+ return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x0456 || ch == 0x045E || ch == 0x2019 || isASCIIDigit(ch) || ch == '-';
});
// http://www.nic.kz/docs/poryadok_vnedreniya_kaz_ru.pdf
@@ -397,7 +397,7 @@
};
CHECK_RULES_IF_SUFFIX_MATCHES(cyrillicKAZ, [](UChar ch) {
// Kazakh letters, digits and dashes are allowed.
- return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x04D9 || ch == 0x0493 || ch == 0x049B || ch == 0x04A3 || ch == 0x04E9 || ch == 0x04B1 || ch == 0x04AF || ch == 0x04BB || ch == 0x0456 || (ch >= '0' && ch <= '9') || ch == '-';
+ return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x04D9 || ch == 0x0493 || ch == 0x049B || ch == 0x04A3 || ch == 0x04E9 || ch == 0x04B1 || ch == 0x04AF || ch == 0x04BB || ch == 0x0456 || isASCIIDigit(ch) || ch == '-';
});
// http://uanic.net/docs/documents-ukr/Rules%20of%20UKR_v4.0.pdf
@@ -409,7 +409,7 @@
};
CHECK_RULES_IF_SUFFIX_MATCHES(cyrillicUKR, [](UChar ch) {
// Russian and Ukrainian letters, digits and dashes are allowed.
- return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x0491 || ch == 0x0404 || ch == 0x0456 || ch == 0x0457 || (ch >= '0' && ch <= '9') || ch == '-';
+ return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x0491 || ch == 0x0404 || ch == 0x0456 || ch == 0x0457 || isASCIIDigit(ch) || ch == '-';
});
// http://www.rnids.rs/data/DOKUMENTI/idn-srb-policy-termsofuse-v1.4-eng.pdf
@@ -421,7 +421,7 @@
};
CHECK_RULES_IF_SUFFIX_MATCHES(cyrillicSRB, [](UChar ch) {
// Serbian letters, digits and dashes are allowed.
- return (ch >= 0x0430 && ch <= 0x0438) || (ch >= 0x043A && ch <= 0x0448) || ch == 0x0452 || ch == 0x0458 || ch == 0x0459 || ch == 0x045A || ch == 0x045B || ch == 0x045F || (ch >= '0' && ch <= '9') || ch == '-';
+ return (ch >= 0x0430 && ch <= 0x0438) || (ch >= 0x043A && ch <= 0x0448) || ch == 0x0452 || ch == 0x0458 || ch == 0x0459 || ch == 0x045A || ch == 0x045B || ch == 0x045F || isASCIIDigit(ch) || ch == '-';
});
// http://marnet.mk/doc/pravilnik-mk-mkd.pdf
@@ -433,7 +433,7 @@
};
CHECK_RULES_IF_SUFFIX_MATCHES(cyrillicMKD, [](UChar ch) {
// Macedonian letters, digits and dashes are allowed.
- return (ch >= 0x0430 && ch <= 0x0438) || (ch >= 0x043A && ch <= 0x0448) || ch == 0x0453 || ch == 0x0455 || ch == 0x0458 || ch == 0x0459 || ch == 0x045A || ch == 0x045C || ch == 0x045F || (ch >= '0' && ch <= '9') || ch == '-';
+ return (ch >= 0x0430 && ch <= 0x0438) || (ch >= 0x043A && ch <= 0x0448) || ch == 0x0453 || ch == 0x0455 || ch == 0x0458 || ch == 0x0459 || ch == 0x045A || ch == 0x045C || ch == 0x045F || isASCIIDigit(ch) || ch == '-';
});
// https://www.mon.mn/cs/
@@ -445,7 +445,7 @@
};
CHECK_RULES_IF_SUFFIX_MATCHES(cyrillicMON, [](UChar ch) {
// Mongolian letters, digits and dashes are allowed.
- return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x04E9 || ch == 0x04AF || (ch >= '0' && ch <= '9') || ch == '-';
+ return (ch >= 0x0430 && ch <= 0x044f) || ch == 0x0451 || ch == 0x04E9 || ch == 0x04AF || isASCIIDigit(ch) || ch == '-';
});
// Not a known top level domain with special rules.
@@ -806,8 +806,8 @@
UInt8 c = inBytes[i];
if (c <= 0x20 || c >= 0x7f) {
*p++ = '%';
- *p++ = uncheckedHexDigit(c >> 4);
- *p++ = uncheckedHexDigit(c & 0xf);
+ *p++ = upperNibbleToASCIIHexDigit(c);
+ *p++ = lowerNibbleToASCIIHexDigit(c);
outLength += 3;
} else {
*p++ = c;
@@ -901,8 +901,8 @@
if (c <= 0x20 || c >= 0x7f) {
char escaped[3];
escaped[0] = '%';
- escaped[1] = uncheckedHexDigit(c >> 4);
- escaped[2] = uncheckedHexDigit(c & 0xf);
+ escaped[1] = upperNibbleToASCIIHexDigit(c);
+ escaped[2] = lowerNibbleToASCIIHexDigit(c);
[resultData appendBytes:escaped length:3];
} else {
char b[1];
@@ -1013,8 +1013,8 @@
for (CFIndex j = 0; j < offset; ++j) {
outBuffer.append('%');
- outBuffer.append(uncheckedHexDigit(utf8Buffer[j] >> 4));
- outBuffer.append(uncheckedHexDigit(utf8Buffer[j] & 0xf));
+ outBuffer.append(upperNibbleToASCIIHexDigit(utf8Buffer[j]));
+ outBuffer.append(lowerNibbleToASCIIHexDigit(utf8Buffer[j]));
}
} else {
UChar utf16Buffer[2];
@@ -1045,8 +1045,8 @@
for (int i = 0; i < length; i++) {
unsigned char c = p[i];
// unescape escape sequences that indicate bytes greater than 0x7f
- if (c == '%' && (i + 1 < length && isHexDigit(p[i + 1])) && i + 2 < length && isHexDigit(p[i + 2])) {
- unsigned char u = (uncheckedHexDigitValue(p[i + 1]) << 4) | uncheckedHexDigitValue(p[i + 2]);
+ if (c == '%' && (i + 1 < length && isASCIIHexDigit(p[i + 1])) && i + 2 < length && isASCIIHexDigit(p[i + 2])) {
+ auto u = toASCIIHexValue(p[i + 1], p[i + 2]);
if (u > 0x7f) {
// unescape
*q++ = u;
@@ -1083,8 +1083,8 @@
unsigned char c = *p;
if (c > 0x7f) {
*q++ = '%';
- *q++ = uncheckedHexDigit(c >> 4);
- *q++ = uncheckedHexDigit(c & 0xf);
+ *q++ = upperNibbleToASCIIHexDigit(c);
+ *q++ = lowerNibbleToASCIIHexDigit(c);
} else
*q++ = *p;
p++;
@@ -1126,8 +1126,8 @@
if (c <= 0x20 || c == 0x7f) {
valid = NO;
break;
- } else if (c == '%' && (i + 1 < length && isHexDigit(p[i + 1])) && i + 2 < length && isHexDigit(p[i + 2])) {
- unsigned char u = (uncheckedHexDigitValue(p[i + 1]) << 4) | uncheckedHexDigitValue(p[i + 2]);
+ } else if (c == '%' && (i + 1 < length && isASCIIHexDigit(p[i + 1])) && i + 2 < length && isASCIIHexDigit(p[i + 2])) {
+ auto u = toASCIIHexValue(p[i + 1], p[i + 2]);
if (u > 0x7f) {
valid = NO;
break;
Modified: trunk/Source/WebCore/platform/network/FormDataBuilder.cpp (209398 => 209399)
--- trunk/Source/WebCore/platform/network/FormDataBuilder.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/platform/network/FormDataBuilder.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -187,7 +187,7 @@
for (unsigned i = 0; i < length; ++i) {
unsigned char c = string.data()[i];
- if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || strchr(safeCharacters, c))
+ if (isASCIIAlphanumeric(c) || strchr(safeCharacters, c))
append(buffer, c);
else if (c == ' ')
append(buffer, '+');
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp (209398 => 209399)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -330,15 +330,15 @@
Arabic
};
CharacterType varType;
- if ('A' <= codePoint && codePoint <= 'Z') {
+ if (isASCIIUpper(codePoint)) {
baseChar = codePoint - 'A';
varType = Latin;
- } else if ('a' <= codePoint && codePoint <= 'z') {
+ } else if (isASCIILower(codePoint)) {
// Lowercase characters are placed immediately after the uppercase characters in the Unicode mathematical block.
// The constant subtraction represents the number of characters between the start of the sequence (capital A) and the first lowercase letter.
baseChar = mathBoldSmallA - mathBoldUpperA + codePoint - 'a';
varType = Latin;
- } else if ('0' <= codePoint && codePoint <= '9') {
+ } else if (isASCIIDigit(codePoint)) {
baseChar = codePoint - '0';
varType = Number;
} else if (greekUpperAlpha <= codePoint && codePoint <= greekUpperOmega) {
Modified: trunk/Source/WebCore/svg/SVGParserUtilities.cpp (209398 => 209399)
--- trunk/Source/WebCore/svg/SVGParserUtilities.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/svg/SVGParserUtilities.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -62,13 +62,12 @@
sign = -1;
}
- if (ptr == end || ((*ptr < '0' || *ptr > '9') && *ptr != '.'))
- // The first character of a number must be one of [0-9+-.]
+ if (ptr == end || (!isASCIIDigit(*ptr) && *ptr != '.'))
return false;
// read the integer part, build right-to-left
const CharacterType* ptrStartIntPart = ptr;
- while (ptr < end && *ptr >= '0' && *ptr <= '9')
+ while (ptr < end && isASCIIDigit(*ptr))
++ptr; // Advance to first non-digit.
if (ptr != ptrStartIntPart) {
@@ -87,10 +86,10 @@
ptr++;
// There must be a least one digit following the .
- if (ptr >= end || *ptr < '0' || *ptr > '9')
+ if (ptr >= end || !isASCIIDigit(*ptr))
return false;
- while (ptr < end && *ptr >= '0' && *ptr <= '9')
+ while (ptr < end && isASCIIDigit(*ptr))
decimal += (*(ptr++) - '0') * (frac *= static_cast<FloatType>(0.1));
}
@@ -108,10 +107,10 @@
}
// There must be an exponent
- if (ptr >= end || *ptr < '0' || *ptr > '9')
+ if (ptr >= end || !isASCIIDigit(*ptr))
return false;
- while (ptr < end && *ptr >= '0' && *ptr <= '9') {
+ while (ptr < end && isASCIIDigit(*ptr)) {
exponent *= static_cast<FloatType>(10);
exponent += *ptr - '0';
ptr++;
Modified: trunk/Source/WebCore/svg/SVGPathStringSource.cpp (209398 => 209399)
--- trunk/Source/WebCore/svg/SVGPathStringSource.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/svg/SVGPathStringSource.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -134,7 +134,7 @@
static bool nextCommandHelper(const CharacterType*& current, SVGPathSegType previousCommand, SVGPathSegType& nextCommand)
{
// Check for remaining coordinates in the current command.
- if ((*current == '+' || *current == '-' || *current == '.' || (*current >= '0' && *current <= '9'))
+ if ((*current == '+' || *current == '-' || *current == '.' || isASCIIDigit(*current))
&& previousCommand != PathSegClosePath) {
if (previousCommand == PathSegMoveToAbs) {
nextCommand = PathSegLineToAbs;
Modified: trunk/Source/WebCore/xml/XPathParser.cpp (209398 => 209399)
--- trunk/Source/WebCore/xml/XPathParser.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebCore/xml/XPathParser.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -209,7 +209,7 @@
UChar aChar = m_data[m_nextPos];
if (aChar >= 0xff) break;
- if (aChar < '0' || aChar > '9') {
+ if (!isASCIIDigit(aChar)) {
if (aChar == '.' && !seenDot)
seenDot = true;
else
@@ -283,7 +283,7 @@
char next = peekAheadHelper();
if (next == '.')
return makeTokenAndAdvance(DOTDOT, 2);
- if (next >= '0' && next <= '9')
+ if (isASCIIDigit(next))
return lexNumber();
return makeTokenAndAdvance('.');
}
Modified: trunk/Source/WebKit2/ChangeLog (209398 => 209399)
--- trunk/Source/WebKit2/ChangeLog 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebKit2/ChangeLog 2016-12-06 17:18:20 UTC (rev 209399)
@@ -1,3 +1,13 @@
+2016-12-04 Darin Adler <da...@apple.com>
+
+ Use ASCIICType more, and improve it a little bit
+ https://bugs.webkit.org/show_bug.cgi?id=165360
+
+ Reviewed by Sam Weinig.
+
+ * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+ (WebKit::capitalizeRFC822HeaderFieldName): Removed unneeded checks to simplify code.
+
2016-12-06 Dave Hyatt <hy...@apple.com>
[CSS Parser] Turn on the new CSS parser
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (209398 => 209399)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp 2016-12-06 17:14:03 UTC (rev 209398)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp 2016-12-06 17:18:20 UTC (rev 209399)
@@ -131,25 +131,13 @@
{
bool capitalizeCharacter = true;
StringBuilder result;
-
for (unsigned i = 0; i < name.length(); i++) {
- UChar c;
-
- if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z')
- c = toASCIIUpper(name[i]);
- else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z')
- c = toASCIILower(name[i]);
- else
- c = name[i];
-
+ result.append(capitalizeCharacter ? toASCIIUpper(name[i]) : toASCIILower(name[i]));
if (name[i] == '-')
capitalizeCharacter = true;
else
capitalizeCharacter = false;
-
- result.append(c);
}
-
return result.toString();
}