Diff
Modified: trunk/Source/WTF/ChangeLog (291901 => 291902)
--- trunk/Source/WTF/ChangeLog 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WTF/ChangeLog 2022-03-25 23:42:25 UTC (rev 291902)
@@ -1,3 +1,20 @@
+2022-03-25 Chris Dumez <[email protected]>
+
+ Use StringView::split() instead of String::split() in more places
+ https://bugs.webkit.org/show_bug.cgi?id=238362
+
+ Reviewed by Geoffrey Garen.
+
+ Use StringView::split() instead of String::split() where suitable and more efficient.
+
+ * wtf/Assertions.cpp:
+ * wtf/text/StringView.cpp:
+ (WTF::StringView::stripWhiteSpace const):
+ * wtf/text/StringView.h:
+ (WTF::StringView::toDouble const):
+ (WTF::StringView::stripLeadingAndTrailingMatchedCharacters const):
+ (WTF::StringView::stripLeadingAndTrailingMatchedCharacters): Deleted.
+
2022-03-25 Antoine Quint <[email protected]>
[web-animations] enable support for mutable timelines by default
Modified: trunk/Source/WTF/wtf/Assertions.cpp (291901 => 291902)
--- trunk/Source/WTF/wtf/Assertions.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WTF/wtf/Assertions.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -548,10 +548,14 @@
}
#endif
- for (auto& logLevelComponent : String(logLevel).split(',')) {
- Vector<String> componentInfo = logLevelComponent.split('=');
- String component = componentInfo[0].stripWhiteSpace();
+ for (auto logLevelComponent : StringView(logLevel).split(',')) {
+ auto componentInfo = logLevelComponent.split('=');
+ auto it = componentInfo.begin();
+ if (it == componentInfo.end())
+ continue;
+ auto component = (*it).stripWhiteSpace();
+
WTFLogChannelState logChannelState = WTFLogChannelState::On;
if (component.startsWith('-')) {
logChannelState = WTFLogChannelState::Off;
@@ -564,8 +568,8 @@
}
WTFLogLevel logChannelLevel = WTFLogLevel::Error;
- if (componentInfo.size() > 1) {
- String level = componentInfo[1].stripWhiteSpace();
+ if (++it != componentInfo.end()) {
+ auto level = (*it).stripWhiteSpace();
if (equalLettersIgnoringASCIICase(level, "error"))
logChannelLevel = WTFLogLevel::Error;
else if (equalLettersIgnoringASCIICase(level, "warning"))
Modified: trunk/Source/WTF/wtf/text/StringView.cpp (291901 => 291902)
--- trunk/Source/WTF/wtf/text/StringView.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WTF/wtf/text/StringView.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -354,6 +354,11 @@
return find(string) != notFound;
}
+StringView StringView::stripWhiteSpace() const
+{
+ return stripLeadingAndTrailingMatchedCharacters(isASCIISpace<UChar>);
+}
+
int codePointCompare(StringView lhs, StringView rhs)
{
bool lhsIs8Bit = lhs.is8Bit();
Modified: trunk/Source/WTF/wtf/text/StringView.h (291901 => 291902)
--- trunk/Source/WTF/wtf/text/StringView.h 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WTF/wtf/text/StringView.h 2022-03-25 23:42:25 UTC (rev 291902)
@@ -131,7 +131,8 @@
StringView right(unsigned length) const { return substring(this->length() - length, length); }
template<typename MatchedCharacterPredicate>
- StringView stripLeadingAndTrailingMatchedCharacters(const MatchedCharacterPredicate&);
+ StringView stripLeadingAndTrailingMatchedCharacters(const MatchedCharacterPredicate&) const;
+ WTF_EXPORT_PRIVATE StringView stripWhiteSpace() const;
class SplitResult;
SplitResult split(UChar) const;
@@ -171,6 +172,7 @@
WTF_EXPORT_PRIVATE bool endsWithIgnoringASCIICase(StringView) const;
float toFloat(bool& isValid) const;
+ double toDouble(bool& isValid) const;
static void invalidate(const StringImpl&);
@@ -184,7 +186,7 @@
void initialize(const UChar*, unsigned length);
template<typename CharacterType, typename MatchedCharacterPredicate>
- StringView stripLeadingAndTrailingMatchedCharacters(const CharacterType*, const MatchedCharacterPredicate&);
+ StringView stripLeadingAndTrailingMatchedCharacters(const CharacterType*, const MatchedCharacterPredicate&) const;
#if CHECK_STRINGVIEW_LIFETIME
WTF_EXPORT_PRIVATE bool underlyingStringIsValid() const;
@@ -584,6 +586,13 @@
return charactersToFloat(characters16(), m_length, &isValid);
}
+inline double StringView::toDouble(bool& isValid) const
+{
+ if (is8Bit())
+ return charactersToDouble(characters8(), m_length, &isValid);
+ return charactersToDouble(characters16(), m_length, &isValid);
+}
+
inline String StringView::toStringWithoutCopying() const
{
if (is8Bit())
@@ -1036,7 +1045,7 @@
}
template<typename CharacterType, typename MatchedCharacterPredicate>
-inline StringView StringView::stripLeadingAndTrailingMatchedCharacters(const CharacterType* characters, const MatchedCharacterPredicate& predicate)
+inline StringView StringView::stripLeadingAndTrailingMatchedCharacters(const CharacterType* characters, const MatchedCharacterPredicate& predicate) const
{
if (!m_length)
return *this;
@@ -1062,7 +1071,7 @@
}
template<typename MatchedCharacterPredicate>
-StringView StringView::stripLeadingAndTrailingMatchedCharacters(const MatchedCharacterPredicate& predicate)
+StringView StringView::stripLeadingAndTrailingMatchedCharacters(const MatchedCharacterPredicate& predicate) const
{
if (is8Bit())
return stripLeadingAndTrailingMatchedCharacters<LChar>(characters8(), predicate);
Modified: trunk/Source/WebCore/ChangeLog (291901 => 291902)
--- trunk/Source/WebCore/ChangeLog 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/ChangeLog 2022-03-25 23:42:25 UTC (rev 291902)
@@ -1,3 +1,47 @@
+2022-03-25 Chris Dumez <[email protected]>
+
+ Use StringView::split() instead of String::split() in more places
+ https://bugs.webkit.org/show_bug.cgi?id=238362
+
+ Reviewed by Geoffrey Garen.
+
+ Use StringView::split() instead of String::split() where suitable and more efficient.
+
+ * Modules/applepay/cocoa/PaymentContactCocoa.mm:
+ (WebCore::convert):
+ * html/HTMLInputElement.cpp:
+ (WebCore::isValidMIMEType):
+ (WebCore::isValidFileExtension):
+ (WebCore::parseAcceptAttribute):
+ * html/ValidationMessage.cpp:
+ (WebCore::ValidationMessage::setMessageDOMAndStartTimer):
+ * html/canvas/WebGLRenderingContextBase.cpp:
+ (WebCore::WebGLRenderingContextBase::compileShader):
+ * inspector/agents/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::nodeForPath):
+ * page/WindowFeatures.cpp:
+ (WebCore::parseDisabledAdaptations):
+ (WebCore::parseDialogFeatures):
+ (WebCore::parseDialogFeaturesMap):
+ * page/WindowFeatures.h:
+ * platform/network/CacheValidation.cpp:
+ (WebCore::collectVaryingRequestHeadersInternal):
+ * platform/network/HTTPParsers.cpp:
+ (WebCore::filenameFromHTTPContentDisposition):
+ (WebCore::parseXFrameOptionsHeader):
+ * platform/network/HTTPParsers.h:
+ * platform/network/ResourceResponseBase.cpp:
+ (WebCore::ResourceResponseBase::isAttachmentWithFilename const):
+ * svg/SVGToOTFFontConversion.cpp:
+ (WebCore::SVGToOTFFontConverter::appendOS2Table):
+ * svg/animation/SVGSMILElement.cpp:
+ (WebCore::SVGSMILElement::parseOffsetValue):
+ (WebCore::SVGSMILElement::parseClockValue):
+ (WebCore::SVGSMILElement::parseCondition):
+ (WebCore::SVGSMILElement::parseBeginOrEnd):
+ (WebCore::SVGSMILElement::parseAttribute):
+ * svg/animation/SVGSMILElement.h:
+
2022-03-25 Alexander Mikhaylenko <[email protected]>
[GTK][WPE] Update widget style to match libadwaita
Modified: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm (291901 => 291902)
--- trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm 2022-03-25 23:42:25 UTC (rev 291902)
@@ -137,10 +137,8 @@
}
CNPostalAddress *postalAddress = contact.postalAddress;
- if (postalAddress.street.length) {
- Vector<String> addressLines = String(postalAddress.street).split('\n');
- result.addressLines = WTFMove(addressLines);
- }
+ if (postalAddress.street.length)
+ result.addressLines = String(postalAddress.street).split('\n');
result.subLocality = postalAddress.subLocality;
result.locality = postalAddress.city;
result.postalCode = postalAddress.postalCode;
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (291901 => 291902)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -1320,7 +1320,7 @@
return isASCII(ch) && ch > ' ' && ch != '"' && ch != '(' && ch != ')' && ch != ',' && ch != '/' && (ch < ':' || ch > '@') && (ch < '[' || ch > ']') && ch != '{' && ch != '}' && ch != 0x7f;
}
-static bool isValidMIMEType(const String& type)
+static bool isValidMIMEType(StringView type)
{
size_t slashPosition = type.find('/');
if (slashPosition == notFound || !slashPosition || slashPosition == type.length() - 1)
@@ -1332,7 +1332,7 @@
return true;
}
-static bool isValidFileExtension(const String& type)
+static bool isValidFileExtension(StringView type)
{
if (type.length() < 2)
return false;
@@ -1339,14 +1339,14 @@
return type[0] == '.';
}
-static Vector<String> parseAcceptAttribute(const String& acceptString, bool (*predicate)(const String&))
+static Vector<String> parseAcceptAttribute(StringView acceptString, bool (*predicate)(StringView))
{
Vector<String> types;
if (acceptString.isEmpty())
return types;
- for (auto& splitType : acceptString.split(',')) {
- String trimmedType = stripLeadingAndTrailingHTMLSpaces(splitType);
+ for (auto splitType : acceptString.split(',')) {
+ auto trimmedType = splitType.stripLeadingAndTrailingMatchedCharacters(isHTMLSpace<UChar>);
if (trimmedType.isEmpty())
continue;
if (!predicate(trimmedType))
Modified: trunk/Source/WebCore/html/ValidationMessage.cpp (291901 => 291902)
--- trunk/Source/WebCore/html/ValidationMessage.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/html/ValidationMessage.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -131,15 +131,18 @@
ASSERT(m_messageBody);
m_messageHeading->removeChildren();
m_messageBody->removeChildren();
- Vector<String> lines = m_message.split('\n');
- Document& document = m_messageHeading->document();
- for (unsigned i = 0; i < lines.size(); ++i) {
- if (i) {
- m_messageBody->appendChild(Text::create(document, lines[i]));
- if (i < lines.size() - 1)
+
+ auto& document = m_messageHeading->document();
+ auto lines = StringView(m_message).split('\n');
+ auto it = lines.begin();
+ if (it != lines.end()) {
+ m_messageHeading->setInnerText((*it).toString());
+ auto firstBodyLineIterator = ++it;
+ for (; it != lines.end(); ++it) {
+ if (it != firstBodyLineIterator)
m_messageBody->appendChild(HTMLBRElement::create(document));
- } else
- m_messageHeading->setInnerText(lines[i]);
+ m_messageBody->appendChild(Text::create(document, (*it).toString()));
+ }
}
int magnification = document.page() ? document.page()->settings().validationMessageTimerMagnification() : -1;
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (291901 => 291902)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -1984,7 +1984,8 @@
if (canvas && m_synthesizedErrorsToConsole && !value) {
Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSExecState::currentState());
- for (auto& error : getShaderInfoLog(shader).split('\n'))
+ auto errors = getShaderInfoLog(shader);
+ for (auto error : StringView(errors).split('\n'))
canvas->document().addConsoleMessage(makeUnique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, MessageLevel::Error, "WebGL: " + error, stackTrace.copyRef()));
}
}
Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (291901 => 291902)
--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -2895,12 +2895,16 @@
return nullptr;
Node* node = m_document.get();
- Vector<String> pathTokens = path.split(',');
- if (!pathTokens.size())
+ auto pathTokens = StringView(path).split(',');
+ auto it = pathTokens.begin();
+ if (it == pathTokens.end())
return nullptr;
- for (size_t i = 0; i < pathTokens.size() - 1; i += 2) {
- auto childNumber = parseIntegerAllowingTrailingJunk<unsigned>(pathTokens[i]);
+ for (; it != pathTokens.end(); ++it) {
+ auto childNumberView = *it;
+ if (++it == pathTokens.end())
+ break;
+ auto childNumber = parseIntegerAllowingTrailingJunk<unsigned>(childNumberView);
if (!childNumber)
return nullptr;
@@ -2917,11 +2921,12 @@
child = innerNextSibling(child);
}
- const auto& childName = pathTokens[i + 1];
+ auto childName = *it;
if (!child || child->nodeName() != childName)
return nullptr;
node = child;
}
+
return node;
}
Modified: trunk/Source/WebCore/page/WindowFeatures.cpp (291901 => 291902)
--- trunk/Source/WebCore/page/WindowFeatures.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/page/WindowFeatures.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -37,7 +37,7 @@
static void setWindowFeature(WindowFeatures&, StringView key, StringView value);
-static DialogFeaturesMap parseDialogFeaturesMap(const String&);
+static DialogFeaturesMap parseDialogFeaturesMap(StringView);
static std::optional<bool> boolFeature(const DialogFeaturesMap&, const char* key);
static std::optional<float> floatFeature(const DialogFeaturesMap&, const char* key, float min, float max);
@@ -115,12 +115,12 @@
}
}
-OptionSet<DisabledAdaptations> parseDisabledAdaptations(const String& disabledAdaptationsString)
+OptionSet<DisabledAdaptations> parseDisabledAdaptations(StringView disabledAdaptationsString)
{
OptionSet<DisabledAdaptations> disabledAdaptations;
- for (auto& name : disabledAdaptationsString.split(',')) {
- auto normalizedName = name.stripWhiteSpace().convertToASCIILowercase();
- if (normalizedName == watchAdaptationName())
+ for (auto name : disabledAdaptationsString.split(',')) {
+ auto trimmedName = name.stripWhiteSpace();
+ if (equalIgnoringASCIICase(trimmedName, watchAdaptationName()))
disabledAdaptations.add(DisabledAdaptations::Watch);
}
return disabledAdaptations;
@@ -166,7 +166,7 @@
features.additionalFeatures.append(key.toString());
}
-WindowFeatures parseDialogFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect)
+WindowFeatures parseDialogFeatures(StringView dialogFeaturesString, const FloatRect& screenAvailableRect)
{
auto featuresMap = parseDialogFeaturesMap(dialogFeaturesString);
@@ -242,7 +242,7 @@
return static_cast<int>(parsedNumber);
}
-static DialogFeaturesMap parseDialogFeaturesMap(const String& string)
+static DialogFeaturesMap parseDialogFeaturesMap(StringView string)
{
// FIXME: Not clear why we take such a different approach to parsing dialog features
// as opposed to window features (using a map, different parsing quirks).
@@ -249,7 +249,7 @@
DialogFeaturesMap features;
- for (auto& featureString : string.split(';')) {
+ for (auto featureString : string.split(';')) {
size_t separatorPosition = featureString.find('=');
size_t colonPosition = featureString.find(':');
if (separatorPosition != notFound && colonPosition != notFound)
@@ -257,16 +257,16 @@
if (separatorPosition == notFound)
separatorPosition = colonPosition;
- String key = featureString.left(separatorPosition).stripWhiteSpace();
+ auto key = featureString.left(separatorPosition).stripWhiteSpace().toString();
// Null string for value indicates key without value.
String value;
if (separatorPosition != notFound) {
- value = featureString.substring(separatorPosition + 1).stripWhiteSpace();
- value = value.left(value.find(' '));
+ auto valueView = featureString.substring(separatorPosition + 1).stripWhiteSpace();
+ value = valueView.left(valueView.find(' ')).toString();
}
- features.set(key, value);
+ features.set(WTFMove(key), WTFMove(value));
}
return features;
Modified: trunk/Source/WebCore/page/WindowFeatures.h (291901 => 291902)
--- trunk/Source/WebCore/page/WindowFeatures.h 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/page/WindowFeatures.h 2022-03-25 23:42:25 UTC (rev 291902)
@@ -60,8 +60,8 @@
};
WindowFeatures parseWindowFeatures(StringView windowFeaturesString);
-WindowFeatures parseDialogFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect);
-OptionSet<DisabledAdaptations> parseDisabledAdaptations(const String&);
+WindowFeatures parseDialogFeatures(StringView dialogFeaturesString, const FloatRect& screenAvailableRect);
+OptionSet<DisabledAdaptations> parseDisabledAdaptations(StringView);
enum class FeatureMode { Window, Viewport };
void processFeaturesString(StringView features, FeatureMode, const Function<void(StringView type, StringView value)>& callback);
Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (291901 => 291902)
--- trunk/Source/WebCore/platform/network/CacheValidation.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -366,10 +366,13 @@
auto varyValue = response.httpHeaderField(HTTPHeaderName::Vary);
if (varyValue.isEmpty())
return { };
- return varyValue.split(',').map([&](auto& varyHeaderName) {
- auto headerName = varyHeaderName.stripWhiteSpace();
- return std::make_pair(headerName, headerValueForVaryFunction(headerName));
- });
+
+ Vector<std::pair<String, String>> headers;
+ for (auto varyHeaderName : StringView(varyValue).split(',')) {
+ auto headerName = varyHeaderName.stripWhiteSpace().toString();
+ headers.append(std::pair { headerName, headerValueForVaryFunction(headerName) });
+ }
+ return headers;
}
Vector<std::pair<String, String>> collectVaryingRequestHeaders(NetworkStorageSession* storageSession, const ResourceRequest& request, const ResourceResponse& response)
Modified: trunk/Source/WebCore/platform/network/HTTPParsers.cpp (291901 => 291902)
--- trunk/Source/WebCore/platform/network/HTTPParsers.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -335,25 +335,25 @@
// that arises from quoted-string, nor does this function properly unquote
// attribute values. Further this function appears to process parameter names
// in a case-sensitive manner. (There are likely other bugs as well.)
-String filenameFromHTTPContentDisposition(const String& value)
+String filenameFromHTTPContentDisposition(StringView value)
{
- for (auto& keyValuePair : value.split(';')) {
+ for (auto keyValuePair : value.split(';')) {
size_t valueStartPos = keyValuePair.find('=');
if (valueStartPos == notFound)
continue;
- String key = keyValuePair.left(valueStartPos).stripWhiteSpace();
+ auto key = keyValuePair.left(valueStartPos).stripWhiteSpace();
if (key.isEmpty() || key != "filename")
continue;
- String value = keyValuePair.substring(valueStartPos + 1).stripWhiteSpace();
+ auto value = keyValuePair.substring(valueStartPos + 1).stripWhiteSpace();
// Remove quotes if there are any
- if (value[0] == '\"')
+ if (value.length() > 1 && value[0] == '\"')
value = value.substring(1, value.length() - 2);
- return value;
+ return value.toString();
}
return String();
@@ -552,7 +552,7 @@
return view.substring(spacePos + 1).toAtomString();
}
-XFrameOptionsDisposition parseXFrameOptionsHeader(const String& header)
+XFrameOptionsDisposition parseXFrameOptionsHeader(StringView header)
{
XFrameOptionsDisposition result = XFrameOptionsDisposition::None;
@@ -559,7 +559,7 @@
if (header.isEmpty())
return result;
- for (auto& currentHeader : header.split(',')) {
+ for (auto currentHeader : header.split(',')) {
currentHeader = currentHeader.stripWhiteSpace();
XFrameOptionsDisposition currentValue = XFrameOptionsDisposition::None;
if (equalLettersIgnoringASCIICase(currentHeader, "deny"))
Modified: trunk/Source/WebCore/platform/network/HTTPParsers.h (291901 => 291902)
--- trunk/Source/WebCore/platform/network/HTTPParsers.h 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.h 2022-03-25 23:42:25 UTC (rev 291902)
@@ -79,12 +79,12 @@
bool isValidHTTPToken(const String&);
bool isValidHTTPToken(StringView);
std::optional<WallTime> parseHTTPDate(const String&);
-String filenameFromHTTPContentDisposition(const String&);
+String filenameFromHTTPContentDisposition(StringView);
WEBCORE_EXPORT String extractMIMETypeFromMediaType(const String&);
String extractCharsetFromMediaType(const String&);
XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL);
AtomString extractReasonPhraseFromHTTPStatusLine(const String&);
-WEBCORE_EXPORT XFrameOptionsDisposition parseXFrameOptionsHeader(const String&);
+WEBCORE_EXPORT XFrameOptionsDisposition parseXFrameOptionsHeader(StringView);
std::optional<std::pair<StringView, HashMap<String, String>>> parseStructuredFieldValue(StringView header);
// -1 could be set to one of the return parameters to indicate the value is not specified.
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (291901 => 291902)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -783,10 +783,11 @@
if (contentDisposition.isNull())
return false;
- if (!equalLettersIgnoringASCIICase(contentDisposition.left(contentDisposition.find(';')).stripWhiteSpace(), "attachment"))
+ StringView contentDispositionView { contentDisposition };
+ if (!equalLettersIgnoringASCIICase(contentDispositionView.left(contentDispositionView.find(';')).stripWhiteSpace(), "attachment"))
return false;
- String filename = filenameFromHTTPContentDisposition(contentDisposition);
+ String filename = filenameFromHTTPContentDisposition(contentDispositionView);
return !filename.isNull();
}
Modified: trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp (291901 => 291902)
--- trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -519,12 +519,14 @@
const unsigned panoseSize = 10;
char panoseBytes[panoseSize];
if (m_fontFaceElement) {
- Vector<String> segments = m_fontFaceElement->attributeWithoutSynchronization(SVGNames::panose_1Attr).string().split(' ');
- if (segments.size() == panoseSize) {
- for (auto& segment : segments) {
- if (auto value = parseIntegerAllowingTrailingJunk<uint8_t>(segment))
- panoseBytes[numPanoseBytes++] = *value;
+ auto segments = StringView(m_fontFaceElement->attributeWithoutSynchronization(SVGNames::panose_1Attr)).split(' ');
+ for (auto segment : segments) {
+ if (numPanoseBytes == panoseSize) {
+ ++numPanoseBytes;
+ break;
}
+ if (auto value = parseIntegerAllowingTrailingJunk<uint8_t>(segment))
+ panoseBytes[numPanoseBytes++] = *value;
}
}
if (numPanoseBytes != panoseSize)
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (291901 => 291902)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -312,35 +312,35 @@
return attributeName() != anyQName();
}
-SMILTime SVGSMILElement::parseOffsetValue(const String& data)
+SMILTime SVGSMILElement::parseOffsetValue(StringView data)
{
bool ok;
double result = 0;
- String parse = data.stripWhiteSpace();
+ auto parse = data.stripWhiteSpace();
if (parse.endsWith('h'))
- result = parse.left(parse.length() - 1).toDouble(&ok) * 60 * 60;
+ result = parse.left(parse.length() - 1).toDouble(ok) * 60 * 60;
else if (parse.endsWith("min"))
- result = parse.left(parse.length() - 3).toDouble(&ok) * 60;
+ result = parse.left(parse.length() - 3).toDouble(ok) * 60;
else if (parse.endsWith("ms"))
- result = parse.left(parse.length() - 2).toDouble(&ok) / 1000;
+ result = parse.left(parse.length() - 2).toDouble(ok) / 1000;
else if (parse.endsWith('s'))
- result = parse.left(parse.length() - 1).toDouble(&ok);
+ result = parse.left(parse.length() - 1).toDouble(ok);
else
- result = parse.toDouble(&ok);
+ result = parse.toDouble(ok);
if (!ok || !SMILTime(result).isFinite())
return SMILTime::unresolved();
return result;
}
-SMILTime SVGSMILElement::parseClockValue(const String& data)
+SMILTime SVGSMILElement::parseClockValue(StringView data)
{
if (data.isNull())
return SMILTime::unresolved();
- String parse = data.stripWhiteSpace();
+ auto parse = data.stripWhiteSpace();
static MainThreadNeverDestroyed<const AtomString> indefiniteValue("indefinite", AtomString::ConstructFromLiteral);
- if (parse == indefiniteValue)
+ if (parse == indefiniteValue.get())
return SMILTime::indefinite();
double result = 0;
@@ -348,16 +348,16 @@
size_t doublePointOne = parse.find(':');
size_t doublePointTwo = parse.find(':', doublePointOne + 1);
if (doublePointOne == 2 && doublePointTwo == 5 && parse.length() >= 8) {
- auto hour = parseInteger<uint8_t>(StringView { parse }.substring(0, 2));
- auto minute = parseInteger<uint8_t>(StringView { parse }.substring(3, 2));
+ auto hour = parseInteger<uint8_t>(parse.substring(0, 2));
+ auto minute = parseInteger<uint8_t>(parse.substring(3, 2));
if (!hour || !minute)
return SMILTime::unresolved();
- result = *hour * 60 * 60 + *minute * 60 + parse.substring(6).toDouble(&ok);
+ result = *hour * 60 * 60 + *minute * 60 + parse.substring(6).toDouble(ok);
} else if (doublePointOne == 2 && doublePointTwo == notFound && parse.length() >= 5) {
- auto minute = parseInteger<uint8_t>(StringView { parse }.substring(0, 2));
+ auto minute = parseInteger<uint8_t>(parse.substring(0, 2));
if (!minute)
return SMILTime::unresolved();
- result = *minute * 60 + parse.substring(3).toDouble(&ok);
+ result = *minute * 60 + parse.substring(3).toDouble(ok);
} else
return parseOffsetValue(parse);
if (!ok || !SMILTime(result).isFinite())
@@ -370,9 +370,9 @@
std::sort(timeList.begin(), timeList.end());
}
-bool SVGSMILElement::parseCondition(const String& value, BeginOrEnd beginOrEnd)
+bool SVGSMILElement::parseCondition(StringView value, BeginOrEnd beginOrEnd)
{
- String parseString = value.stripWhiteSpace();
+ auto parseString = value.stripWhiteSpace();
double sign = 1.;
size_t pos = parseString.find('+');
@@ -381,13 +381,13 @@
if (pos != notFound)
sign = -1.;
}
- String conditionString;
+ StringView conditionString;
SMILTime offset = 0;
if (pos == notFound)
conditionString = parseString;
else {
conditionString = parseString.left(pos).stripWhiteSpace();
- String offsetString = parseString.substring(pos + 1).stripWhiteSpace();
+ auto offsetString = parseString.substring(pos + 1).stripWhiteSpace();
offset = parseOffsetValue(offsetString);
if (offset.isUnresolved())
return false;
@@ -397,22 +397,23 @@
return false;
pos = conditionString.find('.');
- String baseID;
- String nameString;
+ StringView baseID;
+ StringView nameView;
if (pos == notFound)
- nameString = conditionString;
+ nameView = conditionString;
else {
baseID = conditionString.left(pos);
- nameString = conditionString.substring(pos + 1);
+ nameView = conditionString.substring(pos + 1);
}
- if (nameString.isEmpty())
+ if (nameView.isEmpty())
return false;
+ String nameString;
Condition::Type type;
int repeats = -1;
- if (nameString.startsWith("repeat(") && nameString.endsWith(')')) {
+ if (nameView.startsWith("repeat(") && nameView.endsWith(')')) {
// FIXME: For repeat events we just need to add the data carrying TimeEvent class and fire the events at appropiate times.
- auto parsedRepeat = parseInteger<unsigned>(StringView { nameString }.substring(7, nameString.length() - 8));
+ auto parsedRepeat = parseInteger<unsigned>(nameView.substring(7, nameView.length() - 8));
if (!parsedRepeat)
return false;
// FIXME: By assigning an unsigned to a signed, this can turn large integers into negative numbers.
@@ -419,17 +420,21 @@
repeats = *parsedRepeat;
nameString = "repeat"_s;
type = Condition::EventBase;
- } else if (nameString == "begin" || nameString == "end") {
+ } else if (nameView == "begin" || nameView == "end") {
if (baseID.isEmpty())
return false;
type = Condition::Syncbase;
- } else if (nameString.startsWith("accesskey(")) {
+ nameString = nameView.toString();
+ } else if (nameView.startsWith("accesskey(")) {
// FIXME: accesskey() support.
type = Condition::AccessKey;
- } else
+ nameString = nameView.toString();
+ } else {
type = Condition::EventBase;
+ nameString = nameView.toString();
+ }
- m_conditions.append(Condition(type, beginOrEnd, baseID, nameString, offset, repeats));
+ m_conditions.append(Condition(type, beginOrEnd, baseID.toString(), WTFMove(nameString), offset, repeats));
if (type == Condition::EventBase && beginOrEnd == End)
m_hasEndEventConditions = true;
@@ -437,7 +442,7 @@
return true;
}
-void SVGSMILElement::parseBeginOrEnd(const String& parseString, BeginOrEnd beginOrEnd)
+void SVGSMILElement::parseBeginOrEnd(StringView parseString, BeginOrEnd beginOrEnd)
{
Vector<SMILTimeWithOrigin>& timeList = beginOrEnd == Begin ? m_beginTimes : m_endTimes;
if (beginOrEnd == End)
@@ -445,7 +450,7 @@
HashSet<double> existing;
for (auto& time : timeList)
existing.add(time.time().value());
- for (auto& string : parseString.split(';')) {
+ for (auto string : parseString.split(';')) {
SMILTime value = parseClockValue(string);
if (value.isUnresolved())
parseCondition(string, beginOrEnd);
@@ -480,7 +485,7 @@
m_conditions.clear();
parseBeginOrEnd(attributeWithoutSynchronization(SVGNames::endAttr), End);
}
- parseBeginOrEnd(value.string(), Begin);
+ parseBeginOrEnd(value, Begin);
if (isConnected())
connectConditions();
} else if (name == SVGNames::endAttr) {
@@ -489,7 +494,7 @@
m_conditions.clear();
parseBeginOrEnd(attributeWithoutSynchronization(SVGNames::beginAttr), Begin);
}
- parseBeginOrEnd(value.string(), End);
+ parseBeginOrEnd(value, End);
if (isConnected())
connectConditions();
} else if (name == SVGNames::onendAttr)
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (291901 => 291902)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2022-03-25 23:42:25 UTC (rev 291902)
@@ -87,8 +87,8 @@
void reset();
- static SMILTime parseClockValue(const String&);
- static SMILTime parseOffsetValue(const String&);
+ static SMILTime parseClockValue(StringView);
+ static SMILTime parseOffsetValue(StringView);
bool isContributing(SMILTime elapsed) const;
bool isInactive() const;
@@ -160,8 +160,8 @@
RefPtr<Element> m_syncbase;
RefPtr<ConditionEventListener> m_eventListener;
};
- bool parseCondition(const String&, BeginOrEnd beginOrEnd);
- void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd);
+ bool parseCondition(StringView, BeginOrEnd);
+ void parseBeginOrEnd(StringView, BeginOrEnd);
Element* eventBaseFor(const Condition&);
void disconnectConditions();
Modified: trunk/Source/WebKit/ChangeLog (291901 => 291902)
--- trunk/Source/WebKit/ChangeLog 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebKit/ChangeLog 2022-03-25 23:42:25 UTC (rev 291902)
@@ -1,3 +1,20 @@
+2022-03-25 Chris Dumez <[email protected]>
+
+ Use StringView::split() instead of String::split() in more places
+ https://bugs.webkit.org/show_bug.cgi?id=238362
+
+ Reviewed by Geoffrey Garen.
+
+ Use StringView::split() instead of String::split() where suitable and more efficient.
+
+ * Shared/mac/AuxiliaryProcessMac.mm:
+ (WebKit::parseOSVersion):
+ (WebKit::populateSandboxInitializationParameters):
+ * UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm:
+ (WebKit::ProcessLauncher::launchProcess):
+ * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
+ (WebKit::RemoteGraphicsContextGLProxy::initialize):
+
2022-03-25 Elliott Williams <[email protected]>
[Big Sur] WK2 failing to build with `error: reference to 'WebDocumentView' is ambiguous`
Modified: trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm (291901 => 291902)
--- trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm 2022-03-25 23:42:25 UTC (rev 291902)
@@ -657,17 +657,27 @@
return makeString([[NSBundle mainBundle] bundleIdentifier], '+', clientIdentifier);
}
+static StringView parseOSVersion(StringView osSystemMarketingVersion)
+{
+ auto firstDotIndex = osSystemMarketingVersion.find('.');
+ if (firstDotIndex == notFound)
+ return { };
+ auto secondDotIndex = osSystemMarketingVersion.find('.', firstDotIndex + 1);
+ if (secondDotIndex == notFound)
+ return osSystemMarketingVersion;
+ return osSystemMarketingVersion.left(secondDotIndex);
+}
+
static void populateSandboxInitializationParameters(SandboxInitializationParameters& sandboxParameters)
{
RELEASE_ASSERT(!sandboxParameters.userDirectorySuffix().isNull());
String osSystemMarketingVersion = systemMarketingVersion();
- Vector<String> osVersionParts = osSystemMarketingVersion.split('.');
- if (osVersionParts.size() < 2) {
+ auto osVersion = parseOSVersion(osSystemMarketingVersion);
+ if (osVersion.isNull()) {
WTFLogAlways("%s: Couldn't find OS Version\n", getprogname());
exit(EX_NOPERM);
}
- String osVersion = osVersionParts[0] + '.' + osVersionParts[1];
sandboxParameters.addParameter("_OS_VERSION", osVersion.utf8().data());
// Use private temporary and cache directories.
Modified: trunk/Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm (291901 => 291902)
--- trunk/Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm 2022-03-25 23:42:25 UTC (rev 291902)
@@ -158,7 +158,7 @@
if (languagesIterator != m_launchOptions.extraInitializationData.end()) {
LOG_WITH_STREAM(Language, stream << "Process Launcher is copying OverrideLanguages into initialization message: " << languagesIterator->value);
auto languages = adoptOSObject(xpc_array_create(nullptr, 0));
- for (auto& language : languagesIterator->value.split(','))
+ for (auto language : StringView(languagesIterator->value).split(','))
xpc_array_set_string(languages.get(), XPC_ARRAY_APPEND, language.utf8().data());
xpc_dictionary_set_value(initializationMessage.get(), "OverrideLanguages", languages.get());
}
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp (291901 => 291902)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp 2022-03-25 23:14:26 UTC (rev 291901)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp 2022-03-25 23:42:25 UTC (rev 291902)
@@ -119,10 +119,10 @@
void RemoteGraphicsContextGLProxy::initialize(const String& availableExtensions, const String& requestableExtensions)
{
- for (auto& extension : availableExtensions.split(' '))
- m_availableExtensions.add(extension);
- for (auto& extension : requestableExtensions.split(' '))
- m_requestableExtensions.add(extension);
+ for (auto extension : StringView(availableExtensions).split(' '))
+ m_availableExtensions.add(extension.toString());
+ for (auto extension : StringView(requestableExtensions).split(' '))
+ m_requestableExtensions.add(extension.toString());
}
void RemoteGraphicsContextGLProxy::reshape(int width, int height)