Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (225143 => 225144)
--- trunk/Source/_javascript_Core/ChangeLog 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-11-25 02:44:45 UTC (rev 225144)
@@ -1,3 +1,13 @@
+2016-08-05 Darin Adler <[email protected]>
+
+ Fix some minor problems in the StringImpl header
+ https://bugs.webkit.org/show_bug.cgi?id=160630
+
+ Reviewed by Brent Fulgham.
+
+ * inspector/ContentSearchUtilities.cpp: Removed a lot of unneeded explicit
+ Yarr namespacing since we use "using namespace" in this file.
+
2017-11-24 Mark Lam <[email protected]>
Fix CLoop::sanitizeStack() bug where it was clearing part of the JS stack in use.
Modified: trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp (225143 => 225144)
--- trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp 2017-11-25 02:44:45 UTC (rev 225144)
@@ -74,7 +74,7 @@
return TextPosition(OrdinalNumber::fromZeroBasedInt(lineIndex), OrdinalNumber::fromZeroBasedInt(column));
}
-static Vector<std::pair<size_t, String>> getRegularExpressionMatchesByLines(const JSC::Yarr::RegularExpression& regex, const String& text)
+static Vector<std::pair<size_t, String>> getRegularExpressionMatchesByLines(const RegularExpression& regex, const String& text)
{
Vector<std::pair<size_t, String>> result;
if (text.isEmpty())
@@ -128,13 +128,12 @@
.release();
}
-JSC::Yarr::RegularExpression createSearchRegex(const String& query, bool caseSensitive, bool isRegex)
+RegularExpression createSearchRegex(const String& query, bool caseSensitive, bool isRegex)
{
- String regexSource = isRegex ? query : createSearchRegexSource(query);
- return JSC::Yarr::RegularExpression(regexSource, caseSensitive ? TextCaseSensitive : TextCaseInsensitive);
+ return RegularExpression { isRegex ? query : createSearchRegexSource(query), caseSensitive ? TextCaseSensitive : TextCaseInsensitive };
}
-int countRegularExpressionMatches(const JSC::Yarr::RegularExpression& regex, const String& content)
+int countRegularExpressionMatches(const RegularExpression& regex, const String& content)
{
if (content.isEmpty())
return 0;
@@ -157,7 +156,7 @@
{
Ref<Inspector::Protocol::Array<Inspector::Protocol::GenericTypes::SearchMatch>> result = Inspector::Protocol::Array<Inspector::Protocol::GenericTypes::SearchMatch>::create();
- JSC::Yarr::RegularExpression regex = ContentSearchUtilities::createSearchRegex(query, caseSensitive, isRegex);
+ RegularExpression regex = ContentSearchUtilities::createSearchRegex(query, caseSensitive, isRegex);
Vector<std::pair<size_t, String>> matches = getRegularExpressionMatchesByLines(regex, text);
for (const auto& match : matches) {
@@ -178,17 +177,17 @@
{
ASSERT(!content.isNull());
const char* error = nullptr;
- JSC::Yarr::YarrPattern pattern(patternString, JSC::RegExpFlags::FlagMultiline, &error);
+ YarrPattern pattern(patternString, JSC::RegExpFlags::FlagMultiline, &error);
ASSERT(!error);
BumpPointerAllocator regexAllocator;
- auto bytecodePattern = JSC::Yarr::byteCompile(pattern, ®exAllocator);
+ auto bytecodePattern = byteCompile(pattern, ®exAllocator);
ASSERT(bytecodePattern);
ASSERT(pattern.m_numSubpatterns == 1);
Vector<int, 4> matches;
matches.grow(4);
- unsigned result = JSC::Yarr::interpret(bytecodePattern.get(), content, 0, reinterpret_cast<unsigned*>(matches.data()));
- if (result == JSC::Yarr::offsetNoMatch)
+ unsigned result = interpret(bytecodePattern.get(), content, 0, reinterpret_cast<unsigned*>(matches.data()));
+ if (result == offsetNoMatch)
return String();
ASSERT(matches[2] > 0 && matches[3] > 0);
Modified: trunk/Source/WTF/ChangeLog (225143 => 225144)
--- trunk/Source/WTF/ChangeLog 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/ChangeLog 2017-11-25 02:44:45 UTC (rev 225144)
@@ -1,3 +1,47 @@
+2016-08-05 Darin Adler <[email protected]>
+
+ Fix some minor problems in the StringImpl header
+ https://bugs.webkit.org/show_bug.cgi?id=160630
+
+ Reviewed by Brent Fulgham.
+
+ * wtf/text/AtomicString.h: Update since CharacterMatchFunctionPtr is now
+ CodeUnitMatchFunction.
+
+ * wtf/text/StringCommon.h: Added CodeUnitMatchFunction, which replaces
+ CharacterMatchFunctionPtr.
+
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::stripMatchedCharacters): Changed template argument name
+ to CodeUnitPredicate to help make it clear this works on code units, not
+ code points.
+ (WTF::UCharPredicate): Deleted.
+ (WTF::SpaceOrNewlinePredicate): Deleted.
+ (WTF::StringImpl::stripWhiteSpace): Removed unneeded use of predicate class to
+ turn a function into a functor; functions already work fine as functors without
+ a class wrapping them.
+ (WTF::StringImpl::stripLeadingAndTrailingCharacters): Ditto. Also renamed
+ from stripWhiteSpace, since it strips arbitrary characters.
+ (WTF::StringImpl::removeCharacters): Fixed various minor style issues and
+ updated to new type name.
+ (WTF::StringImpl::simplifyMatchedCharactersToSpace): Ditto.
+ (WTF::StringImpl::simplifyWhiteSpace): More of the same.
+ (WTF::StringImpl::find): Ditto.
+
+ * wtf/text/StringImpl.h: Removed unneeded include of uchar.h, since it's
+ included by StringCommon.h. Removed =CharacterMatchFunctionPtr and
+ IsWhiteSpaceFunctionPtr, both replaced by CodeUnitMatchFunction. Fixed
+ a mistake recently introduced in isSpaceOrNewline, which was unnecessarily,
+ inefficiently using ICU for non-ASCII Latin-1 characters.
+
+ * wtf/text/StringView.h: Use CodeUnitMatchFunction instead of CharacterMatchFunction.
+
+ * wtf/text/WTFString.cpp:
+ (WTF::String::stripLeadingAndTrailingCharacters): Updated function name and type.
+ (WTF::String::simplifyWhiteSpace): Updated type.
+ (WTF::String::removeCharacters): Updated type.
+ * wtf/text/WTFString.h: Ditto.
+
2017-11-23 Darin Adler <[email protected]>
Fix dictionary leak in lookup, convert FindOptions to OptionSet, tweak code style nearby
Modified: trunk/Source/WTF/wtf/text/AtomicString.h (225143 => 225144)
--- trunk/Source/WTF/wtf/text/AtomicString.h 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/wtf/text/AtomicString.h 2017-11-25 02:44:45 UTC (rev 225144)
@@ -121,7 +121,7 @@
size_t find(const String& string, unsigned start = 0) const { return m_string.find(string, start); }
size_t findIgnoringASCIICase(const String& string) const { return m_string.findIgnoringASCIICase(string); }
size_t findIgnoringASCIICase(const String& string, unsigned startOffset) const { return m_string.findIgnoringASCIICase(string, startOffset); }
- size_t find(CharacterMatchFunctionPtr matchFunction, unsigned start = 0) const { return m_string.find(matchFunction, start); }
+ size_t find(CodeUnitMatchFunction matchFunction, unsigned start = 0) const { return m_string.find(matchFunction, start); }
bool startsWith(const String& string) const { return m_string.startsWith(string); }
bool startsWithIgnoringASCIICase(const String& string) const { return m_string.startsWithIgnoringASCIICase(string); }
Modified: trunk/Source/WTF/wtf/text/StringCommon.h (225143 => 225144)
--- trunk/Source/WTF/wtf/text/StringCommon.h 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/wtf/text/StringCommon.h 2017-11-25 02:44:45 UTC (rev 225144)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,6 +33,8 @@
namespace WTF {
+using CodeUnitMatchFunction = bool (*)(UChar);
+
template<typename CharacterTypeA, typename CharacterTypeB> bool equalIgnoringASCIICase(const CharacterTypeA*, const CharacterTypeB*, unsigned length);
template<typename CharacterTypeA, typename CharacterTypeB> bool equalIgnoringASCIICase(const CharacterTypeA*, unsigned lengthA, const CharacterTypeB*, unsigned lengthB);
@@ -655,4 +657,4 @@
using WTF::equalIgnoringASCIICase;
using WTF::equalLettersIgnoringASCIICase;
-#endif // StringCommon_h
+#endif
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (225143 => 225144)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2017-11-25 02:44:45 UTC (rev 225144)
@@ -693,8 +693,7 @@
return convertASCIICase<CaseConvertType::Upper>(*this, m_data16, m_length);
}
-template <class UCharPredicate>
-inline Ref<StringImpl> StringImpl::stripMatchedCharacters(UCharPredicate predicate)
+template<typename CodeUnitPredicate> inline Ref<StringImpl> StringImpl::stripMatchedCharacters(CodeUnitPredicate predicate)
{
if (!m_length)
return *this;
@@ -721,63 +720,40 @@
return create(m_data16 + start, end + 1 - start);
}
-class UCharPredicate {
-public:
- inline UCharPredicate(CharacterMatchFunctionPtr function): m_function(function) { }
-
- inline bool operator()(UChar character) const
- {
- return m_function(character);
- }
-
-private:
- const CharacterMatchFunctionPtr m_function;
-};
-
-class SpaceOrNewlinePredicate {
-public:
- inline bool operator()(UChar character) const
- {
- return isSpaceOrNewline(character);
- }
-};
-
Ref<StringImpl> StringImpl::stripWhiteSpace()
{
- return stripMatchedCharacters(SpaceOrNewlinePredicate());
+ return stripMatchedCharacters(isSpaceOrNewline);
}
-Ref<StringImpl> StringImpl::stripWhiteSpace(IsWhiteSpaceFunctionPtr isWhiteSpace)
+Ref<StringImpl> StringImpl::stripLeadingAndTrailingCharacters(CodeUnitMatchFunction predicate)
{
- return stripMatchedCharacters(UCharPredicate(isWhiteSpace));
+ return stripMatchedCharacters(predicate);
}
-template<typename CharacterType> ALWAYS_INLINE Ref<StringImpl> StringImpl::removeCharacters(const CharacterType* characters, CharacterMatchFunctionPtr findMatch)
+template<typename CharacterType> ALWAYS_INLINE Ref<StringImpl> StringImpl::removeCharacters(const CharacterType* characters, CodeUnitMatchFunction findMatch)
{
auto* from = characters;
- auto* fromend = from + m_length;
-
+ auto* fromEnd = from + m_length;
+
// Assume the common case will not remove any characters
- while (from != fromend && !findMatch(*from))
+ while (from != fromEnd && !findMatch(*from))
++from;
- if (from == fromend)
+ if (from == fromEnd)
return *this;
-
+
StringBuffer<CharacterType> data(m_length);
auto* to = data.characters();
unsigned outc = from - characters;
-
+
if (outc)
copyCharacters(to, characters, outc);
- while (true) {
- while (from != fromend && findMatch(*from))
+ do {
+ while (from != fromEnd && findMatch(*from))
++from;
- while (from != fromend && !findMatch(*from))
+ while (from != fromEnd && !findMatch(*from))
to[outc++] = *from++;
- if (from == fromend)
- break;
- }
+ } while (from != fromEnd);
data.shrink(outc);
@@ -784,7 +760,7 @@
return adopt(WTFMove(data));
}
-Ref<StringImpl> StringImpl::removeCharacters(CharacterMatchFunctionPtr findMatch)
+Ref<StringImpl> StringImpl::removeCharacters(CodeUnitMatchFunction findMatch)
{
if (is8Bit())
return removeCharacters(characters8(), findMatch);
@@ -796,34 +772,34 @@
StringBuffer<CharacterType> data(m_length);
auto* from = characters<CharacterType>();
- auto* fromend = from + m_length;
- int outc = 0;
+ auto* fromEnd = from + m_length;
+ unsigned outc = 0;
bool changedToSpace = false;
auto* to = data.characters();
while (true) {
- while (from != fromend && predicate(*from)) {
+ while (from != fromEnd && predicate(*from)) {
if (*from != ' ')
changedToSpace = true;
++from;
}
- while (from != fromend && !predicate(*from))
+ while (from != fromEnd && !predicate(*from))
to[outc++] = *from++;
- if (from != fromend)
+ if (from != fromEnd)
to[outc++] = ' ';
else
break;
}
-
- if (outc > 0 && to[outc - 1] == ' ')
+
+ if (outc && to[outc - 1] == ' ')
--outc;
-
- if (static_cast<unsigned>(outc) == m_length && !changedToSpace)
+
+ if (outc == m_length && !changedToSpace)
return *this;
-
+
data.shrink(outc);
-
+
return adopt(WTFMove(data));
}
@@ -830,15 +806,15 @@
Ref<StringImpl> StringImpl::simplifyWhiteSpace()
{
if (is8Bit())
- return StringImpl::simplifyMatchedCharactersToSpace<LChar>(SpaceOrNewlinePredicate());
- return StringImpl::simplifyMatchedCharactersToSpace<UChar>(SpaceOrNewlinePredicate());
+ return StringImpl::simplifyMatchedCharactersToSpace<LChar>(isSpaceOrNewline);
+ return StringImpl::simplifyMatchedCharactersToSpace<UChar>(isSpaceOrNewline);
}
-Ref<StringImpl> StringImpl::simplifyWhiteSpace(IsWhiteSpaceFunctionPtr isWhiteSpace)
+Ref<StringImpl> StringImpl::simplifyWhiteSpace(CodeUnitMatchFunction isWhiteSpace)
{
if (is8Bit())
- return StringImpl::simplifyMatchedCharactersToSpace<LChar>(UCharPredicate(isWhiteSpace));
- return StringImpl::simplifyMatchedCharactersToSpace<UChar>(UCharPredicate(isWhiteSpace));
+ return StringImpl::simplifyMatchedCharactersToSpace<LChar>(isWhiteSpace);
+ return StringImpl::simplifyMatchedCharactersToSpace<UChar>(isWhiteSpace);
}
int StringImpl::toIntStrict(bool* ok, int base)
@@ -925,7 +901,7 @@
return charactersToFloat(characters16(), m_length, ok);
}
-size_t StringImpl::find(CharacterMatchFunctionPtr matchFunction, unsigned start)
+size_t StringImpl::find(CodeUnitMatchFunction matchFunction, unsigned start)
{
if (is8Bit())
return WTF::find(characters8(), m_length, matchFunction, start);
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (225143 => 225144)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2017-11-25 02:44:45 UTC (rev 225144)
@@ -24,7 +24,6 @@
#define StringImpl_h
#include <limits.h>
-#include <unicode/uchar.h>
#include <unicode/ustring.h>
#include <wtf/ASCIICType.h>
#include <wtf/CheckedArithmetic.h>
@@ -69,12 +68,9 @@
template<typename> struct BufferFromStaticDataTranslator;
template<typename> struct HashAndCharactersTranslator;
-// Define STRING_STATS to 1 turn on runtime statistics for string sizes and memory usage.
+// Define STRING_STATS to 1 turn on runtime statistics of string sizes and memory usage.
#define STRING_STATS 0
-typedef bool (*CharacterMatchFunctionPtr)(UChar);
-typedef bool (*IsWhiteSpaceFunctionPtr)(UChar);
-
template<bool isSpecialCharacter(UChar), typename CharacterType> bool isAllSpecialCharacters(const CharacterType*, size_t length);
#if STRING_STATS
@@ -368,7 +364,7 @@
template<typename CharacterType> static void copyCharacters(CharacterType* destination, const CharacterType* source, unsigned numCharacters);
static void copyCharacters(UChar* destination, const LChar* source, unsigned numCharacters);
- // Some string features, like refcounting and the atomicity flag, are not
+ // Some string features, like reference counting and the atomicity flag, are not
// thread-safe. We achieve thread safety by isolation, giving each thread
// its own copy of the string.
Ref<StringImpl> isolatedCopy() const;
@@ -408,12 +404,11 @@
Ref<StringImpl> foldCase();
Ref<StringImpl> stripWhiteSpace();
- Ref<StringImpl> stripWhiteSpace(IsWhiteSpaceFunctionPtr);
WTF_EXPORT_STRING_API Ref<StringImpl> simplifyWhiteSpace();
- Ref<StringImpl> simplifyWhiteSpace(IsWhiteSpaceFunctionPtr);
+ Ref<StringImpl> simplifyWhiteSpace(CodeUnitMatchFunction);
- Ref<StringImpl> removeCharacters(CharacterMatchFunctionPtr);
- template<typename CharacterType> Ref<StringImpl> removeCharacters(const CharacterType*, CharacterMatchFunctionPtr);
+ Ref<StringImpl> stripLeadingAndTrailingCharacters(CodeUnitMatchFunction);
+ Ref<StringImpl> removeCharacters(CodeUnitMatchFunction);
bool isAllASCII() const;
bool isAllLatin1() const;
@@ -422,7 +417,7 @@
size_t find(LChar character, unsigned start = 0);
size_t find(char character, unsigned start = 0);
size_t find(UChar character, unsigned start = 0);
- WTF_EXPORT_STRING_API size_t find(CharacterMatchFunctionPtr, unsigned index = 0);
+ WTF_EXPORT_STRING_API size_t find(CodeUnitMatchFunction, unsigned index = 0);
size_t find(const LChar*, unsigned index = 0);
ALWAYS_INLINE size_t find(const char* string, unsigned index = 0) { return find(reinterpret_cast<const LChar*>(string), index); }
WTF_EXPORT_STRING_API size_t find(StringImpl*);
@@ -504,8 +499,9 @@
enum class CaseConvertType { Upper, Lower };
template<CaseConvertType, typename CharacterType> static Ref<StringImpl> convertASCIICase(StringImpl&, const CharacterType*, unsigned);
- template<typename UCharPredicate> Ref<StringImpl> stripMatchedCharacters(UCharPredicate);
- template<typename CharacterType, typename UCharPredicate> Ref<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate);
+ template<class CodeUnitPredicate> Ref<StringImpl> stripMatchedCharacters(CodeUnitPredicate);
+ template<typename CharacterType> ALWAYS_INLINE Ref<StringImpl> removeCharacters(const CharacterType* characters, CodeUnitMatchFunction);
+ template<typename CharacterType, class CodeUnitPredicate> Ref<StringImpl> simplifyMatchedCharactersToSpace(CodeUnitPredicate);
template<typename CharacterType> static Ref<StringImpl> constructInternal(StringImpl&, unsigned);
template<typename CharacterType> static Ref<StringImpl> createUninitializedInternal(unsigned, CharacterType*&);
template<typename CharacterType> static Ref<StringImpl> createUninitializedInternalNonEmpty(unsigned, CharacterType*&);
@@ -563,8 +559,8 @@
template<unsigned length> bool equalLettersIgnoringASCIICase(const StringImpl&, const char (&lowercaseLetters)[length]);
template<unsigned length> bool equalLettersIgnoringASCIICase(const StringImpl*, const char (&lowercaseLetters)[length]);
-size_t find(const LChar*, unsigned length, CharacterMatchFunctionPtr, unsigned index = 0);
-size_t find(const UChar*, unsigned length, CharacterMatchFunctionPtr, unsigned index = 0);
+size_t find(const LChar*, unsigned length, CodeUnitMatchFunction, unsigned index = 0);
+size_t find(const UChar*, unsigned length, CodeUnitMatchFunction, unsigned index = 0);
template<typename CharacterType> size_t reverseFindLineTerminator(const CharacterType*, unsigned length, unsigned index = std::numeric_limits<unsigned>::max());
template<typename CharacterType> size_t reverseFind(const CharacterType*, unsigned length, CharacterType matchCharacter, unsigned index = std::numeric_limits<unsigned>::max());
@@ -616,7 +612,7 @@
return characters16();
}
-inline size_t find(const LChar* characters, unsigned length, CharacterMatchFunctionPtr matchFunction, unsigned index)
+inline size_t find(const LChar* characters, unsigned length, CodeUnitMatchFunction matchFunction, unsigned index)
{
while (index < length) {
if (matchFunction(characters[index]))
@@ -626,7 +622,7 @@
return notFound;
}
-inline size_t find(const UChar* characters, unsigned length, CharacterMatchFunctionPtr matchFunction, unsigned index)
+inline size_t find(const UChar* characters, unsigned length, CodeUnitMatchFunction matchFunction, unsigned index)
{
while (index < length) {
if (matchFunction(characters[index]))
@@ -700,8 +696,7 @@
return equalIgnoringNullity(a.data(), a.size(), b);
}
-template<typename CharacterType1, typename CharacterType2>
-inline int codePointCompare(const CharacterType1* characters1, unsigned length1, const CharacterType2* characters2, unsigned length2)
+template<typename CharacterType1, typename CharacterType2> inline int codePointCompare(const CharacterType1* characters1, unsigned length1, const CharacterType2* characters2, unsigned length2)
{
unsigned commonLength = std::min(length1, length2);
@@ -742,9 +737,8 @@
inline bool isSpaceOrNewline(UChar character)
{
- // Use isASCIISpace() for basic Latin-1.
- // This will include newlines, which aren't included in Unicode DirWS.
- return isASCII(character) ? isASCIISpace(character) : u_charDirection(character) == U_WHITE_SPACE_NEUTRAL;
+ // Use isASCIISpace() for all Latin-1 characters. This will include newlines, which aren't included in Unicode DirWS.
+ return character <= 0xFF ? isASCIISpace(character) : u_charDirection(character) == U_WHITE_SPACE_NEUTRAL;
}
template<typename CharacterType> inline unsigned lengthOfNullTerminatedString(const CharacterType* string)
Modified: trunk/Source/WTF/wtf/text/StringView.h (225143 => 225144)
--- trunk/Source/WTF/wtf/text/StringView.h 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/wtf/text/StringView.h 2017-11-25 02:44:45 UTC (rev 225144)
@@ -45,8 +45,6 @@
namespace WTF {
-using CharacterMatchFunction = bool (*)(UChar);
-
// StringView is a non-owning reference to a string, similar to the proposed std::string_view.
class StringView {
@@ -126,7 +124,7 @@
SplitResult split(UChar) const;
size_t find(UChar, unsigned start = 0) const;
- size_t find(CharacterMatchFunction, unsigned start = 0) const;
+ size_t find(CodeUnitMatchFunction, unsigned start = 0) const;
WTF_EXPORT_STRING_API size_t find(StringView, unsigned start) const;
@@ -539,7 +537,7 @@
return WTF::find(characters16(), m_length, character, start);
}
-inline size_t StringView::find(CharacterMatchFunction matchFunction, unsigned start) const
+inline size_t StringView::find(CodeUnitMatchFunction matchFunction, unsigned start) const
{
if (is8Bit())
return WTF::find(characters8(), m_length, matchFunction, start);
@@ -980,4 +978,4 @@
using WTF::equal;
using WTF::StringView;
-#endif // StringView_h
+#endif
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (225143 => 225144)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2017-11-25 02:44:45 UTC (rev 225144)
@@ -378,12 +378,10 @@
return m_impl ? m_impl->stripWhiteSpace() : String { };
}
-String String::stripWhiteSpace(IsWhiteSpaceFunctionPtr isWhiteSpace) const
+String String::stripLeadingAndTrailingCharacters(CodeUnitMatchFunction predicate) const
{
// FIXME: Should this function, and the many others like it, be inlined?
- // FIXME: This function needs a new name. It strips leading and trailing
- // characters that match a predicate; not necessarily "white space".
- return m_impl ? m_impl->stripWhiteSpace(isWhiteSpace) : String { };
+ return m_impl ? m_impl->stripLeadingAndTrailingCharacters(predicate) : String { };
}
String String::simplifyWhiteSpace() const
@@ -396,13 +394,13 @@
return m_impl ? m_impl->simplifyWhiteSpace() : String { };
}
-String String::simplifyWhiteSpace(IsWhiteSpaceFunctionPtr isWhiteSpace) const
+String String::simplifyWhiteSpace(CodeUnitMatchFunction isWhiteSpace) const
{
// FIXME: Should this function, and the many others like it, be inlined?
return m_impl ? m_impl->simplifyWhiteSpace(isWhiteSpace) : String { };
}
-String String::removeCharacters(CharacterMatchFunctionPtr findMatch) const
+String String::removeCharacters(CodeUnitMatchFunction findMatch) const
{
// FIXME: Should this function, and the many others like it, be inlined?
return m_impl ? m_impl->removeCharacters(findMatch) : String { };
Modified: trunk/Source/WTF/wtf/text/WTFString.h (225143 => 225144)
--- trunk/Source/WTF/wtf/text/WTFString.h 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2017-11-25 02:44:45 UTC (rev 225144)
@@ -189,7 +189,7 @@
size_t findIgnoringASCIICase(const String& string) const { return m_impl ? m_impl->findIgnoringASCIICase(string.impl()) : notFound; }
size_t findIgnoringASCIICase(const String& string, unsigned startOffset) const { return m_impl ? m_impl->findIgnoringASCIICase(string.impl(), startOffset) : notFound; }
- size_t find(CharacterMatchFunctionPtr matchFunction, unsigned start = 0) const { return m_impl ? m_impl->find(matchFunction, start) : notFound; }
+ size_t find(CodeUnitMatchFunction matchFunction, unsigned start = 0) const { return m_impl ? m_impl->find(matchFunction, start) : notFound; }
size_t find(const LChar* string, unsigned start = 0) const { return m_impl ? m_impl->find(string, start) : notFound; }
// Find the last instance of a single character or string.
@@ -250,11 +250,11 @@
WTF_EXPORT_STRING_API String convertToUppercaseWithLocale(const AtomicString& localeIdentifier) const;
WTF_EXPORT_STRING_API String stripWhiteSpace() const;
- WTF_EXPORT_STRING_API String stripWhiteSpace(IsWhiteSpaceFunctionPtr) const;
WTF_EXPORT_STRING_API String simplifyWhiteSpace() const;
- WTF_EXPORT_STRING_API String simplifyWhiteSpace(IsWhiteSpaceFunctionPtr) const;
+ WTF_EXPORT_STRING_API String simplifyWhiteSpace(CodeUnitMatchFunction) const;
- WTF_EXPORT_STRING_API String removeCharacters(CharacterMatchFunctionPtr) const;
+ WTF_EXPORT_STRING_API String stripLeadingAndTrailingCharacters(CodeUnitMatchFunction) const;
+ WTF_EXPORT_STRING_API String removeCharacters(CodeUnitMatchFunction) const;
// Returns the string with case folded for case insensitive comparison.
// Use convertToASCIILowercase instead if ASCII case insensitive comparison is desired.
Modified: trunk/Source/WebCore/ChangeLog (225143 => 225144)
--- trunk/Source/WebCore/ChangeLog 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WebCore/ChangeLog 2017-11-25 02:44:45 UTC (rev 225144)
@@ -1,3 +1,23 @@
+2016-08-05 Darin Adler <[email protected]>
+
+ Fix some minor problems in the StringImpl header
+ https://bugs.webkit.org/show_bug.cgi?id=160630
+
+ Reviewed by Brent Fulgham.
+
+ * html/HTMLOptionElement.cpp:
+ (WebCore::HTMLOptionElement::text): Use stripLeadingAndTrailingHTMLSpaces
+ instead of stripWhiteSpace(isHTMLSpace).
+ (WebCore::HTMLOptionElement::value): Ditto.
+ (WebCore::HTMLOptionElement::label): Ditto.
+ (WebCore::HTMLOptionElement::displayLabel): Ditto.
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::didBeginDocument): Use stripLeadingAndTrailingHTMLSpaces
+ instead of calling the general purpose one and passing isHTMLSpace.
+ * platform/network/HTTPParsers.h:
+ (WebCore::stripLeadingAndTrailingHTTPSpaces): Updated to use the
+ new name, stripLeadingAndTrailingCharacters.
+
2017-11-23 Darin Adler <[email protected]>
Fix dictionary leak in lookup, convert FindOptions to OptionSet, tweak code style nearby
Modified: trunk/Source/WebCore/html/HTMLOptionElement.cpp (225143 => 225144)
--- trunk/Source/WebCore/html/HTMLOptionElement.cpp 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WebCore/html/HTMLOptionElement.cpp 2017-11-25 02:44:45 UTC (rev 225144)
@@ -104,7 +104,7 @@
// FIXME: Is displayStringModifiedByEncoding helpful here?
// If it's correct here, then isn't it needed in the value and label functions too?
- return document().displayStringModifiedByEncoding(text).stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
+ return stripLeadingAndTrailingHTMLSpaces(document().displayStringModifiedByEncoding(text)).simplifyWhiteSpace(isHTMLSpace);
}
void HTMLOptionElement::setText(const String &text)
@@ -194,7 +194,7 @@
const AtomicString& value = attributeWithoutSynchronization(valueAttr);
if (!value.isNull())
return value;
- return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
+ return stripLeadingAndTrailingHTMLSpaces(collectOptionInnerText()).simplifyWhiteSpace(isHTMLSpace);
}
void HTMLOptionElement::setValue(const String& value)
@@ -271,8 +271,8 @@
{
String label = attributeWithoutSynchronization(labelAttr);
if (!label.isNull())
- return label.stripWhiteSpace(isHTMLSpace);
- return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
+ return stripLeadingAndTrailingHTMLSpaces(label);
+ return stripLeadingAndTrailingHTMLSpaces(collectOptionInnerText()).simplifyWhiteSpace(isHTMLSpace);
}
// Same as label() but ignores the label content attribute in quirks mode for compatibility with other browsers.
@@ -279,7 +279,7 @@
String HTMLOptionElement::displayLabel() const
{
if (document().inQuirksMode())
- return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace);
+ return stripLeadingAndTrailingHTMLSpaces(collectOptionInnerText()).simplifyWhiteSpace(isHTMLSpace);
return label();
}
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (225143 => 225144)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2017-11-25 02:44:45 UTC (rev 225144)
@@ -733,7 +733,7 @@
if (!headerContentLanguage.isEmpty()) {
size_t commaIndex = headerContentLanguage.find(',');
headerContentLanguage.truncate(commaIndex); // notFound == -1 == don't truncate
- headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTMLSpace);
+ headerContentLanguage = stripLeadingAndTrailingHTMLSpaces(headerContentLanguage);
if (!headerContentLanguage.isEmpty())
m_frame.document()->setContentLanguage(headerContentLanguage);
}
Modified: trunk/Source/WebCore/platform/network/HTTPParsers.h (225143 => 225144)
--- trunk/Source/WebCore/platform/network/HTTPParsers.h 2017-11-25 01:49:57 UTC (rev 225143)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.h 2017-11-25 02:44:45 UTC (rev 225144)
@@ -28,8 +28,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HTTPParsers_h
-#define HTTPParsers_h
+#pragma once
#include <wtf/Forward.h>
#include <wtf/HashSet.h>
@@ -111,7 +110,7 @@
// Strip leading and trailing whitespace as defined in https://fetch.spec.whatwg.org/#concept-header-value-normalize.
inline String stripLeadingAndTrailingHTTPSpaces(const String& string)
{
- return string.stripWhiteSpace(isHTTPSpace);
+ return string.stripLeadingAndTrailingCharacters(isHTTPSpace);
}
inline StringView stripLeadingAndTrailingHTTPSpaces(StringView string)
@@ -120,5 +119,3 @@
}
}
-
-#endif