Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (291836 => 291837)
--- trunk/Source/_javascript_Core/ChangeLog 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1,3 +1,17 @@
+2022-03-24 Chris Dumez <cdu...@apple.com>
+
+ String's startsWith() / endsWith() / replace() should take in a StringView instead of a String
+ https://bugs.webkit.org/show_bug.cgi?id=238333
+
+ Reviewed by Geoff Garen.
+
+ * runtime/FileBasedFuzzerAgent.cpp:
+ (JSC::FileBasedFuzzerAgent::getPredictionInternal):
+ * runtime/IntlRelativeTimeFormat.cpp:
+ (JSC::singularUnit):
+ * runtime/TemporalObject.cpp:
+ (JSC::singularUnit):
+
2022-03-24 Yusuke Suzuki <ysuz...@apple.com>
[JSC] JSRemoteFunction thunk should materialize code-pointer
Modified: trunk/Source/_javascript_Core/runtime/FileBasedFuzzerAgent.cpp (291836 => 291837)
--- trunk/Source/_javascript_Core/runtime/FileBasedFuzzerAgent.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/_javascript_Core/runtime/FileBasedFuzzerAgent.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -78,7 +78,7 @@
return original;
if (sourceAfterDivot.containsIgnoringASCIICase("yield"))
return original;
- if (sourceAfterDivot.startsWith('[') && sourceAfterDivot.endsWith("]"))
+ if (sourceAfterDivot.startsWith('[') && sourceAfterDivot.endsWith(']'))
return original;
if (sourceUpToDivot.containsIgnoringASCIICase("yield"))
return original;
Modified: trunk/Source/_javascript_Core/runtime/IntlRelativeTimeFormat.cpp (291836 => 291837)
--- trunk/Source/_javascript_Core/runtime/IntlRelativeTimeFormat.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/_javascript_Core/runtime/IntlRelativeTimeFormat.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -203,7 +203,7 @@
static StringView singularUnit(StringView unit)
{
// Plurals are allowed, but thankfully they're all just a simple -s.
- return unit.endsWith("s") ? unit.left(unit.length() - 1) : unit;
+ return unit.endsWith('s') ? unit.left(unit.length() - 1) : unit;
}
// https://tc39.es/ecma402/#sec-singularrelativetimeunit
Modified: trunk/Source/_javascript_Core/runtime/TemporalObject.cpp (291836 => 291837)
--- trunk/Source/_javascript_Core/runtime/TemporalObject.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/_javascript_Core/runtime/TemporalObject.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -145,7 +145,7 @@
static StringView singularUnit(StringView unit)
{
// Plurals are allowed, but thankfully they're all just a simple -s.
- return unit.endsWith("s") ? unit.left(unit.length() - 1) : unit;
+ return unit.endsWith('s') ? unit.left(unit.length() - 1) : unit;
}
// For use in error messages where a string value is potentially unbounded
Modified: trunk/Source/WTF/ChangeLog (291836 => 291837)
--- trunk/Source/WTF/ChangeLog 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WTF/ChangeLog 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1,3 +1,49 @@
+2022-03-24 Chris Dumez <cdu...@apple.com>
+
+ String's startsWith() / endsWith() / replace() should take in a StringView instead of a String
+ https://bugs.webkit.org/show_bug.cgi?id=238333
+
+ Reviewed by Geoff Garen.
+
+ String's startsWith() / endsWith() / replace() should take in a StringView instead of a String,
+ to avoid unnecessary String creation in many instances.
+
+ * wtf/text/AtomString.h:
+ * wtf/text/StringCommon.h:
+ (WTF::startsWith): Deleted.
+ (WTF::startsWithIgnoringASCIICase): Deleted.
+ (WTF::endsWith): Deleted.
+ (WTF::endsWithIgnoringASCIICase): Deleted.
+ * wtf/text/StringImpl.cpp:
+ (WTF::equalInner):
+ (WTF::StringImpl::startsWith const):
+ (WTF::StringImpl::startsWithIgnoringASCIICase const):
+ (WTF::StringImpl::hasInfixStartingAt const):
+ (WTF::StringImpl::endsWith):
+ (WTF::StringImpl::endsWithIgnoringASCIICase const):
+ (WTF::StringImpl::hasInfixEndingAt const):
+ (WTF::StringImpl::replace):
+ * wtf/text/StringImpl.h:
+ (WTF::StringImpl::startsWith const): Deleted.
+ (WTF::StringImpl::endsWith const): Deleted.
+ * wtf/text/StringView.h:
+ (WTF::startsWith):
+ (WTF::startsWithIgnoringASCIICase):
+ (WTF::endsWith):
+ (WTF::endsWithIgnoringASCIICase):
+ (WTF::String::replace):
+ (WTF::String::startsWith const):
+ (WTF::String::startsWithIgnoringASCIICase const):
+ (WTF::String::endsWith const):
+ (WTF::String::endsWithIgnoringASCIICase const):
+ (WTF::String::hasInfixStartingAt const):
+ (WTF::String::hasInfixEndingAt const):
+ (WTF::AtomString::startsWith const):
+ (WTF::AtomString::startsWithIgnoringASCIICase const):
+ (WTF::AtomString::endsWith const):
+ (WTF::AtomString::endsWithIgnoringASCIICase const):
+ * wtf/text/WTFString.h:
+
2022-03-24 Don Olmstead <don.olmst...@sony.com>
[GLib] Add user directories to WTF::FileSystem
Modified: trunk/Source/WTF/wtf/text/AtomString.h (291836 => 291837)
--- trunk/Source/WTF/wtf/text/AtomString.h 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WTF/wtf/text/AtomString.h 2022-03-25 00:13:55 UTC (rev 291837)
@@ -124,15 +124,13 @@
size_t findIgnoringASCIICase(StringView, unsigned start) const;
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); }
+ bool startsWith(StringView) const;
+ bool startsWithIgnoringASCIICase(StringView) const;
bool startsWith(UChar character) const { return m_string.startsWith(character); }
- template<unsigned matchLength> bool startsWith(const char (&prefix)[matchLength]) const { return m_string.startsWith<matchLength>(prefix); }
- bool endsWith(const String& string) const { return m_string.endsWith(string); }
- bool endsWithIgnoringASCIICase(const String& string) const { return m_string.endsWithIgnoringASCIICase(string); }
+ bool endsWith(StringView) const;
+ bool endsWithIgnoringASCIICase(StringView) const;
bool endsWith(UChar character) const { return m_string.endsWith(character); }
- template<unsigned matchLength> bool endsWith(const char (&prefix)[matchLength]) const { return m_string.endsWith<matchLength>(prefix); }
WTF_EXPORT_PRIVATE AtomString convertToASCIILowercase() const;
WTF_EXPORT_PRIVATE AtomString convertToASCIIUppercase() const;
Modified: trunk/Source/WTF/wtf/text/StringCommon.h (291836 => 291837)
--- trunk/Source/WTF/wtf/text/StringCommon.h 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WTF/wtf/text/StringCommon.h 2022-03-25 00:13:55 UTC (rev 291837)
@@ -381,80 +381,6 @@
return equalIgnoringASCIICase(a.characters16(), b, length);
}
-template<typename StringClassA, typename StringClassB>
-bool startsWith(const StringClassA& reference, const StringClassB& prefix)
-{
- unsigned prefixLength = prefix.length();
- if (prefixLength > reference.length())
- return false;
-
- if (reference.is8Bit()) {
- if (prefix.is8Bit())
- return equal(reference.characters8(), prefix.characters8(), prefixLength);
- return equal(reference.characters8(), prefix.characters16(), prefixLength);
- }
- if (prefix.is8Bit())
- return equal(reference.characters16(), prefix.characters8(), prefixLength);
- return equal(reference.characters16(), prefix.characters16(), prefixLength);
-}
-
-template<typename StringClassA, typename StringClassB>
-bool startsWithIgnoringASCIICase(const StringClassA& reference, const StringClassB& prefix)
-{
- unsigned prefixLength = prefix.length();
- if (prefixLength > reference.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);
-}
-
-template<typename StringClassA, typename StringClassB>
-bool endsWith(const StringClassA& reference, const StringClassB& suffix)
-{
- unsigned suffixLength = suffix.length();
- unsigned referenceLength = reference.length();
- if (suffixLength > referenceLength)
- return false;
-
- unsigned startOffset = referenceLength - suffixLength;
-
- if (reference.is8Bit()) {
- if (suffix.is8Bit())
- return equal(reference.characters8() + startOffset, suffix.characters8(), suffixLength);
- return equal(reference.characters8() + startOffset, suffix.characters16(), suffixLength);
- }
- if (suffix.is8Bit())
- return equal(reference.characters16() + startOffset, suffix.characters8(), suffixLength);
- return equal(reference.characters16() + startOffset, suffix.characters16(), suffixLength);
-}
-
-template<typename StringClassA, typename StringClassB>
-bool endsWithIgnoringASCIICase(const StringClassA& reference, const StringClassB& suffix)
-{
- unsigned suffixLength = suffix.length();
- unsigned referenceLength = reference.length();
- if (suffixLength > referenceLength)
- return false;
-
- unsigned startOffset = referenceLength - suffixLength;
-
- if (reference.is8Bit()) {
- if (suffix.is8Bit())
- return equalIgnoringASCIICase(reference.characters8() + startOffset, suffix.characters8(), suffixLength);
- return equalIgnoringASCIICase(reference.characters8() + startOffset, suffix.characters16(), suffixLength);
- }
- if (suffix.is8Bit())
- return equalIgnoringASCIICase(reference.characters16() + startOffset, suffix.characters8(), suffixLength);
- return equalIgnoringASCIICase(reference.characters16() + startOffset, suffix.characters16(), suffixLength);
-}
-
template <typename SearchCharacterType, typename MatchCharacterType>
size_t findIgnoringASCIICase(const SearchCharacterType* source, const MatchCharacterType* matchCharacters, unsigned startOffset, unsigned searchLength, unsigned matchLength)
{
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (291836 => 291837)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1053,7 +1053,7 @@
return equal(string.characters16() + start, reinterpret_cast<const LChar*>(matchString), matchLength);
}
-ALWAYS_INLINE static bool equalInner(const StringImpl& string, unsigned start, const StringImpl& matchString)
+ALWAYS_INLINE static bool equalInner(const StringImpl& string, unsigned start, StringView matchString)
{
if (start > string.length())
return false;
@@ -1072,26 +1072,16 @@
return equal(string.characters16() + start, matchString.characters16(), matchString.length());
}
-bool StringImpl::startsWith(const StringImpl* string) const
+bool StringImpl::startsWith(StringView string) const
{
- return !string || ::WTF::startsWith(*this, *string);
+ return !string || ::WTF::startsWith(*this, string);
}
-bool StringImpl::startsWith(const StringImpl& string) const
+bool StringImpl::startsWithIgnoringASCIICase(StringView prefix) const
{
- return ::WTF::startsWith(*this, string);
+ return prefix && ::WTF::startsWithIgnoringASCIICase(*this, prefix);
}
-bool StringImpl::startsWithIgnoringASCIICase(const StringImpl* prefix) const
-{
- return prefix && ::WTF::startsWithIgnoringASCIICase(*this, *prefix);
-}
-
-bool StringImpl::startsWithIgnoringASCIICase(const StringImpl& prefix) const
-{
- return ::WTF::startsWithIgnoringASCIICase(*this, prefix);
-}
-
bool StringImpl::startsWith(UChar character) const
{
return m_length && (*this)[0] == character;
@@ -1102,31 +1092,21 @@
return matchLength <= length() && equalInner(*this, 0, matchString, matchLength);
}
-bool StringImpl::hasInfixStartingAt(const StringImpl& matchString, unsigned start) const
+bool StringImpl::hasInfixStartingAt(StringView matchString, unsigned start) const
{
return equalInner(*this, start, matchString);
}
-bool StringImpl::endsWith(StringImpl* suffix)
+bool StringImpl::endsWith(StringView suffix)
{
- return suffix && ::WTF::endsWith(*this, *suffix);
+ return suffix && ::WTF::endsWith(*this, suffix);
}
-bool StringImpl::endsWith(StringImpl& suffix)
+bool StringImpl::endsWithIgnoringASCIICase(StringView suffix) const
{
- return ::WTF::endsWith(*this, suffix);
+ return suffix && ::WTF::endsWithIgnoringASCIICase(*this, suffix);
}
-bool StringImpl::endsWithIgnoringASCIICase(const StringImpl* suffix) const
-{
- return suffix && ::WTF::endsWithIgnoringASCIICase(*this, *suffix);
-}
-
-bool StringImpl::endsWithIgnoringASCIICase(const StringImpl& suffix) const
-{
- return ::WTF::endsWithIgnoringASCIICase(*this, suffix);
-}
-
bool StringImpl::endsWith(UChar character) const
{
return m_length && (*this)[m_length - 1] == character;
@@ -1137,9 +1117,9 @@
return matchLength <= length() && equalInner(*this, length() - matchLength, matchString, matchLength);
}
-bool StringImpl::hasInfixEndingAt(const StringImpl& matchString, unsigned endOffset) const
+bool StringImpl::hasInfixEndingAt(StringView matchString, unsigned end) const
{
- return endOffset >= matchString.length() && equalInner(*this, endOffset - matchString.length(), matchString);
+ return end >= matchString.length() && equalInner(*this, end - matchString.length(), matchString);
}
Ref<StringImpl> StringImpl::replace(UChar target, UChar replacement)
@@ -1203,11 +1183,11 @@
return newImpl;
}
-Ref<StringImpl> StringImpl::replace(unsigned position, unsigned lengthToReplace, StringImpl* string)
+Ref<StringImpl> StringImpl::replace(unsigned position, unsigned lengthToReplace, StringView string)
{
position = std::min(position, length());
lengthToReplace = std::min(lengthToReplace, length() - position);
- unsigned lengthToInsert = string ? string->length() : 0;
+ unsigned lengthToInsert = string.length();
if (!lengthToReplace && !lengthToInsert)
return *this;
@@ -1214,12 +1194,12 @@
if ((length() - lengthToReplace) >= (MaxLength - lengthToInsert))
CRASH();
- if (is8Bit() && (!string || string->is8Bit())) {
+ if (is8Bit() && (!string || string.is8Bit())) {
LChar* data;
auto newImpl = createUninitialized(length() - lengthToReplace + lengthToInsert, data);
copyCharacters(data, m_data8, position);
if (string)
- copyCharacters(data + position, string->m_data8, lengthToInsert);
+ copyCharacters(data + position, string.characters8(), lengthToInsert);
copyCharacters(data + position + lengthToInsert, m_data8 + position + lengthToReplace, length() - position - lengthToReplace);
return newImpl;
}
@@ -1230,10 +1210,10 @@
else
copyCharacters(data, m_data16, position);
if (string) {
- if (string->is8Bit())
- copyCharacters(data + position, string->m_data8, lengthToInsert);
+ if (string.is8Bit())
+ copyCharacters(data + position, string.characters8(), lengthToInsert);
else
- copyCharacters(data + position, string->m_data16, lengthToInsert);
+ copyCharacters(data + position, string.characters16(), lengthToInsert);
}
if (is8Bit())
copyCharacters(data + position + lengthToInsert, m_data8 + position + lengthToReplace, length() - position - lengthToReplace);
@@ -1242,13 +1222,13 @@
return newImpl;
}
-Ref<StringImpl> StringImpl::replace(UChar pattern, StringImpl* replacement)
+Ref<StringImpl> StringImpl::replace(UChar pattern, StringView replacement)
{
if (!replacement)
return *this;
- if (replacement->is8Bit())
- return replace(pattern, replacement->m_data8, replacement->length());
- return replace(pattern, replacement->m_data16, replacement->length());
+ if (replacement.is8Bit())
+ return replace(pattern, replacement.characters8(), replacement.length());
+ return replace(pattern, replacement.characters16(), replacement.length());
}
Ref<StringImpl> StringImpl::replace(UChar pattern, const LChar* replacement, unsigned repStrLength)
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (291836 => 291837)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2022-03-25 00:13:55 UTC (rev 291837)
@@ -438,31 +438,25 @@
WTF_EXPORT_PRIVATE size_t reverseFind(UChar, unsigned start = MaxLength);
WTF_EXPORT_PRIVATE size_t reverseFind(StringView, unsigned start = MaxLength);
- WTF_EXPORT_PRIVATE bool startsWith(const StringImpl*) const;
- WTF_EXPORT_PRIVATE bool startsWith(const StringImpl&) const;
- WTF_EXPORT_PRIVATE bool startsWithIgnoringASCIICase(const StringImpl*) const;
- WTF_EXPORT_PRIVATE bool startsWithIgnoringASCIICase(const StringImpl&) const;
+ WTF_EXPORT_PRIVATE bool startsWith(StringView) const;
+ WTF_EXPORT_PRIVATE bool startsWithIgnoringASCIICase(StringView) const;
WTF_EXPORT_PRIVATE bool startsWith(UChar) const;
WTF_EXPORT_PRIVATE bool startsWith(const char*, unsigned matchLength) const;
- template<unsigned matchLength> bool startsWith(const char (&prefix)[matchLength]) const { return startsWith(prefix, matchLength - 1); }
- WTF_EXPORT_PRIVATE bool hasInfixStartingAt(const StringImpl&, unsigned start) const;
+ WTF_EXPORT_PRIVATE bool hasInfixStartingAt(StringView, unsigned start) const;
- WTF_EXPORT_PRIVATE bool endsWith(StringImpl*);
- WTF_EXPORT_PRIVATE bool endsWith(StringImpl&);
- WTF_EXPORT_PRIVATE bool endsWithIgnoringASCIICase(const StringImpl*) const;
- WTF_EXPORT_PRIVATE bool endsWithIgnoringASCIICase(const StringImpl&) const;
+ WTF_EXPORT_PRIVATE bool endsWith(StringView);
+ WTF_EXPORT_PRIVATE bool endsWithIgnoringASCIICase(StringView) const;
WTF_EXPORT_PRIVATE bool endsWith(UChar) const;
WTF_EXPORT_PRIVATE bool endsWith(const char*, unsigned matchLength) const;
- template<unsigned matchLength> bool endsWith(const char (&prefix)[matchLength]) const { return endsWith(prefix, matchLength - 1); }
- WTF_EXPORT_PRIVATE bool hasInfixEndingAt(const StringImpl&, unsigned endOffset) const;
+ WTF_EXPORT_PRIVATE bool hasInfixEndingAt(StringView, unsigned end) const;
WTF_EXPORT_PRIVATE Ref<StringImpl> replace(UChar, UChar);
- WTF_EXPORT_PRIVATE Ref<StringImpl> replace(UChar, StringImpl*);
+ WTF_EXPORT_PRIVATE Ref<StringImpl> replace(UChar, StringView);
ALWAYS_INLINE Ref<StringImpl> replace(UChar pattern, const char* replacement, unsigned replacementLength) { return replace(pattern, reinterpret_cast<const LChar*>(replacement), replacementLength); }
WTF_EXPORT_PRIVATE Ref<StringImpl> replace(UChar, const LChar*, unsigned replacementLength);
Ref<StringImpl> replace(UChar, const UChar*, unsigned replacementLength);
WTF_EXPORT_PRIVATE Ref<StringImpl> replace(StringView, StringView);
- WTF_EXPORT_PRIVATE Ref<StringImpl> replace(unsigned start, unsigned length, StringImpl*);
+ WTF_EXPORT_PRIVATE Ref<StringImpl> replace(unsigned start, unsigned length, StringView);
WTF_EXPORT_PRIVATE UCharDirection defaultWritingDirection(bool* hasStrongDirectionality = nullptr);
Modified: trunk/Source/WTF/wtf/text/StringView.h (291836 => 291837)
--- trunk/Source/WTF/wtf/text/StringView.h 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WTF/wtf/text/StringView.h 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1157,6 +1157,76 @@
return findIgnoringASCIICase(source.characters16(), stringToFind.characters16(), start, searchLength, matchLength);
}
+inline bool startsWith(StringView reference, StringView prefix)
+{
+ unsigned prefixLength = prefix.length();
+ if (prefixLength > reference.length())
+ return false;
+
+ if (reference.is8Bit()) {
+ if (prefix.is8Bit())
+ return equal(reference.characters8(), prefix.characters8(), prefixLength);
+ return equal(reference.characters8(), prefix.characters16(), prefixLength);
+ }
+ if (prefix.is8Bit())
+ return equal(reference.characters16(), prefix.characters8(), prefixLength);
+ return equal(reference.characters16(), prefix.characters16(), prefixLength);
+}
+
+inline bool startsWithIgnoringASCIICase(StringView reference, StringView prefix)
+{
+ unsigned prefixLength = prefix.length();
+ if (prefixLength > reference.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);
+}
+
+inline bool endsWith(StringView reference, StringView suffix)
+{
+ unsigned suffixLength = suffix.length();
+ unsigned referenceLength = reference.length();
+ if (suffixLength > referenceLength)
+ return false;
+
+ unsigned startOffset = referenceLength - suffixLength;
+
+ if (reference.is8Bit()) {
+ if (suffix.is8Bit())
+ return equal(reference.characters8() + startOffset, suffix.characters8(), suffixLength);
+ return equal(reference.characters8() + startOffset, suffix.characters16(), suffixLength);
+ }
+ if (suffix.is8Bit())
+ return equal(reference.characters16() + startOffset, suffix.characters8(), suffixLength);
+ return equal(reference.characters16() + startOffset, suffix.characters16(), suffixLength);
+}
+
+inline bool endsWithIgnoringASCIICase(StringView reference, StringView suffix)
+{
+ unsigned suffixLength = suffix.length();
+ unsigned referenceLength = reference.length();
+ if (suffixLength > referenceLength)
+ return false;
+
+ unsigned startOffset = referenceLength - suffixLength;
+
+ if (reference.is8Bit()) {
+ if (suffix.is8Bit())
+ return equalIgnoringASCIICase(reference.characters8() + startOffset, suffix.characters8(), suffixLength);
+ return equalIgnoringASCIICase(reference.characters8() + startOffset, suffix.characters16(), suffixLength);
+ }
+ if (suffix.is8Bit())
+ return equalIgnoringASCIICase(reference.characters16() + startOffset, suffix.characters8(), suffixLength);
+ return equalIgnoringASCIICase(reference.characters16() + startOffset, suffix.characters16(), suffixLength);
+}
+
inline size_t String::find(StringView string) const
{
return m_impl ? m_impl->find(string) : notFound;
@@ -1203,13 +1273,50 @@
return *this;
}
-inline String& String::replace(unsigned start, unsigned length, const String& replacement)
+inline String& String::replace(unsigned start, unsigned length, StringView replacement)
{
if (m_impl)
- m_impl = m_impl->replace(start, length, replacement.impl());
+ m_impl = m_impl->replace(start, length, replacement);
return *this;
}
+inline String& String::replace(UChar target, StringView replacement)
+{
+ if (m_impl)
+ m_impl = m_impl->replace(target, replacement);
+ return *this;
+}
+
+inline bool String::startsWith(StringView string) const
+{
+ return m_impl ? m_impl->startsWith(string) : string.isEmpty();
+}
+
+inline bool String::startsWithIgnoringASCIICase(StringView string) const
+{
+ return m_impl ? m_impl->startsWithIgnoringASCIICase(string) : string.isEmpty();
+}
+
+inline bool String::endsWith(StringView string) const
+{
+ return m_impl ? m_impl->endsWith(string) : string.isEmpty();
+}
+
+inline bool String::endsWithIgnoringASCIICase(StringView string) const
+{
+ return m_impl ? m_impl->endsWithIgnoringASCIICase(string) : string.isEmpty();
+}
+
+inline bool String::hasInfixStartingAt(StringView prefix, unsigned start) const
+{
+ return m_impl && prefix && m_impl->hasInfixStartingAt(prefix, start);
+}
+
+inline bool String::hasInfixEndingAt(StringView suffix, unsigned end) const
+{
+ return m_impl && suffix && m_impl->hasInfixEndingAt(suffix, end);
+}
+
inline size_t AtomString::find(StringView string, unsigned start) const
{
return m_string.find(string, start);
@@ -1235,6 +1342,26 @@
return m_string.containsIgnoringASCIICase(string);
}
+inline bool AtomString::startsWith(StringView string) const
+{
+ return m_string.startsWith(string);
+}
+
+inline bool AtomString::startsWithIgnoringASCIICase(StringView string) const
+{
+ return m_string.startsWithIgnoringASCIICase(string);
+}
+
+inline bool AtomString::endsWith(StringView string) const
+{
+ return m_string.endsWith(string);
+}
+
+inline bool AtomString::endsWithIgnoringASCIICase(StringView string) const
+{
+ return m_string.endsWithIgnoringASCIICase(string);
+}
+
} // namespace WTF
using WTF::append;
Modified: trunk/Source/WTF/wtf/text/WTFString.h (291836 => 291837)
--- trunk/Source/WTF/wtf/text/WTFString.h 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2022-03-25 00:13:55 UTC (rev 291837)
@@ -182,18 +182,16 @@
bool containsIgnoringASCIICase(StringView) const;
bool containsIgnoringASCIICase(StringView, unsigned start) const;
- bool startsWith(const String& string) const { return m_impl ? m_impl->startsWith(string.impl()) : string.isEmpty(); }
- bool startsWithIgnoringASCIICase(const String& string) const { return m_impl ? m_impl->startsWithIgnoringASCIICase(string.impl()) : string.isEmpty(); }
+ bool startsWith(StringView) const;
+ bool startsWithIgnoringASCIICase(StringView) const;
bool startsWith(UChar character) const { return m_impl && m_impl->startsWith(character); }
- template<unsigned matchLength> bool startsWith(const char (&prefix)[matchLength]) const { return m_impl ? m_impl->startsWith<matchLength>(prefix) : !matchLength; }
- bool hasInfixStartingAt(const String& prefix, unsigned start) const { return m_impl && prefix.impl() && m_impl->hasInfixStartingAt(*prefix.impl(), start); }
+ bool hasInfixStartingAt(StringView prefix, unsigned start) const;
- bool endsWith(const String& string) const { return m_impl ? m_impl->endsWith(string.impl()) : string.isEmpty(); }
- bool endsWithIgnoringASCIICase(const String& string) const { return m_impl ? m_impl->endsWithIgnoringASCIICase(string.impl()) : string.isEmpty(); }
+ bool endsWith(StringView) const;
+ bool endsWithIgnoringASCIICase(StringView) const;
bool endsWith(UChar character) const { return m_impl && m_impl->endsWith(character); }
bool endsWith(char character) const { return endsWith(static_cast<UChar>(character)); }
- template<unsigned matchLength> bool endsWith(const char (&prefix)[matchLength]) const { return m_impl ? m_impl->endsWith<matchLength>(prefix) : !matchLength; }
- bool hasInfixEndingAt(const String& suffix, unsigned endOffset) const { return m_impl && suffix.impl() && m_impl->hasInfixEndingAt(*suffix.impl(), endOffset); }
+ bool hasInfixEndingAt(StringView suffix, unsigned end) const;
WTF_EXPORT_PRIVATE void append(const String&);
WTF_EXPORT_PRIVATE void append(LChar);
@@ -204,9 +202,9 @@
WTF_EXPORT_PRIVATE void insert(const String&, unsigned position);
String& replace(UChar target, UChar replacement);
- String& replace(UChar target, const String& replacement);
+ String& replace(UChar target, StringView replacement);
String& replace(StringView target, StringView replacement);
- String& replace(unsigned start, unsigned length, const String& replacement);
+ String& replace(unsigned start, unsigned length, StringView replacement);
template<unsigned characterCount> String& replaceWithLiteral(UChar target, const char (&replacement)[characterCount]);
WTF_EXPORT_PRIVATE void truncate(unsigned length);
@@ -499,13 +497,6 @@
return *this;
}
-inline String& String::replace(UChar target, const String& replacement)
-{
- if (m_impl)
- m_impl = m_impl->replace(target, replacement.impl());
- return *this;
-}
-
template<unsigned characterCount> ALWAYS_INLINE String& String::replaceWithLiteral(UChar target, const char (&characters)[characterCount])
{
if (m_impl)
Modified: trunk/Source/WebCore/ChangeLog (291836 => 291837)
--- trunk/Source/WebCore/ChangeLog 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/ChangeLog 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1,3 +1,34 @@
+2022-03-24 Chris Dumez <cdu...@apple.com>
+
+ String's startsWith() / endsWith() / replace() should take in a StringView instead of a String
+ https://bugs.webkit.org/show_bug.cgi?id=238333
+
+ Reviewed by Geoff Garen.
+
+ * Modules/mediastream/PeerConnectionBackend.cpp:
+ (WebCore::shouldIgnoreIceCandidate):
+ * css/CSSImageValue.cpp:
+ (WebCore::ResolvedURL::isLocalURL const):
+ * page/PageConsoleClient.cpp:
+ (WebCore::PageConsoleClient::screenshot):
+ * page/csp/ContentSecurityPolicySource.cpp:
+ (WebCore::ContentSecurityPolicySource::pathMatches const):
+ * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+ (WebCore::GraphicsContextGLANGLE::getUnmangledInfoLog):
+ * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
+ (WebCore::CDMFactoryFairPlayStreaming::supportsKeySystem):
+ * platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:
+ (WebCore::ImageDecoderGStreamer::supportsContainerType):
+ (WebCore::ImageDecoderGStreamer::canDecodeType):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::supportsType):
+ * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+ (WebCore::GraphicsContextGLOpenGL::checkVaryingsPacking const):
+ * platform/network/ParsedRequestRange.cpp:
+ (WebCore::ParsedRequestRange::parse):
+ * platform/network/curl/CookieJarDB.cpp:
+ (WebCore::checkSecureCookie):
+
2022-03-24 Nikolaos Mouchtaris <nmouchta...@apple.com>
Fix serialization of nan, infinity, -infinity for calc()
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (291836 => 291837)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -296,7 +296,7 @@
static inline bool shouldIgnoreIceCandidate(const RTCIceCandidate& iceCandidate)
{
auto address = extractIPAddress(iceCandidate.candidate());
- if (!address.endsWithIgnoringASCIICase(".local"_s))
+ if (!address.endsWithIgnoringASCIICase(".local"))
return false;
if (!WTF::isVersion4UUID(StringView { address }.substring(0, address.length() - 6))) {
Modified: trunk/Source/WebCore/css/CSSImageValue.cpp (291836 => 291837)
--- trunk/Source/WebCore/css/CSSImageValue.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/css/CSSImageValue.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -43,7 +43,7 @@
// https://drafts.csswg.org/css-values/#url-local-url-flag
bool ResolvedURL::isLocalURL() const
{
- return specifiedURLString.startsWith("#");
+ return specifiedURLString.startsWith('#');
}
static ResolvedURL makeResolvedURL(URL&& resolvedURL)
Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (291836 => 291837)
--- trunk/Source/WebCore/page/PageConsoleClient.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -401,7 +401,7 @@
// FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations
} else {
String base64;
- if (possibleTarget.getString(lexicalGlobalObject, base64) && base64.startsWithIgnoringASCIICase("data:"_s) && base64.length() > 5) {
+ if (possibleTarget.getString(lexicalGlobalObject, base64) && base64.startsWithIgnoringASCIICase("data:") && base64.length() > 5) {
target = possibleTarget;
dataURL = base64;
}
Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicySource.cpp (291836 => 291837)
--- trunk/Source/WebCore/page/csp/ContentSecurityPolicySource.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicySource.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -87,7 +87,7 @@
auto path = PAL::decodeURLEscapeSequences(url.path());
- if (m_path.endsWith("/"))
+ if (m_path.endsWith('/'))
return path.startsWith(m_path);
return path == m_path;
Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1911,8 +1911,8 @@
// causes a warning in some compilers. There is no point showing
// this warning to the user since they didn't write the code that
// is causing it.
- static const NeverDestroyed<String> angleWarning { "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n"_s };
- int startFrom = log.startsWith(angleWarning) ? angleWarning.get().length() : 0;
+ static constexpr char angleWarning[] = "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n";
+ int startFrom = log.startsWith(angleWarning) ? strlen(angleWarning) : 0;
processedLog.append(log.substring(startFrom, log.length() - startFrom));
LOG(WebGL, "Unmangled ShaderInfoLog:\n%s", processedLog.toString().utf8().data());
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -250,7 +250,7 @@
{
// https://w3c.github.io/encrypted-media/#key-system
// "Key System strings are compared using case-sensitive matching."
- return keySystem == "com.apple.fps" || keySystem.startsWith("com.apple.fps."_s);
+ return keySystem == "com.apple.fps" || keySystem.startsWith("com.apple.fps.");
}
CDMPrivateFairPlayStreaming::CDMPrivateFairPlayStreaming(const CDMPrivateClient& client)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -104,7 +104,7 @@
if (!isInWebProcess())
return false;
- if (!type.startsWith("video/"_s))
+ if (!type.startsWith("video/"))
return false;
return GStreamerRegistryScanner::singleton().isContainerTypeSupported(GStreamerRegistryScanner::Configuration::Decoding, type);
@@ -115,7 +115,7 @@
if (mimeType.isEmpty())
return false;
- if (!mimeType.startsWith("video/"_s))
+ if (!mimeType.startsWith("video/"))
return false;
// Ideally this decoder should operate only from the WebProcess (or from the GPUProcess) which
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -2582,7 +2582,7 @@
return result;
// This player doesn't support pictures rendering.
- if (parameters.type.raw().startsWith("image"_s))
+ if (parameters.type.raw().startsWith("image"))
return result;
auto& gstRegistryScanner = GStreamerRegistryScanner::singleton();
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -528,7 +528,7 @@
const String& symbolName = vertexSymbol.key;
// The varying map includes variables for each index of an array variable.
// We only want a single variable to represent the array.
- if (symbolName.endsWith("]"))
+ if (symbolName.endsWith(']'))
continue;
// Don't count built in varyings.
@@ -1974,8 +1974,8 @@
// causes a warning in some compilers. There is no point showing
// this warning to the user since they didn't write the code that
// is causing it.
- static const NeverDestroyed<String> angleWarning { "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n"_s };
- int startFrom = log.startsWith(angleWarning) ? angleWarning.get().length() : 0;
+ static constexpr char angleWarning[] = "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n";
+ int startFrom = log.startsWith(angleWarning) ? strlen(angleWarning) : 0;
int matchedLength = 0;
do {
Modified: trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateGStreamer.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateGStreamer.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateGStreamer.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -173,7 +173,7 @@
const char* containerCapsDescription = "";
auto containerType = contentType.containerType();
- if (containerType.endsWith("mp4"_s))
+ if (containerType.endsWith("mp4"))
containerCapsDescription = "video/quicktime, variant=iso";
else
containerCapsDescription = containerType.utf8().data();
@@ -181,7 +181,7 @@
auto containerCaps = adoptGRef(gst_caps_from_string(containerCapsDescription));
auto profile = "" nullptr, containerCaps.get(), nullptr));
- if (containerType.endsWith("mp4"_s))
+ if (containerType.endsWith("mp4"))
gst_encoding_profile_set_element_properties(GST_ENCODING_PROFILE(profile.get()), gst_structure_from_string("element-properties-map, map={[mp4mux,fragment-duration=1000,fragment-mode=0,streamable=0,force-create-timecode-trak=1]}", nullptr));
auto codecs = contentType.codecs();
@@ -194,11 +194,11 @@
videoCapsName = "video/x-vp9"_s;
else if (codecs.contains("av1"_s))
videoCapsName = "video/x-av1"_s;
- else if (codecs.findIf([](auto& codec) { return codec.startsWith("avc1"_s); }) != notFound)
+ else if (codecs.findIf([](auto& codec) { return codec.startsWith("avc1"); }) != notFound)
videoCapsName = "video/x-h264"_s;
- else if (containerType.endsWith("webm"_s))
+ else if (containerType.endsWith("webm"))
videoCapsName = "video/x-vp8"_s;
- else if (containerType.endsWith("mp4"_s))
+ else if (containerType.endsWith("mp4"))
videoCapsName = "video/x-h264"_s;
else {
GST_WARNING("Video codec for %s not supported", contentType.raw().utf8().data());
@@ -218,11 +218,11 @@
audioCapsName = "audio/x-vorbis"_s;
else if (codecs.contains("opus"_s))
audioCapsName = "audio/x-opus";
- else if (codecs.findIf([](auto& codec) { return codec.startsWith("mp4a"_s); }) != notFound)
+ else if (codecs.findIf([](auto& codec) { return codec.startsWith("mp4a"); }) != notFound)
audioCapsName = "audio/mpeg, mpegversion=4"_s;
- else if (containerType.endsWith("webm"_s))
+ else if (containerType.endsWith("webm"))
audioCapsName = "audio/x-vorbis"_s;
- else if (containerType.endsWith("mp4"_s))
+ else if (containerType.endsWith("mp4"))
audioCapsName = "audio/mpeg, mpegversion=4"_s;
else {
GST_WARNING("Audio codec for %s not supported", contentType.raw().utf8().data());
Modified: trunk/Source/WebCore/platform/network/ParsedRequestRange.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/network/ParsedRequestRange.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/network/ParsedRequestRange.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -33,7 +33,7 @@
std::optional<ParsedRequestRange> ParsedRequestRange::parse(StringView input)
{
// https://tools.ietf.org/html/rfc7233#section-2.1 but assuming there will always be a begin and an end or parsing will fail
- if (!input.startsWith(StringView("bytes="_s)))
+ if (!input.startsWith("bytes="))
return std::nullopt;
size_t begin { 0 };
Modified: trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp (291836 => 291837)
--- trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -490,11 +490,11 @@
static bool checkSecureCookie(const Cookie& cookie)
{
- if (cookie.name.startsWith("__Secure-"_s) && !cookie.secure)
+ if (cookie.name.startsWith("__Secure-") && !cookie.secure)
return false;
// Cookies for __Host must have the Secure attribute, path explicitly set to "/", and no domain attribute
- if (cookie.name.startsWith("__Host-"_s) && (!cookie.secure || cookie.path != "/"_s || !cookie.domain.isEmpty()))
+ if (cookie.name.startsWith("__Host-") && (!cookie.secure || cookie.path != "/"_s || !cookie.domain.isEmpty()))
return false;
return true;
Modified: trunk/Source/WebKit/NetworkProcess/storage/LocalStorageManager.cpp (291836 => 291837)
--- trunk/Source/WebKit/NetworkProcess/storage/LocalStorageManager.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebKit/NetworkProcess/storage/LocalStorageManager.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -42,7 +42,7 @@
// We should not include origin in file name.
static std::optional<WebCore::SecurityOriginData> fileNameToOrigin(const String& fileName)
{
- if (!fileName.endsWith(fileSuffix))
+ if (!fileName.endsWith(StringView { fileSuffix }))
return std::nullopt;
auto suffixLength = strlen(fileSuffix);
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (291836 => 291837)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2022-03-25 00:13:55 UTC (rev 291837)
@@ -4450,7 +4450,7 @@
static bool matchesExtensionOrEquivalent(const String& filename, const String& extension)
{
- return filename.endsWithIgnoringASCIICase("." + extension)
+ return filename.endsWithIgnoringASCIICase(makeString('.', extension))
|| (equalLettersIgnoringASCIICase(extension, "jpeg") && filename.endsWithIgnoringASCIICase(".jpg"));
}
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (291836 => 291837)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1,3 +1,13 @@
+2022-03-24 Chris Dumez <cdu...@apple.com>
+
+ String's startsWith() / endsWith() / replace() should take in a StringView instead of a String
+ https://bugs.webkit.org/show_bug.cgi?id=238333
+
+ Reviewed by Geoff Garen.
+
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::handleAcceptedCandidateWithSoftSpaces):
+
2022-03-18 Jonathan Bedard <jbed...@apple.com>
[iOS 15.4] Fix unused variables
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm (291836 => 291837)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2022-03-25 00:13:55 UTC (rev 291837)
@@ -1175,7 +1175,7 @@
if (replacementLength > 0) {
NSRange replacedRange = NSMakeRange(acceptedCandidate.range.location, replacementLength);
NSRange softSpaceRange = NSMakeRange(NSMaxRange(replacedRange) - 1, 1);
- if (acceptedCandidate.replacement.endsWith(" "))
+ if (acceptedCandidate.replacement.endsWith(' '))
[(WebHTMLView *)view _setSoftSpaceRange:softSpaceRange];
}
}
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp (291836 => 291837)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp 2022-03-25 00:13:47 UTC (rev 291836)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp 2022-03-25 00:13:55 UTC (rev 291837)
@@ -420,10 +420,10 @@
TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithNull)
{
auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
- ASSERT_FALSE(reference->startsWithIgnoringASCIICase(nullptr));
+ ASSERT_FALSE(reference->startsWithIgnoringASCIICase(StringView { }));
auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
- ASSERT_FALSE(empty->startsWithIgnoringASCIICase(nullptr));
+ ASSERT_FALSE(empty->startsWithIgnoringASCIICase(StringView { }));
}
TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithEmpty)
@@ -509,10 +509,10 @@
TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithNull)
{
auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
- ASSERT_FALSE(reference->endsWithIgnoringASCIICase(nullptr));
+ ASSERT_FALSE(reference->endsWithIgnoringASCIICase(StringView { }));
auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
- ASSERT_FALSE(empty->endsWithIgnoringASCIICase(nullptr));
+ ASSERT_FALSE(empty->endsWithIgnoringASCIICase(StringView { }));
}
TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithEmpty)