Diff
Modified: trunk/Source/WTF/ChangeLog (278668 => 278669)
--- trunk/Source/WTF/ChangeLog 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/ChangeLog 2021-06-09 20:46:24 UTC (rev 278669)
@@ -1,3 +1,17 @@
+2021-06-09 Chris Dumez <[email protected]>
+
+ Avoid some calls to StringView::toString() / StringView::toStringWithoutCopying()
+ https://bugs.webkit.org/show_bug.cgi?id=226803
+
+ Reviewed by Darin Adler.
+
+ Add support to TextStream for printing a StringView directly, without having to convert
+ it to a String first.
+
+ * wtf/text/TextStream.cpp:
+ (WTF::TextStream::operator<<):
+ * wtf/text/TextStream.h:
+
2021-06-09 Alicia Boya GarcĂa <[email protected]>
[WTF][GStreamer] Add RAII lockers for 3rd party locks
Modified: trunk/Source/WTF/wtf/URL.cpp (278668 => 278669)
--- trunk/Source/WTF/wtf/URL.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/wtf/URL.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -378,7 +378,7 @@
{
// Firefox and IE remove everything after the first ':'.
auto newProtocolPrefix = newProtocol.substring(0, newProtocol.find(':'));
- auto newProtocolCanonicalized = URLParser::maybeCanonicalizeScheme(newProtocolPrefix.toStringWithoutCopying());
+ auto newProtocolCanonicalized = URLParser::maybeCanonicalizeScheme(newProtocolPrefix);
if (!newProtocolCanonicalized)
return false;
@@ -529,9 +529,10 @@
));
}
-static String percentEncodeCharacters(const String& input, bool(*shouldEncode)(UChar))
+template<typename StringType>
+static String percentEncodeCharacters(const StringType& input, bool(*shouldEncode)(UChar))
{
- auto encode = [shouldEncode] (const String& input) {
+ auto encode = [shouldEncode] (const StringType& input) {
CString utf8 = input.utf8();
auto* data = ""
StringBuilder builder;
@@ -552,7 +553,10 @@
if (UNLIKELY(shouldEncode(input[i])))
return encode(input);
}
- return input;
+ if constexpr (std::is_same_v<StringType, StringView>)
+ return input.toString();
+ else
+ return input;
}
void URL::parse(const String& string)
@@ -584,7 +588,7 @@
parse(makeString(
StringView(m_string).left(m_userStart),
slashSlashNeeded ? "//" : "",
- percentEncodeCharacters(newUser.toStringWithoutCopying(), URLParser::isInUserInfoEncodeSet),
+ percentEncodeCharacters(newUser, URLParser::isInUserInfoEncodeSet),
needSeparator ? "@" : "",
StringView(m_string).substring(end)
));
@@ -606,7 +610,7 @@
parse(makeString(
StringView(m_string).left(m_userEnd),
needLeadingSlashes ? "//:" : ":",
- percentEncodeCharacters(newPassword.toStringWithoutCopying(), URLParser::isInUserInfoEncodeSet),
+ percentEncodeCharacters(newPassword, URLParser::isInUserInfoEncodeSet),
'@',
StringView(m_string).substring(credentialsEnd())
));
@@ -670,7 +674,7 @@
auto questionMarkOrNumberSignOrNonASCII = [] (UChar character) {
return character == '?' || character == '#' || !isASCII(character);
};
- return percentEncodeCharacters(path.toStringWithoutCopying(), questionMarkOrNumberSignOrNonASCII);
+ return percentEncodeCharacters(path, questionMarkOrNumberSignOrNonASCII);
}
void URL::setPath(StringView path)
Modified: trunk/Source/WTF/wtf/URLParser.cpp (278668 => 278669)
--- trunk/Source/WTF/wtf/URLParser.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/wtf/URLParser.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -698,7 +698,7 @@
}
}
-std::optional<String> URLParser::maybeCanonicalizeScheme(const String& scheme)
+std::optional<String> URLParser::maybeCanonicalizeScheme(StringView scheme)
{
if (scheme.isEmpty())
return std::nullopt;
Modified: trunk/Source/WTF/wtf/URLParser.h (278668 => 278669)
--- trunk/Source/WTF/wtf/URLParser.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/wtf/URLParser.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -46,7 +46,7 @@
WTF_EXPORT_PRIVATE static String serialize(const URLEncodedForm&);
WTF_EXPORT_PRIVATE static bool isSpecialScheme(const String& scheme);
- WTF_EXPORT_PRIVATE static std::optional<String> maybeCanonicalizeScheme(const String& scheme);
+ WTF_EXPORT_PRIVATE static std::optional<String> maybeCanonicalizeScheme(StringView scheme);
static const UIDNA& internationalDomainNameTranscoder();
static bool isInUserInfoEncodeSet(UChar);
Modified: trunk/Source/WTF/wtf/text/StringView.cpp (278668 => 278669)
--- trunk/Source/WTF/wtf/text/StringView.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/wtf/text/StringView.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -247,6 +247,30 @@
return convertASCIICase<ASCIICase::Upper>(static_cast<const UChar*>(m_characters), m_length);
}
+template<typename CharacterType>
+static AtomString convertASCIILowercaseAtom(const CharacterType* input, unsigned length)
+{
+ for (unsigned i = 0; i < length; ++i) {
+ if (UNLIKELY(isASCIIUpper(input[i]))) {
+ CharacterType* characters;
+ auto result = String::createUninitialized(length, characters);
+ StringImpl::copyCharacters(characters, input, i);
+ for (; i < length; ++i)
+ characters[i] = toASCIILower(input[i]);
+ return result;
+ }
+ }
+ // Fast path when the StringView is already all lowercase.
+ return AtomString(input, length);
+}
+
+AtomString StringView::convertToASCIILowercaseAtom() const
+{
+ if (m_is8Bit)
+ return convertASCIILowercaseAtom(characters8(), m_length);
+ return convertASCIILowercaseAtom(characters16(), m_length);
+}
+
template<typename DestinationCharacterType, typename SourceCharacterType>
void getCharactersWithASCIICaseInternal(StringView::CaseConvertType type, DestinationCharacterType* destination, const SourceCharacterType* source, unsigned length)
{
Modified: trunk/Source/WTF/wtf/text/StringView.h (278668 => 278669)
--- trunk/Source/WTF/wtf/text/StringView.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/wtf/text/StringView.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -148,6 +148,7 @@
WTF_EXPORT_PRIVATE String convertToASCIILowercase() const;
WTF_EXPORT_PRIVATE String convertToASCIIUppercase() const;
+ WTF_EXPORT_PRIVATE AtomString convertToASCIILowercaseAtom() const;
bool contains(UChar) const;
bool contains(CodeUnitMatchFunction) const;
Modified: trunk/Source/WTF/wtf/text/TextStream.cpp (278668 => 278669)
--- trunk/Source/WTF/wtf/text/TextStream.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/wtf/text/TextStream.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -118,6 +118,12 @@
return *this << buffer;
}
+TextStream& TextStream::operator<<(const AtomString& string)
+{
+ m_text.append(string);
+ return *this;
+}
+
TextStream& TextStream::operator<<(const String& string)
{
m_text.append(string);
@@ -124,6 +130,12 @@
return *this;
}
+TextStream& TextStream::operator<<(StringView string)
+{
+ m_text.append(string);
+ return *this;
+}
+
TextStream& TextStream::operator<<(const FormatNumberRespectingIntegers& numberToFormat)
{
if (hasFractions(numberToFormat.value)) {
Modified: trunk/Source/WTF/wtf/text/TextStream.h (278668 => 278669)
--- trunk/Source/WTF/wtf/text/TextStream.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WTF/wtf/text/TextStream.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -70,7 +70,9 @@
WTF_EXPORT_PRIVATE TextStream& operator<<(double);
WTF_EXPORT_PRIVATE TextStream& operator<<(const char*);
WTF_EXPORT_PRIVATE TextStream& operator<<(const void*);
+ WTF_EXPORT_PRIVATE TextStream& operator<<(const AtomString&);
WTF_EXPORT_PRIVATE TextStream& operator<<(const String&);
+ WTF_EXPORT_PRIVATE TextStream& operator<<(StringView);
// Deprecated. Use the NumberRespectingIntegers FormattingFlag instead.
WTF_EXPORT_PRIVATE TextStream& operator<<(const FormatNumberRespectingIntegers&);
Modified: trunk/Source/WebCore/ChangeLog (278668 => 278669)
--- trunk/Source/WebCore/ChangeLog 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/ChangeLog 2021-06-09 20:46:24 UTC (rev 278669)
@@ -1,3 +1,19 @@
+2021-06-09 Chris Dumez <[email protected]>
+
+ Avoid some calls to StringView::toString() / StringView::toStringWithoutCopying()
+ https://bugs.webkit.org/show_bug.cgi?id=226803
+
+ Reviewed by Darin Adler.
+
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeFontVariationTag):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::scrollToFragmentInternal):
+ * platform/text/hyphen/HyphenationLibHyphen.cpp:
+ (WebCore::lastHyphenLocation):
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::writeDebugInfo):
+
2021-06-09 Tyler Wilcock <[email protected]>
[css-counter-styles] Mark counter-style descriptors as "descriptor-only"
Modified: trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp (278668 => 278669)
--- trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -99,7 +99,7 @@
isVarying = true;
return;
}
- auto name = nameView.toString();
+ auto name = nameView.toStringWithoutCopying();
isVarying = cachedRequest.httpHeaderField(name) != request.httpHeaderField(name);
});
Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp (278668 => 278669)
--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -98,9 +98,7 @@
if (parameterName.length()
&& isValidHTTPToken(parameterName)
&& parameterValue.isAllSpecialCharacters<isHTTPQuotedStringTokenCodePoint>()) {
- String nameString = parameterName.toString();
- if (!parameters.contains(nameString))
- parameters.set(nameString, parameterValue.toString());
+ parameters.ensure(parameterName.toString(), [&] { return parameterValue.toString(); });
}
}
return parameters;
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (278668 => 278669)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -1004,7 +1004,7 @@
if (!equalIgnoringFragmentIdentifier(documentURL, linkURL))
return nullptr;
- auto linkedNode = m_renderer->document().findAnchor(fragmentIdentifier.toStringWithoutCopying());
+ auto linkedNode = m_renderer->document().findAnchor(fragmentIdentifier);
if (!linkedNode)
return nullptr;
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (278668 => 278669)
--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -536,7 +536,7 @@
if (range.peek().type() != StringToken)
return nullptr;
- auto string = range.consumeIncludingWhitespace().value().toString();
+ auto string = range.consumeIncludingWhitespace().value();
FontTag tag;
if (string.length() != tag.size())
@@ -2303,9 +2303,11 @@
return nullptr;
CSSParserToken token = args.consumeIncludingWhitespace();
- auto attrName = token.value().toAtomString();
+ AtomString attrName;
if (context.isHTMLDocument)
- attrName = attrName.convertToASCIILowercase();
+ attrName = token.value().convertToASCIILowercaseAtom();
+ else
+ attrName = token.value().toAtomString();
if (!args.atEnd())
return nullptr;
@@ -3329,16 +3331,13 @@
return isGridTrackFixedSized(*minPrimitiveValue) || isGridTrackFixedSized(*maxPrimitiveValue);
}
-static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNames)
+static Vector<String> parseGridTemplateAreasColumnNames(StringView gridRowNames)
{
ASSERT(!gridRowNames.isEmpty());
Vector<String> columnNames;
- // Using StringImpl to avoid checks and indirection in every call to String::operator[].
- StringImpl& text = *gridRowNames.impl();
-
StringBuilder areaName;
- for (unsigned i = 0; i < text.length(); ++i) {
- if (isCSSSpace(text[i])) {
+ for (auto character : gridRowNames.codeUnits()) {
+ if (isCSSSpace(character)) {
if (!areaName.isEmpty()) {
columnNames.append(areaName.toString());
areaName.clear();
@@ -3345,7 +3344,7 @@
}
continue;
}
- if (text[i] == '.') {
+ if (character == '.') {
if (areaName == ".")
continue;
if (!areaName.isEmpty()) {
@@ -3353,7 +3352,7 @@
areaName.clear();
}
} else {
- if (!isNameCodePoint(text[i]))
+ if (!isNameCodePoint(character))
return Vector<String>();
if (areaName == ".") {
columnNames.append(areaName.toString());
@@ -3361,7 +3360,7 @@
}
}
- areaName.append(text[i]);
+ areaName.append(character);
}
if (!areaName.isEmpty())
@@ -3370,7 +3369,7 @@
return columnNames;
}
-static bool parseGridTemplateAreasRow(const String& gridRowNames, NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount)
+static bool parseGridTemplateAreasRow(StringView gridRowNames, NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount)
{
if (gridRowNames.isAllSpecialCharacters<isCSSSpace>())
return false;
@@ -3595,7 +3594,7 @@
size_t columnCount = 0;
while (range.peek().type() == StringToken) {
- if (!parseGridTemplateAreasRow(range.consumeIncludingWhitespace().value().toString(), gridAreaMap, rowCount, columnCount))
+ if (!parseGridTemplateAreasRow(range.consumeIncludingWhitespace().value(), gridAreaMap, rowCount, columnCount))
return nullptr;
++rowCount;
}
@@ -5611,7 +5610,7 @@
templateRows->append(lineNames.releaseNonNull());
// Handle a template-area's row.
- if (m_range.peek().type() != StringToken || !parseGridTemplateAreasRow(m_range.consumeIncludingWhitespace().value().toString(), gridAreaMap, rowCount, columnCount))
+ if (m_range.peek().type() != StringToken || !parseGridTemplateAreasRow(m_range.consumeIncludingWhitespace().value(), gridAreaMap, rowCount, columnCount))
return false;
++rowCount;
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (278668 => 278669)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -2442,9 +2442,11 @@
else {
if (!acceptQuirkyColors)
return std::nullopt;
- if (token.type() == IdentToken)
- string = token.value().toString(); // e.g. FF0000
- else if (token.type() == NumberToken || token.type() == DimensionToken) {
+ if (token.type() == IdentToken) {
+ view = token.value(); // e.g. FF0000
+ if (view.length() != 3 && view.length() != 6)
+ return std::nullopt;
+ } else if (token.type() == NumberToken || token.type() == DimensionToken) {
if (token.numericValueType() != IntegerValueType)
return std::nullopt;
auto numericValue = token.numericValue();
@@ -2457,10 +2459,12 @@
string = makeString(integerValue, token.value()); // e.g. 0001FF
if (string.length() < 6)
string = makeString(&"000000"[string.length()], string);
- }
- if (string.length() != 3 && string.length() != 6)
+
+ if (string.length() != 3 && string.length() != 6)
+ return std::nullopt;
+ view = string;
+ } else
return std::nullopt;
- view = string;
}
auto result = CSSParser::parseHexColor(view);
if (!result)
@@ -3559,7 +3563,7 @@
if (identMatches<CSSValueDecimal, CSSValueDisc, CSSValueNone>(nameToken.id()))
return AtomString();
auto name = nameToken.value();
- return isPredefinedCounterStyle(nameToken.id()) ? name.convertToASCIILowercase() : name.toString();
+ return isPredefinedCounterStyle(nameToken.id()) ? name.convertToASCIILowercaseAtom() : name.toAtomString();
}
std::optional<CSSValueID> consumeFontVariantCSS21Raw(CSSParserTokenRange& range)
Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (278668 => 278669)
--- trunk/Source/WebCore/dom/ScriptElement.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -368,7 +368,7 @@
ASSERT(m_element.document().contentSecurityPolicy());
const auto& contentSecurityPolicy = *m_element.document().contentSecurityPolicy();
bool hasKnownNonce = contentSecurityPolicy.allowScriptWithNonce(nonce, m_element.isInUserAgentShadowTree());
- if (!contentSecurityPolicy.allowInlineScript(m_element.document().url().string(), m_startLineNumber, sourceCode.source().toStringWithoutCopying(), hasKnownNonce))
+ if (!contentSecurityPolicy.allowInlineScript(m_element.document().url().string(), m_startLineNumber, sourceCode.source(), hasKnownNonce))
return false;
m_loadableScript = WTFMove(script);
@@ -389,7 +389,7 @@
ASSERT(m_element.document().contentSecurityPolicy());
const ContentSecurityPolicy& contentSecurityPolicy = *m_element.document().contentSecurityPolicy();
bool hasKnownNonce = contentSecurityPolicy.allowScriptWithNonce(m_element.attributeWithoutSynchronization(HTMLNames::nonceAttr), m_element.isInUserAgentShadowTree());
- if (!contentSecurityPolicy.allowInlineScript(m_element.document().url().string(), m_startLineNumber, sourceCode.source().toStringWithoutCopying(), hasKnownNonce))
+ if (!contentSecurityPolicy.allowInlineScript(m_element.document().url().string(), m_startLineNumber, sourceCode.source(), hasKnownNonce))
return;
}
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (278668 => 278669)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -196,7 +196,7 @@
if (document().scriptableDocumentParser() && !document().isInDocumentWrite())
startLineNumber = document().scriptableDocumentParser()->textPosition().m_line;
- if (reason == ModifiedByCloning || document().contentSecurityPolicy()->allowInlineStyle(document().url().string(), startLineNumber, String(), isInUserAgentShadowTree()))
+ if (reason == ModifiedByCloning || document().contentSecurityPolicy()->allowInlineStyle(document().url().string(), startLineNumber, { }, isInUserAgentShadowTree()))
setInlineStyleFromString(newStyleString);
elementData()->setStyleAttributeIsDirty(false);
Modified: trunk/Source/WebCore/dom/TreeScope.cpp (278668 => 278669)
--- trunk/Source/WebCore/dom/TreeScope.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/dom/TreeScope.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -443,7 +443,7 @@
// FIXME: Would be nice to change this to take a StringView, since that's what callers have
// and there is no particular advantage to already having a String.
-Element* TreeScope::findAnchor(const String& name)
+Element* TreeScope::findAnchor(StringView name)
{
if (name.isEmpty())
return nullptr;
Modified: trunk/Source/WebCore/dom/TreeScope.h (278668 => 278669)
--- trunk/Source/WebCore/dom/TreeScope.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/dom/TreeScope.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -104,7 +104,7 @@
// for an anchor with the given name. ID matching is always case sensitive, but
// Anchor name matching is case sensitive in strict mode and not case sensitive in
// quirks mode for historical compatibility reasons.
- Element* findAnchor(const String& name);
+ Element* findAnchor(StringView name);
ContainerNode& rootNode() const { return m_rootNode; }
Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (278668 => 278669)
--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm 2021-06-09 20:46:24 UTC (rev 278669)
@@ -168,7 +168,7 @@
bool DataDetection::canBePresentedByDataDetectors(const URL& url)
{
- return [PAL::softLink_DataDetectorsCore_DDURLTapAndHoldSchemes() containsObject:(NSString *)url.protocol().toStringWithoutCopying().convertToASCIILowercase()];
+ return [PAL::softLink_DataDetectorsCore_DDURLTapAndHoldSchemes() containsObject:(NSString *)url.protocol().convertToASCIILowercase()];
}
bool DataDetection::isDataDetectorLink(Element& element)
Modified: trunk/Source/WebCore/page/FrameView.cpp (278668 => 278669)
--- trunk/Source/WebCore/page/FrameView.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/page/FrameView.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -2209,7 +2209,7 @@
bool FrameView::scrollToFragment(const URL& url)
{
auto fragmentIdentifier = url.fragmentIdentifier();
- if (scrollToFragmentInternal(fragmentIdentifier.toString()))
+ if (scrollToFragmentInternal(fragmentIdentifier))
return true;
if (scrollToFragmentInternal(decodeURLEscapeSequences(fragmentIdentifier)))
@@ -2219,7 +2219,7 @@
return false;
}
-bool FrameView::scrollToFragmentInternal(const String& fragmentIdentifier)
+bool FrameView::scrollToFragmentInternal(StringView fragmentIdentifier)
{
// If our URL has no ref, then we have no place we need to jump to.
if (fragmentIdentifier.isNull())
Modified: trunk/Source/WebCore/page/FrameView.h (278668 => 278669)
--- trunk/Source/WebCore/page/FrameView.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/page/FrameView.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -809,7 +809,7 @@
void updateWidgetPositionsTimerFired();
- bool scrollToFragmentInternal(const String&);
+ bool scrollToFragmentInternal(StringView);
void scrollToAnchor();
void scrollPositionChanged(const ScrollPosition& oldPosition, const ScrollPosition& newPosition);
void scrollableAreaSetChanged();
Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (278668 => 278669)
--- trunk/Source/WebCore/page/SecurityOrigin.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -153,7 +153,7 @@
}
// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy (Editor's Draft, 17 November 2016)
-static bool shouldTreatAsPotentiallyTrustworthy(const String& protocol, const String& host)
+static bool shouldTreatAsPotentiallyTrustworthy(const String& protocol, StringView host)
{
if (LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(protocol))
return true;
Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (278668 => 278669)
--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -322,7 +322,7 @@
}
template<typename Predicate>
-ContentSecurityPolicy::HashInEnforcedAndReportOnlyPoliciesPair ContentSecurityPolicy::findHashOfContentInPolicies(Predicate&& predicate, const String& content, OptionSet<ContentSecurityPolicyHashAlgorithm> algorithms) const
+ContentSecurityPolicy::HashInEnforcedAndReportOnlyPoliciesPair ContentSecurityPolicy::findHashOfContentInPolicies(Predicate&& predicate, StringView content, OptionSet<ContentSecurityPolicyHashAlgorithm> algorithms) const
{
if (algorithms.isEmpty() || content.isEmpty())
return { false, false };
@@ -404,7 +404,7 @@
return allPoliciesWithDispositionAllow(ContentSecurityPolicy::Disposition::Enforce, &ContentSecurityPolicyDirectiveList::violatedDirectiveForStyleNonce, strippedNonce);
}
-bool ContentSecurityPolicy::allowInlineScript(const String& contextURL, const WTF::OrdinalNumber& contextLine, const String& scriptContent, bool overrideContentSecurityPolicy) const
+bool ContentSecurityPolicy::allowInlineScript(const String& contextURL, const WTF::OrdinalNumber& contextLine, StringView scriptContent, bool overrideContentSecurityPolicy) const
{
if (overrideContentSecurityPolicy)
return true;
@@ -427,7 +427,7 @@
return foundHashInEnforcedPolicies || allPoliciesWithDispositionAllow(ContentSecurityPolicy::Disposition::Enforce, handleViolatedDirective, &ContentSecurityPolicyDirectiveList::violatedDirectiveForUnsafeInlineScript);
}
-bool ContentSecurityPolicy::allowInlineStyle(const String& contextURL, const WTF::OrdinalNumber& contextLine, const String& styleContent, bool overrideContentSecurityPolicy) const
+bool ContentSecurityPolicy::allowInlineStyle(const String& contextURL, const WTF::OrdinalNumber& contextLine, StringView styleContent, bool overrideContentSecurityPolicy) const
{
if (overrideContentSecurityPolicy)
return true;
Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h (278668 => 278669)
--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -91,8 +91,8 @@
bool allowJavaScriptURLs(const String& contextURL, const WTF::OrdinalNumber& contextLine, bool overrideContentSecurityPolicy = false) const;
bool allowInlineEventHandlers(const String& contextURL, const WTF::OrdinalNumber& contextLine, bool overrideContentSecurityPolicy = false) const;
- bool allowInlineScript(const String& contextURL, const WTF::OrdinalNumber& contextLine, const String& scriptContent, bool overrideContentSecurityPolicy = false) const;
- bool allowInlineStyle(const String& contextURL, const WTF::OrdinalNumber& contextLine, const String& styleContent, bool overrideContentSecurityPolicy = false) const;
+ bool allowInlineScript(const String& contextURL, const WTF::OrdinalNumber& contextLine, StringView scriptContent, bool overrideContentSecurityPolicy = false) const;
+ bool allowInlineStyle(const String& contextURL, const WTF::OrdinalNumber& contextLine, StringView styleContent, bool overrideContentSecurityPolicy = false) const;
bool allowEval(JSC::JSGlobalObject*, bool overrideContentSecurityPolicy = false) const;
@@ -206,7 +206,7 @@
bool allowResourceFromSource(const URL&, RedirectResponseReceived, const char*, ResourcePredicate) const;
using HashInEnforcedAndReportOnlyPoliciesPair = std::pair<bool, bool>;
- template<typename Predicate> HashInEnforcedAndReportOnlyPoliciesPair findHashOfContentInPolicies(Predicate&&, const String& content, OptionSet<ContentSecurityPolicyHashAlgorithm>) const WARN_UNUSED_RETURN;
+ template<typename Predicate> HashInEnforcedAndReportOnlyPoliciesPair findHashOfContentInPolicies(Predicate&&, StringView content, OptionSet<ContentSecurityPolicyHashAlgorithm>) const WARN_UNUSED_RETURN;
void reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const URL& blockedURL, const String& consoleMessage, JSC::JSGlobalObject*) const;
void reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList&, const URL& blockedURL, const String& consoleMessage, JSC::JSGlobalObject* = nullptr) const;
Modified: trunk/Source/WebCore/platform/LegacySchemeRegistry.cpp (278668 => 278669)
--- trunk/Source/WebCore/platform/LegacySchemeRegistry.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/platform/LegacySchemeRegistry.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -253,7 +253,7 @@
bool LegacySchemeRegistry::schemeIsHandledBySchemeHandler(StringView scheme)
{
Locker locker { schemeRegistryLock };
- return schemesHandledBySchemeHandler().contains(scheme.toString());
+ return schemesHandledBySchemeHandler().contains(scheme.toStringWithoutCopying());
}
static URLSchemesMap& schemesAllowingDatabaseAccessInPrivateBrowsing()
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (278668 => 278669)
--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -446,7 +446,7 @@
auto slashLocation = codecID.find('/');
auto length = slashLocation == notFound ? codecID.length() - 2 : slashLocation - 2;
- m_codec = AtomString { codecID.substring(2, length).convertToASCIILowercase() };
+ m_codec = codecID.substring(2, length).convertToASCIILowercaseAtom();
return *m_codec;
}
bool isVideo() const final { return m_track.track_type.is_present() && m_track.track_type.value() == TrackType::kVideo; }
Modified: trunk/Source/WebCore/platform/network/ParsedContentType.cpp (278668 => 278669)
--- trunk/Source/WebCore/platform/network/ParsedContentType.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/platform/network/ParsedContentType.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -122,7 +122,7 @@
static bool containsNonTokenCharacters(StringView input, Mode mode)
{
if (mode == Mode::MimeSniff)
- return !isValidHTTPToken(input.toStringWithoutCopying());
+ return !isValidHTTPToken(input);
for (unsigned index = 0; index < input.length(); ++index) {
if (!isTokenCharacter(input[index]))
return true;
Modified: trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp (278668 => 278669)
--- trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -278,7 +278,7 @@
// which stores either UTF-16 or Latin1 data. This is unfortunate for performance
// reasons and we should consider switching to a more flexible hyphenation library
// if it is available.
- CString utf8StringCopy = string.toStringWithoutCopying().utf8();
+ CString utf8StringCopy = string.utf8();
// WebCore often passes strings like " wordtohyphenate" to the platform layer. Since
// libhyphen isn't advanced enough to deal with leading spaces (presumably CoreFoundation
Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (278668 => 278669)
--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -471,7 +471,7 @@
if (behavior.contains(RenderAsTextFlag::ShowIDAndClass)) {
if (Element* element = is<Element>(object.node()) ? downcast<Element>(object.node()) : nullptr) {
if (element->hasID())
- ts << " id=\"" + element->getIdAttribute() + "\"";
+ ts << " id=\"" << element->getIdAttribute() << "\"";
if (element->hasClass()) {
ts << " class=\"";
Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (278668 => 278669)
--- trunk/Source/WebCore/svg/SVGSVGElement.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -546,7 +546,7 @@
return transform;
}
-SVGViewElement* SVGSVGElement::findViewAnchor(const String& fragmentIdentifier) const
+SVGViewElement* SVGSVGElement::findViewAnchor(StringView fragmentIdentifier) const
{
auto* anchorElement = document().findAnchor(fragmentIdentifier);
return is<SVGViewElement>(anchorElement) ? downcast<SVGViewElement>(anchorElement): nullptr;
@@ -558,7 +558,7 @@
return is<SVGSVGElement>(viewportElement) ? downcast<SVGSVGElement>(viewportElement) : nullptr;
}
-SVGSVGElement* SVGSVGElement::findRootAnchor(const String& fragmentIdentifier) const
+SVGSVGElement* SVGSVGElement::findRootAnchor(StringView fragmentIdentifier) const
{
if (auto* viewElement = findViewAnchor(fragmentIdentifier))
return findRootAnchor(viewElement);
@@ -565,7 +565,7 @@
return nullptr;
}
-bool SVGSVGElement::scrollToFragment(const String& fragmentIdentifier)
+bool SVGSVGElement::scrollToFragment(StringView fragmentIdentifier)
{
auto renderer = this->renderer();
auto view = m_viewSpec;
@@ -616,7 +616,7 @@
rootElement->inheritViewAttributes(*viewElement);
if (auto* renderer = rootElement->renderer())
RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
- m_currentViewFragmentIdentifier = fragmentIdentifier;
+ m_currentViewFragmentIdentifier = fragmentIdentifier.toString();
return true;
}
}
Modified: trunk/Source/WebCore/svg/SVGSVGElement.h (278668 => 278669)
--- trunk/Source/WebCore/svg/SVGSVGElement.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/svg/SVGSVGElement.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -84,7 +84,7 @@
public:
static Ref<SVGSVGElement> create(const QualifiedName&, Document&);
static Ref<SVGSVGElement> create(Document&);
- bool scrollToFragment(const String& fragmentIdentifier);
+ bool scrollToFragment(StringView fragmentIdentifier);
void resetScrollAnchor();
using SVGGraphicsElement::ref;
@@ -141,9 +141,9 @@
RefPtr<Frame> frameForCurrentScale() const;
Ref<NodeList> collectIntersectionOrEnclosureList(SVGRect&, SVGElement*, bool (*checkFunction)(SVGElement&, SVGRect&));
- SVGViewElement* findViewAnchor(const String& fragmentIdentifier) const;
+ SVGViewElement* findViewAnchor(StringView fragmentIdentifier) const;
SVGSVGElement* findRootAnchor(const SVGViewElement*) const;
- SVGSVGElement* findRootAnchor(const String&) const;
+ SVGSVGElement* findRootAnchor(StringView) const;
bool m_useCurrentView { false };
Ref<SMILTimeContainer> m_timeContainer;
Modified: trunk/Source/WebCore/svg/SVGViewSpec.cpp (278668 => 278669)
--- trunk/Source/WebCore/svg/SVGViewSpec.cpp 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/svg/SVGViewSpec.cpp 2021-06-09 20:46:24 UTC (rev 278669)
@@ -68,7 +68,7 @@
template<typename CharacterType> static constexpr CharacterType zoomAndPanSpec[] = {'z', 'o', 'o', 'm', 'A', 'n', 'd', 'P', 'a', 'n'};
template<typename CharacterType> static constexpr CharacterType viewTargetSpec[] = {'v', 'i', 'e', 'w', 'T', 'a', 'r', 'g', 'e', 't'};
-bool SVGViewSpec::parseViewSpec(const StringView& string)
+bool SVGViewSpec::parseViewSpec(StringView string)
{
return readCharactersForParsing(string, [&](auto buffer) -> bool {
using CharacterType = typename decltype(buffer)::CharacterType;
Modified: trunk/Source/WebCore/svg/SVGViewSpec.h (278668 => 278669)
--- trunk/Source/WebCore/svg/SVGViewSpec.h 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebCore/svg/SVGViewSpec.h 2021-06-09 20:46:24 UTC (rev 278669)
@@ -36,7 +36,7 @@
return adoptRef(*new SVGViewSpec(contextElement));
}
- bool parseViewSpec(const StringView&);
+ bool parseViewSpec(StringView);
void reset();
void resetContextElement() { m_contextElement = nullptr; }
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (278668 => 278669)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2021-06-09 19:53:39 UTC (rev 278668)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2021-06-09 20:46:24 UTC (rev 278669)
@@ -565,7 +565,7 @@
if ([WKWebView handlesURLScheme:urlScheme])
[NSException raise:NSInvalidArgumentException format:@"'%@' is a URL scheme that WKWebView handles natively", urlScheme];
- auto canonicalScheme = WTF::URLParser::maybeCanonicalizeScheme(urlScheme);
+ auto canonicalScheme = WTF::URLParser::maybeCanonicalizeScheme(String(urlScheme));
if (!canonicalScheme)
[NSException raise:NSInvalidArgumentException format:@"'%@' is not a valid URL scheme", urlScheme];
@@ -577,7 +577,7 @@
- (id <WKURLSchemeHandler>)urlSchemeHandlerForURLScheme:(NSString *)urlScheme
{
- auto canonicalScheme = WTF::URLParser::maybeCanonicalizeScheme(urlScheme);
+ auto canonicalScheme = WTF::URLParser::maybeCanonicalizeScheme(String(urlScheme));
if (!canonicalScheme)
return nil;