String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
authorross.kirsling@sony.com <ross.kirsling@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2018 22:00:03 +0000 (22:00 +0000)
committerross.kirsling@sony.com <ross.kirsling@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2018 22:00:03 +0000 (22:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187963

Reviewed by Alex Christensen.

Source/JavaScriptCore:

* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::dispatch):
* jsc.cpp:
(ModuleName::ModuleName):
(resolvePath):
* runtime/IntlObject.cpp:
(JSC::canonicalizeLanguageTag):
(JSC::removeUnicodeLocaleExtension):
Update split/splitAllowingEmptyEntries usage.

Source/WebCore:

* Modules/applepay/cocoa/PaymentContactCocoa.mm:
(WebCore::convert):
* Modules/cache/DOMCache.cpp:
(WebCore::hasResponseVaryStarHeaderValue):
* Modules/cache/DOMCacheEngine.cpp:
(WebCore::DOMCacheEngine::queryCacheMatch):
* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::filterICECandidate):
(WebCore::PeerConnectionBackend::filterSDP const):
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::checkResponseHeaders):
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::determineARIADropEffects):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::determineARIADropEffects):
* accessibility/AccessibilityRenderObject.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* editing/cocoa/DataDetection.mm:
(WebCore::DataDetection::shouldCancelDefaultAction):
* editing/markup.cpp:
(WebCore::fillContainerFromString):
(WebCore::createFragmentFromText):
* html/EmailInputType.cpp:
(WebCore::EmailInputType::typeMismatchFor const):
(WebCore::EmailInputType::sanitizeValue const):
* html/HTMLInputElement.cpp:
(WebCore::parseAcceptAttribute):
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::setMessageDOMAndStartTimer):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::compileShader):
* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::nodeForPath):
* loader/FormSubmission.cpp:
(WebCore::encodingFromAcceptCharset):
* loader/ResourceTiming.cpp:
(WebCore::passesTimingAllowCheck):
* page/WindowFeatures.cpp:
(WebCore::parseDisabledAdaptations):
(WebCore::parseDialogFeaturesMap):
* platform/URL.cpp:
(WebCore::isIPv4Address):
(WebCore::isIPv6Address):
* platform/graphics/GLContext.cpp:
(WebCore::GLContext::version):
* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::patternToFamilies):
* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::extractGStreamerOptionsFromCommandLine):
* platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
(WebCore::Extensions3DOpenGLCommon::Extensions3DOpenGLCommon):
(WebCore::Extensions3DOpenGLCommon::initializeAvailableExtensions):
* platform/gtk/PasteboardHelper.cpp:
(WebCore::PasteboardHelper::fillSelectionData):
* platform/gtk/SelectionData.cpp:
(WebCore::SelectionData::setURIList):
* platform/network/CacheValidation.cpp:
(WebCore::collectVaryingRequestHeaders):
* platform/network/HTTPParsers.cpp:
(WebCore::filenameFromHTTPContentDisposition):
(WebCore::parseXFrameOptionsHeader):
(WebCore::parseAccessControlExposeHeadersAllowList):
* platform/network/curl/CookieUtil.cpp:
(WebCore::CookieUtil::parseCookieHeader):
* platform/network/curl/CurlCacheEntry.cpp:
(WebCore::CurlCacheEntry::loadResponseHeaders):
* platform/network/curl/CurlCacheManager.cpp:
(WebCore::CurlCacheManager::loadIndex):
* platform/network/soup/CookieJarSoup.cpp:
(WebCore::setCookiesFromDOM):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::parseAttribute):
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::appendOS2Table):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::parseBeginOrEnd):
* testing/MockCDMFactory.cpp:
(WebCore::MockCDM::sanitizeResponse const):
(WebCore::MockCDMInstance::updateLicense):
Update split/splitAllowingEmptyEntries usage.

Source/WebDriver:

* WebDriverService.cpp:
(WebDriver::WebDriverService::findCommand):
* glib/WebDriverServiceGLib.cpp:
(WebDriver::parseVersion):
Update split/splitAllowingEmptyEntries usage.

Source/WebKit:

* NetworkProcess/cache/CacheStorageEngineCache.cpp:
(WebKit::CacheStorage::updateVaryInformation):
* NetworkProcess/capture/NetworkCaptureManager.cpp:
(WebKit::NetworkCapture::Manager::fuzzyMatchURLs):
* Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
(WebKit::getPluginInfoFromPropertyLists):
(WebKit::PluginVersion::parse):
* Shared/Plugins/Netscape/unix/NetscapePluginModuleUnix.cpp:
(WebKit::NetscapePluginModule::parseMIMEDescription):
* Shared/Plugins/unix/PluginSearchPath.cpp:
(WebKit::pluginsDirectories):
* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::initializeSandbox):
* UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp:
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::fileCanBeAcceptedForUpload):
* UIProcess/Launcher/glib/ProcessLauncherGLib.cpp:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/Plugins/unix/PluginProcessProxyUnix.cpp:
(WebKit::PluginProcessProxy::scanPlugin):
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::isTransparentSilverlightBackgroundValue):
Update split/splitAllowingEmptyEntries usage.

Source/WebKitLegacy/win:

* Plugins/PluginPackageWin.cpp:
(WebCore::PluginPackage::fetchInfo):
Update split/splitAllowingEmptyEntries usage.

Source/WTF:

* wtf/Assertions.cpp:
Update split/splitAllowingEmptyEntries usage.

* wtf/text/StringView.h:
(WTF::StringView::splitAllowingEmptyEntries const):
* wtf/text/WTFString.cpp:
(WTF::String::splitInternal const):
(WTF::String::split const):
(WTF::String::splitAllowingEmptyEntries const):
* wtf/text/WTFString.h:
(WTF::String::split const):
Introduce splitAllowingEmptyEntries instead of boolean or enum parameter.

Tools:

* TestWebKitAPI/Tests/WTF/WTFString.cpp:
Add tests for String::split and String::splitAllowingEmptyEntries.

* TestWebKitAPI/Tests/WTF/StringView.cpp:
* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader):
Update split/splitAllowingEmptyEntries usage.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234278 268f45cc-cd09-0410-ab3c-d52691b4dbfc

68 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/IntlObject.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Assertions.cpp
Source/WTF/wtf/text/StringView.h
Source/WTF/wtf/text/WTFString.cpp
Source/WTF/wtf/text/WTFString.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm
Source/WebCore/Modules/cache/DOMCache.cpp
Source/WebCore/Modules/cache/DOMCacheEngine.cpp
Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
Source/WebCore/Modules/websockets/WebSocketHandshake.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/editing/cocoa/DataDetection.mm
Source/WebCore/editing/markup.cpp
Source/WebCore/html/EmailInputType.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/ValidationMessage.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
Source/WebCore/loader/FormSubmission.cpp
Source/WebCore/loader/ResourceTiming.cpp
Source/WebCore/page/WindowFeatures.cpp
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/graphics/GLContext.cpp
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
Source/WebCore/platform/gtk/PasteboardHelper.cpp
Source/WebCore/platform/gtk/SelectionData.cpp
Source/WebCore/platform/network/CacheValidation.cpp
Source/WebCore/platform/network/HTTPParsers.cpp
Source/WebCore/platform/network/curl/CookieUtil.cpp
Source/WebCore/platform/network/curl/CurlCacheEntry.cpp
Source/WebCore/platform/network/curl/CurlCacheManager.cpp
Source/WebCore/platform/network/soup/CookieJarSoup.cpp
Source/WebCore/svg/SVGAnimationElement.cpp
Source/WebCore/svg/SVGToOTFFontConversion.cpp
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/testing/MockCDMFactory.cpp
Source/WebDriver/ChangeLog
Source/WebDriver/WebDriverService.cpp
Source/WebDriver/glib/WebDriverServiceGLib.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp
Source/WebKit/NetworkProcess/capture/NetworkCaptureManager.cpp
Source/WebKit/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm
Source/WebKit/Shared/Plugins/Netscape/unix/NetscapePluginModuleUnix.cpp
Source/WebKit/Shared/Plugins/unix/PluginSearchPath.cpp
Source/WebKit/Shared/mac/ChildProcessMac.mm
Source/WebKit/UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp
Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp
Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit/UIProcess/Plugins/unix/PluginProcessProxyUnix.cpp
Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/Plugins/PluginPackageWin.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp
Tools/WebKitTestRunner/TestController.cpp

index 4ec995f..8e23ad3 100644 (file)
@@ -1,3 +1,20 @@
+2018-07-26  Ross Kirsling  <ross.kirsling@sony.com>
+
+        String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
+        https://bugs.webkit.org/show_bug.cgi?id=187963
+
+        Reviewed by Alex Christensen.
+
+        * inspector/InspectorBackendDispatcher.cpp:
+        (Inspector::BackendDispatcher::dispatch):
+        * jsc.cpp:
+        (ModuleName::ModuleName):
+        (resolvePath):
+        * runtime/IntlObject.cpp:
+        (JSC::canonicalizeLanguageTag):
+        (JSC::removeUnicodeLocaleExtension):
+        Update split/splitAllowingEmptyEntries usage.
+
 2018-07-26  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r234181 and r234189.
index 99ec27a..aa4eb4e 100644 (file)
@@ -161,8 +161,7 @@ void BackendDispatcher::dispatch(const String& message)
             return;
         }
 
-        Vector<String> domainAndMethod;
-        methodString.split('.', true, domainAndMethod);
+        Vector<String> domainAndMethod = methodString.splitAllowingEmptyEntries('.');
         if (domainAndMethod.size() != 2 || !domainAndMethod[0].length() || !domainAndMethod[1].length()) {
             reportProtocolError(InvalidRequest, "The 'method' property was formatted incorrectly. It should be 'Domain.method'"_s);
             sendPendingErrors();
index da2e71c..c49baac 100644 (file)
@@ -687,7 +687,7 @@ struct ModuleName {
 ModuleName::ModuleName(const String& moduleName)
 {
     // A module name given from code is represented as the UNIX style path. Like, `./A/B.js`.
-    moduleName.split('/', true, queries);
+    queries = moduleName.splitAllowingEmptyEntries('/');
 }
 
 static std::optional<DirectoryName> extractDirectoryName(const String& absolutePathToFile)
@@ -750,8 +750,7 @@ static std::optional<DirectoryName> currentWorkingDirectory()
 
 static String resolvePath(const DirectoryName& directoryName, const ModuleName& moduleName)
 {
-    Vector<String> directoryPieces;
-    directoryName.queryName.split(pathSeparator(), false, directoryPieces);
+    Vector<String> directoryPieces = directoryName.queryName.split(pathSeparator());
 
     // Only first '/' is recognized as the path from the root.
     if (moduleName.startsWithRoot())
index b2027e4..be30d26 100644 (file)
@@ -484,8 +484,7 @@ static String canonicalizeLanguageTag(const String& locale)
     if (!grandfather.isNull())
         return grandfather;
 
-    Vector<String> parts;
-    locale.split('-', true, parts);
+    Vector<String> parts = locale.splitAllowingEmptyEntries('-');
     if (!parts.isEmpty()) {
         String langtag = canonicalLangTag(parts);
         if (!langtag.isNull())
@@ -623,8 +622,7 @@ String defaultLocale(ExecState& state)
 
 String removeUnicodeLocaleExtension(const String& locale)
 {
-    Vector<String> parts;
-    locale.split('-', parts);
+    Vector<String> parts = locale.split('-');
     StringBuilder builder;
     size_t partsSize = parts.size();
     bool atPrivate = false;
index 191dd85..5274849 100644 (file)
@@ -1,3 +1,23 @@
+2018-07-26  Ross Kirsling  <ross.kirsling@sony.com>
+
+        String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
+        https://bugs.webkit.org/show_bug.cgi?id=187963
+
+        Reviewed by Alex Christensen.
+
+        * wtf/Assertions.cpp:
+        Update split/splitAllowingEmptyEntries usage.
+
+        * wtf/text/StringView.h:
+        (WTF::StringView::splitAllowingEmptyEntries const):
+        * wtf/text/WTFString.cpp:
+        (WTF::String::splitInternal const):
+        (WTF::String::split const):
+        (WTF::String::splitAllowingEmptyEntries const):
+        * wtf/text/WTFString.h:
+        (WTF::String::split const):
+        Introduce splitAllowingEmptyEntries instead of boolean or enum parameter.
+
 2018-07-26  Sam Weinig  <sam@webkit.org>
 
         Remove unused/undefined String::appendInternal
index 13b7093..9700e05 100644 (file)
@@ -504,13 +504,8 @@ void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t c
     }
 #endif
 
-    String logLevelString = logLevel;
-    Vector<String> components;
-    logLevelString.split(',', components);
-
-    for (size_t i = 0; i < components.size(); ++i) {
-        Vector<String> componentInfo;
-        components[i].split('=', componentInfo);
+    for (auto& logLevelComponent : String(logLevel).split(',')) {
+        Vector<String> componentInfo = logLevelComponent.split('=');
         String component = componentInfo[0].stripWhiteSpace();
 
         WTFLogChannelState logChannelState = WTFLogChannelOn;
index 02ed753..c6c6883 100644 (file)
@@ -124,11 +124,9 @@ public:
     template<typename MatchedCharacterPredicate>
     StringView stripLeadingAndTrailingMatchedCharacters(const MatchedCharacterPredicate&);
 
-    enum AllowEmptyEntriesTag { AllowEmptyEntries };
-
     class SplitResult;
     SplitResult split(UChar) const;
-    SplitResult split(UChar, AllowEmptyEntriesTag) const;
+    SplitResult splitAllowingEmptyEntries(UChar) const;
 
     size_t find(UChar, unsigned start = 0) const;
     size_t find(CodeUnitMatchFunction, unsigned start = 0) const;
@@ -905,7 +903,7 @@ inline auto StringView::split(UChar separator) const -> SplitResult
     return SplitResult { *this, separator, false };
 }
 
-inline auto StringView::split(UChar separator, AllowEmptyEntriesTag) const -> SplitResult
+inline auto StringView::splitAllowingEmptyEntries(UChar separator) const -> SplitResult
 {
     return SplitResult { *this, separator, true };
 }
index 57bf1f8..1781133 100644 (file)
@@ -705,9 +705,10 @@ bool String::isSafeToSendToAnotherThread() const
     return isEmpty() || (m_impl->hasOneRef() && !m_impl->isAtomic());
 }
 
-void String::split(const String& separator, bool allowEmptyEntries, Vector<String>& result) const
+template<bool allowEmptyEntries>
+inline Vector<String> String::splitInternal(const String& separator) const
 {
-    result.clear();
+    Vector<String> result;
 
     unsigned startPos = 0;
     size_t endPos;
@@ -718,9 +719,12 @@ void String::split(const String& separator, bool allowEmptyEntries, Vector<Strin
     }
     if (allowEmptyEntries || startPos != length())
         result.append(substring(startPos));
+
+    return result;
 }
 
-void String::split(UChar separator, bool allowEmptyEntries, const SplitFunctor& functor) const
+template<bool allowEmptyEntries>
+inline void String::splitInternal(UChar separator, const SplitFunctor& functor) const
 {
     StringView view(*this);
 
@@ -735,12 +739,45 @@ void String::split(UChar separator, bool allowEmptyEntries, const SplitFunctor&
         functor(view.substring(startPos));
 }
 
-void String::split(UChar separator, bool allowEmptyEntries, Vector<String>& result) const
+template<bool allowEmptyEntries>
+inline Vector<String> String::splitInternal(UChar separator) const
 {
-    result.clear();
-    split(separator, allowEmptyEntries, [&result](StringView item) {
+    Vector<String> result;
+    splitInternal<allowEmptyEntries>(separator, [&result](StringView item) {
         result.append(item.toString());
     });
+
+    return result;
+}
+
+void String::split(UChar separator, const SplitFunctor& functor) const
+{
+    splitInternal<false>(separator, functor);
+}
+
+Vector<String> String::split(UChar separator) const
+{
+    return splitInternal<false>(separator);
+}
+
+Vector<String> String::split(const String& separator) const
+{
+    return splitInternal<false>(separator);
+}
+
+void String::splitAllowingEmptyEntries(UChar separator, const SplitFunctor& functor) const
+{
+    splitInternal<true>(separator, functor);
+}
+
+Vector<String> String::splitAllowingEmptyEntries(UChar separator) const
+{
+    return splitInternal<true>(separator);
+}
+
+Vector<String> String::splitAllowingEmptyEntries(const String& separator) const
+{
+    return splitInternal<true>(separator);
 }
 
 CString String::ascii() const
index 2986bd8..ae61ffc 100644 (file)
@@ -270,15 +270,15 @@ public:
     static String createUninitialized(unsigned length, UChar*& data) { return StringImpl::createUninitialized(length, data); }
     static String createUninitialized(unsigned length, LChar*& data) { return StringImpl::createUninitialized(length, data); }
 
-    WTF_EXPORT_PRIVATE void split(const String& separator, bool allowEmptyEntries, Vector<String>& result) const;
-    void split(const String& separator, Vector<String>& result) const { split(separator, false, result); }
-
     using SplitFunctor = WTF::Function<void(const StringView&)>;
-    WTF_EXPORT_PRIVATE void split(UChar separator, bool allowEmptyEntries, const SplitFunctor&) const;
-    WTF_EXPORT_PRIVATE void split(UChar separator, bool allowEmptyEntries, Vector<String>& result) const;
-    void split(UChar separator, Vector<String>& result) const { split(separator, false, result); }
-    Vector<String> split(UChar separator) const;
-    Vector<String> split(const String& separator) const;
+
+    WTF_EXPORT_PRIVATE void split(UChar separator, const SplitFunctor&) const;
+    WTF_EXPORT_PRIVATE Vector<String> split(UChar separator) const;
+    WTF_EXPORT_PRIVATE Vector<String> split(const String& separator) const;
+
+    WTF_EXPORT_PRIVATE void splitAllowingEmptyEntries(UChar separator, const SplitFunctor&) const;
+    WTF_EXPORT_PRIVATE Vector<String> splitAllowingEmptyEntries(UChar separator) const;
+    WTF_EXPORT_PRIVATE Vector<String> splitAllowingEmptyEntries(const String& separator) const;
 
     WTF_EXPORT_PRIVATE int toIntStrict(bool* ok = nullptr, int base = 10) const;
     WTF_EXPORT_PRIVATE unsigned toUIntStrict(bool* ok = nullptr, int base = 10) const;
@@ -369,6 +369,10 @@ public:
 private:
     template<typename CharacterType> void removeInternal(const CharacterType*, unsigned, unsigned);
 
+    template<bool allowEmptyEntries> void splitInternal(UChar separator, const SplitFunctor&) const;
+    template<bool allowEmptyEntries> Vector<String> splitInternal(UChar separator) const;
+    template<bool allowEmptyEntries> Vector<String> splitInternal(const String& separator) const;
+
     RefPtr<StringImpl> m_impl;
 };
 
@@ -531,20 +535,6 @@ template<unsigned characterCount> ALWAYS_INLINE String& String::replaceWithLiter
     return *this;
 }
 
-inline Vector<String> String::split(UChar separator) const
-{
-    Vector<String> result;
-    split(separator, false, result);
-    return result;
-}
-
-inline Vector<String> String::split(const String& separator) const
-{
-    Vector<String> result;
-    split(separator, false, result);
-    return result;
-}
-
 template<size_t inlineCapacity> inline String String::make8BitFrom16BitSource(const Vector<UChar, inlineCapacity>& buffer)
 {
     return make8BitFrom16BitSource(buffer.data(), buffer.size());
index a1a9462..c487994 100644 (file)
@@ -1,3 +1,92 @@
+2018-07-26  Ross Kirsling  <ross.kirsling@sony.com>
+
+        String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
+        https://bugs.webkit.org/show_bug.cgi?id=187963
+
+        Reviewed by Alex Christensen.
+
+        * Modules/applepay/cocoa/PaymentContactCocoa.mm:
+        (WebCore::convert):
+        * Modules/cache/DOMCache.cpp:
+        (WebCore::hasResponseVaryStarHeaderValue):
+        * Modules/cache/DOMCacheEngine.cpp:
+        (WebCore::DOMCacheEngine::queryCacheMatch):
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::filterICECandidate):
+        (WebCore::PeerConnectionBackend::filterSDP const):
+        * Modules/websockets/WebSocketHandshake.cpp:
+        (WebCore::WebSocketHandshake::checkResponseHeaders):
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::determineARIADropEffects):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::determineARIADropEffects):
+        * accessibility/AccessibilityRenderObject.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::DataDetection::shouldCancelDefaultAction):
+        * editing/markup.cpp:
+        (WebCore::fillContainerFromString):
+        (WebCore::createFragmentFromText):
+        * html/EmailInputType.cpp:
+        (WebCore::EmailInputType::typeMismatchFor const):
+        (WebCore::EmailInputType::sanitizeValue const):
+        * html/HTMLInputElement.cpp:
+        (WebCore::parseAcceptAttribute):
+        * html/ValidationMessage.cpp:
+        (WebCore::ValidationMessage::setMessageDOMAndStartTimer):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::compileShader):
+        * inspector/agents/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::nodeForPath):
+        * loader/FormSubmission.cpp:
+        (WebCore::encodingFromAcceptCharset):
+        * loader/ResourceTiming.cpp:
+        (WebCore::passesTimingAllowCheck):
+        * page/WindowFeatures.cpp:
+        (WebCore::parseDisabledAdaptations):
+        (WebCore::parseDialogFeaturesMap):
+        * platform/URL.cpp:
+        (WebCore::isIPv4Address):
+        (WebCore::isIPv6Address):
+        * platform/graphics/GLContext.cpp:
+        (WebCore::GLContext::version):
+        * platform/graphics/freetype/FontCacheFreeType.cpp:
+        (WebCore::patternToFamilies):
+        * platform/graphics/gstreamer/GStreamerCommon.cpp:
+        (WebCore::extractGStreamerOptionsFromCommandLine):
+        * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
+        (WebCore::Extensions3DOpenGLCommon::Extensions3DOpenGLCommon):
+        (WebCore::Extensions3DOpenGLCommon::initializeAvailableExtensions):
+        * platform/gtk/PasteboardHelper.cpp:
+        (WebCore::PasteboardHelper::fillSelectionData):
+        * platform/gtk/SelectionData.cpp:
+        (WebCore::SelectionData::setURIList):
+        * platform/network/CacheValidation.cpp:
+        (WebCore::collectVaryingRequestHeaders):
+        * platform/network/HTTPParsers.cpp:
+        (WebCore::filenameFromHTTPContentDisposition):
+        (WebCore::parseXFrameOptionsHeader):
+        (WebCore::parseAccessControlExposeHeadersAllowList):
+        * platform/network/curl/CookieUtil.cpp:
+        (WebCore::CookieUtil::parseCookieHeader):
+        * platform/network/curl/CurlCacheEntry.cpp:
+        (WebCore::CurlCacheEntry::loadResponseHeaders):
+        * platform/network/curl/CurlCacheManager.cpp:
+        (WebCore::CurlCacheManager::loadIndex):
+        * platform/network/soup/CookieJarSoup.cpp:
+        (WebCore::setCookiesFromDOM):
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::SVGAnimationElement::parseAttribute):
+        * svg/SVGToOTFFontConversion.cpp:
+        (WebCore::SVGToOTFFontConverter::appendOS2Table):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::parseBeginOrEnd):
+        * testing/MockCDMFactory.cpp:
+        (WebCore::MockCDM::sanitizeResponse const):
+        (WebCore::MockCDMInstance::updateLicense):
+        Update split/splitAllowingEmptyEntries usage.
+
 2018-07-26  Nan Wang  <n_wang@apple.com>
 
         AX: nothing returned for various previous text marker APIs from one div/p node to another
index 3be6210..bbaa4ef 100644 (file)
@@ -202,8 +202,7 @@ static ApplePayPaymentContact convert(unsigned version, PKContact *contact)
 
     CNPostalAddress *postalAddress = contact.postalAddress;
     if (postalAddress.street.length) {
-        Vector<String> addressLines;
-        String(postalAddress.street).split("\n", addressLines);
+        Vector<String> addressLines = String(postalAddress.street).split('\n');
         result.addressLines = WTFMove(addressLines);
     }
     result.subLocality = subLocality(postalAddress);
index 23135c1..38d5a66 100644 (file)
@@ -145,7 +145,7 @@ static inline bool hasResponseVaryStarHeaderValue(const FetchResponse& response)
 {
     auto varyValue = response.headers().internalHeaders().get(WebCore::HTTPHeaderName::Vary);
     bool hasStar = false;
-    varyValue.split(',', false, [&](StringView view) {
+    varyValue.split(',', [&](StringView view) {
         if (!hasStar && stripLeadingAndTrailingHTTPSpaces(view) == "*")
             hasStar = true;
     });
index 49128c6..1bfbda7 100644 (file)
@@ -88,7 +88,7 @@ bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cach
         return true;
 
     bool isVarying = false;
-    varyValue.split(',', false, [&](StringView view) {
+    varyValue.split(',', [&](StringView view) {
         if (isVarying)
             return;
         auto nameView = stripLeadingAndTrailingHTTPSpaces(view);
index 213daf0..f5e9931 100644 (file)
@@ -382,7 +382,7 @@ static String filterICECandidate(String&& sdp)
     bool skipNextItem = false;
     bool isFirst = true;
     StringBuilder filteredSDP;
-    sdp.split(' ', false, [&](StringView item) {
+    sdp.split(' ', [&](StringView item) {
         if (skipNextItem) {
             skipNextItem = false;
             return;
@@ -412,7 +412,7 @@ String PeerConnectionBackend::filterSDP(String&& sdp) const
         return WTFMove(sdp);
 
     StringBuilder filteredSDP;
-    sdp.split('\n', false, [&filteredSDP](StringView line) {
+    sdp.split('\n', [&filteredSDP](StringView line) {
         if (!line.startsWith("a=candidate"))
             filteredSDP.append(line);
         else if (line.find(" host ", 11) == notFound)
index 2701adb..7427bb5 100644 (file)
@@ -605,8 +605,7 @@ bool WebSocketHandshake::checkResponseHeaders()
             m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Protocol mismatch"_s;
             return false;
         }
-        Vector<String> result;
-        m_clientProtocol.split(WebSocket::subprotocolSeparator(), result);
+        Vector<String> result = m_clientProtocol.split(WebSocket::subprotocolSeparator());
         if (!result.contains(serverWebSocketProtocol)) {
             m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Protocol mismatch"_s;
             return false;
index 47d5da7..3933507 100644 (file)
@@ -731,7 +731,7 @@ public:
     virtual bool supportsARIADragging() const { return false; }
     virtual bool isARIAGrabbed() { return false; }
     virtual void setARIAGrabbed(bool) { }
-    virtual void determineARIADropEffects(Vector<String>&) { }
+    virtual Vector<String> determineARIADropEffects() { return { }; }
     
     // Called on the root AX object to return the deepest available element.
     virtual AccessibilityObject* accessibilityHitTest(const IntPoint&) const { return nullptr; }
index aed3ec9..730cbb5 100644 (file)
@@ -1029,17 +1029,16 @@ bool AccessibilityRenderObject::isARIAGrabbed()
     return elementAttributeValue(aria_grabbedAttr);
 }
 
-void AccessibilityRenderObject::determineARIADropEffects(Vector<String>& effects)
+Vector<String> AccessibilityRenderObject::determineARIADropEffects()
 {
     const AtomicString& dropEffects = getAttribute(aria_dropeffectAttr);
     if (dropEffects.isEmpty()) {
-        effects.clear();
-        return;
+        return { };
     }
     
     String dropEffectsString = dropEffects.string();
     dropEffectsString.replace('\n', ' ');
-    dropEffectsString.split(' ', effects);
+    return dropEffectsString.split(' ');
 }
     
 bool AccessibilityRenderObject::exposesTitleUIElement() const
index 48af65a..003f183 100644 (file)
@@ -176,7 +176,7 @@ public:
     bool supportsARIADropping() const override;
     bool supportsARIADragging() const override;
     bool isARIAGrabbed() override;
-    void determineARIADropEffects(Vector<String>&) override;
+    Vector<String> determineARIADropEffects() override;
     
     VisiblePosition visiblePositionForPoint(const IntPoint&) const override;
     VisiblePosition visiblePositionForIndex(unsigned indexValue, bool lastIndexOK) const override;
index e336937..241141c 100644 (file)
@@ -3093,8 +3093,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return [NSNumber numberWithBool:m_object->isARIAGrabbed()];
     
     if ([attributeName isEqualToString:NSAccessibilityDropEffectsAttribute]) {
-        Vector<String> dropEffects;
-        m_object->determineARIADropEffects(dropEffects);
+        Vector<String> dropEffects = m_object->determineARIADropEffects();
         return convertStringsToNSArray(dropEffects);
     }
     
index b4f53f9..5bcc3a8 100644 (file)
@@ -202,8 +202,7 @@ bool DataDetection::shouldCancelDefaultAction(Element& element)
     NSArray *results = element.document().frame()->dataDetectionResults();
     if (!results)
         return false;
-    Vector<String> resultIndices;
-    resultAttribute.string().split('/', resultIndices);
+    Vector<String> resultIndices = resultAttribute.string().split('/');
     DDResultRef result = [[results objectAtIndex:resultIndices[0].toInt()] coreResult];
     // Handle the case of a signature block, where we need to check the correct subresult.
     for (size_t i = 1; i < resultIndices.size(); i++) {
index 0e183fd..d1ec589 100644 (file)
@@ -933,8 +933,7 @@ static void fillContainerFromString(ContainerNode& paragraph, const String& stri
 
     ASSERT(string.find('\n') == notFound);
 
-    Vector<String> tabList;
-    string.split('\t', true, tabList);
+    Vector<String> tabList = string.splitAllowingEmptyEntries('\t');
     String tabText = emptyString();
     bool first = true;
     size_t numEntries = tabList.size();
@@ -1034,8 +1033,7 @@ Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text)
         && block != editableRootForPosition(context.startPosition());
     bool useLineBreak = enclosingTextFormControl(context.startPosition());
 
-    Vector<String> list;
-    string.split('\n', true, list); // true gets us empty strings in the list
+    Vector<String> list = string.splitAllowingEmptyEntries('\n');
     size_t numLines = list.size();
     for (size_t i = 0; i < numLines; ++i) {
         const String& s = list[i];
index 0a84339..4255369 100644 (file)
@@ -64,9 +64,7 @@ bool EmailInputType::typeMismatchFor(const String& value) const
         return false;
     if (!element()->multiple())
         return !isValidEmailAddress(value);
-    Vector<String> addresses;
-    value.split(',', true, addresses);
-    for (auto& address : addresses) {
+    for (auto& address : value.splitAllowingEmptyEntries(',')) {
         if (!isValidEmailAddress(stripLeadingAndTrailingHTMLSpaces(address)))
             return true;
     }
@@ -101,8 +99,7 @@ String EmailInputType::sanitizeValue(const String& proposedValue) const
     ASSERT(element());
     if (!element()->multiple())
         return stripLeadingAndTrailingHTMLSpaces(noLineBreakValue);
-    Vector<String> addresses;
-    noLineBreakValue.split(',', true, addresses);
+    Vector<String> addresses = noLineBreakValue.splitAllowingEmptyEntries(',');
     StringBuilder strippedValue;
     for (unsigned i = 0; i < addresses.size(); ++i) {
         if (i > 0)
index 8e584d9..b1ff12d 100644 (file)
@@ -1278,9 +1278,7 @@ static Vector<String> parseAcceptAttribute(const String& acceptString, bool (*pr
     if (acceptString.isEmpty())
         return types;
 
-    Vector<String> splitTypes;
-    acceptString.split(',', false, splitTypes);
-    for (auto& splitType : splitTypes) {
+    for (auto& splitType : acceptString.split(',')) {
         String trimmedType = stripLeadingAndTrailingHTMLSpaces(splitType);
         if (trimmedType.isEmpty())
             continue;
index 470eaed..4cc00bc 100644 (file)
@@ -127,8 +127,7 @@ void ValidationMessage::setMessageDOMAndStartTimer()
     ASSERT(m_messageBody);
     m_messageHeading->removeChildren();
     m_messageBody->removeChildren();
-    Vector<String> lines;
-    m_message.split('\n', lines);
+    Vector<String> lines = m_message.split('\n');
     Document& document = m_messageHeading->document();
     for (unsigned i = 0; i < lines.size(); ++i) {
         if (i) {
index d559428..19181e4 100644 (file)
@@ -1536,9 +1536,7 @@ void WebGLRenderingContextBase::compileShader(WebGLShader* shader)
     if (canvas && m_synthesizedErrorsToConsole && !value) {
         Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState());
 
-        Vector<String> errors;
-        getShaderInfoLog(shader).split("\n", errors);
-        for (String& error : errors)
+        for (auto& error : getShaderInfoLog(shader).split('\n'))
             canvas->document().addConsoleMessage(std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, MessageLevel::Error, "WebGL: " + error, stackTrace.copyRef()));
     }
 }
index 472298b..9869b63 100644 (file)
@@ -2295,8 +2295,7 @@ Node* InspectorDOMAgent::nodeForPath(const String& path)
         return nullptr;
 
     Node* node = m_document.get();
-    Vector<String> pathTokens;
-    path.split(',', false, pathTokens);
+    Vector<String> pathTokens = path.split(',');
     if (!pathTokens.size())
         return nullptr;
 
index fe42787..336dcc1 100644 (file)
@@ -133,10 +133,7 @@ static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Docum
     String normalizedAcceptCharset = acceptCharset;
     normalizedAcceptCharset.replace(',', ' ');
 
-    Vector<String> charsets;
-    normalizedAcceptCharset.split(' ', charsets);
-
-    for (auto& charset : charsets) {
+    for (auto& charset : normalizedAcceptCharset.split(' ')) {
         TextEncoding encoding(charset);
         if (encoding.isValid())
             return encoding;
index dcc47b3..a6ab680 100644 (file)
@@ -47,9 +47,7 @@ static bool passesTimingAllowCheck(const ResourceResponse& response, const Secur
         return true;
 
     const String& securityOrigin = initiatorSecurityOrigin.toString();
-    Vector<String> timingAllowOrigins;
-    timingAllowOriginString.split(',', timingAllowOrigins);
-    for (auto& origin : timingAllowOrigins) {
+    for (auto& origin : timingAllowOriginString.split(',')) {
         if (origin.stripWhiteSpace() == securityOrigin)
             return true;
     }
index c3fc993..cf90107 100644 (file)
@@ -117,9 +117,7 @@ void processFeaturesString(StringView features, FeatureMode mode, const WTF::Fun
 OptionSet<DisabledAdaptations> parseDisabledAdaptations(const String& disabledAdaptationsString)
 {
     OptionSet<DisabledAdaptations> disabledAdaptations;
-    Vector<String> disabledAdaptationNames;
-    disabledAdaptationsString.split(',', false, disabledAdaptationNames);
-    for (auto& name : disabledAdaptationNames) {
+    for (auto& name : disabledAdaptationsString.split(',')) {
         auto normalizedName = name.stripWhiteSpace().convertToASCIILowercase();
         if (normalizedName == watchAdaptationName())
             disabledAdaptations |= DisabledAdaptations::Watch;
@@ -248,10 +246,7 @@ static DialogFeaturesMap parseDialogFeaturesMap(const String& string)
 
     DialogFeaturesMap features;
 
-    Vector<String> vector;
-    string.split(';', vector);
-
-    for (auto& featureString : vector) {
+    for (auto& featureString : string.split(';')) {
         size_t separatorPosition = featureString.find('=');
         size_t colonPosition = featureString.find(':');
         if (separatorPosition != notFound && colonPosition != notFound)
index c99de10..e908497 100644 (file)
@@ -1066,7 +1066,7 @@ static bool isIPv4Address(StringView string)
 {
     auto count = 0;
 
-    for (const auto octet : string.split('.', StringView::AllowEmptyEntries)) {
+    for (const auto octet : string.splitAllowingEmptyEntries('.')) {
         if (count >= 4)
             return false;
 
@@ -1100,7 +1100,7 @@ static bool isIPv6Address(StringView string)
     auto skipState = None;
     auto count = 0;
 
-    for (const auto hextet : string.split(':', StringView::AllowEmptyEntries)) {
+    for (const auto hextet : string.splitAllowingEmptyEntries(':')) {
         if (count >= 8 || skipState == Final)
             return false;
 
index 28d9b3b..f6d30db 100644 (file)
@@ -173,19 +173,18 @@ unsigned GLContext::version()
         // Version string can start with the version number (all versions except GLES 1 and 2) or with
         // "OpenGL". Different fields inside the version string are separated by spaces.
         String versionString = String(reinterpret_cast<const char*>(::glGetString(GL_VERSION)));
-        Vector<String> versionStringComponents;
-        versionString.split(' ', versionStringComponents);
+        Vector<String> versionStringComponents = versionString.split(' ');
 
         Vector<String> versionDigits;
         if (versionStringComponents[0] == "OpenGL") {
             // If the version string starts with "OpenGL" it can be GLES 1 or 2. In GLES1 version string starts
             // with "OpenGL ES-<profile> major.minor" and in GLES2 with "OpenGL ES major.minor". Version is the
             // third component in both cases.
-            versionStringComponents[2].split('.', versionDigits);
+            versionDigits = versionStringComponents[2].split('.');
         } else {
             // Version is the first component. The version number is always "major.minor" or
             // "major.minor.release". Ignore the release number.
-            versionStringComponents[0].split('.', versionDigits);
+            versionDigits = versionStringComponents[0].split('.');
         }
 
         m_version = versionDigits[0].toUInt() * 100 + versionDigits[1].toUInt() * 10;
index e975cc6..eea2d17 100644 (file)
@@ -115,9 +115,7 @@ static Vector<String> patternToFamilies(FcPattern& pattern)
     String patternString = String::fromUTF8(patternChars);
     free(patternChars);
 
-    Vector<String> results;
-    patternString.split(',', results);
-    return results;
+    return patternString.split(',');
 }
 
 Vector<String> FontCache::systemFontFamilies()
index f668e77..62353e4 100644 (file)
@@ -246,7 +246,7 @@ Vector<String> extractGStreamerOptionsFromCommandLine()
 
     Vector<String> options;
     auto optionsString = String::fromUTF8(contents.get(), length);
-    optionsString.split('\0', false, [&options](StringView item) {
+    optionsString.split('\0', [&options](StringView item) {
         if (item.startsWith("--gst"))
             options.append(item.toString());
     });
index 74ac4dc..d3f00e6 100644 (file)
@@ -78,8 +78,7 @@ Extensions3DOpenGLCommon::Extensions3DOpenGLCommon(GraphicsContext3D* context, b
     m_vendor = String(reinterpret_cast<const char*>(::glGetString(GL_VENDOR)));
     m_renderer = String(reinterpret_cast<const char*>(::glGetString(GL_RENDERER)));
 
-    Vector<String> vendorComponents;
-    m_vendor.convertToASCIILowercase().split(' ', vendorComponents);
+    Vector<String> vendorComponents = m_vendor.convertToASCIILowercase().split(' ');
     if (vendorComponents.contains("nvidia"))
         m_isNVIDIA = true;
     if (vendorComponents.contains("ati") || vendorComponents.contains("amd"))
@@ -235,10 +234,8 @@ void Extensions3DOpenGLCommon::initializeAvailableExtensions()
 #endif
     {
         String extensionsString = getExtensions();
-        Vector<String> availableExtensions;
-        extensionsString.split(' ', availableExtensions);
-        for (size_t i = 0; i < availableExtensions.size(); ++i)
-            m_availableExtensions.add(availableExtensions[i]);
+        for (auto& extension : extensionsString.split(' '))
+            m_availableExtensions.add(extension);
     }
     m_initializedAvailableExtensions = true;
 }
index 1cdcd51..c15ad06 100644 (file)
@@ -225,8 +225,7 @@ void PasteboardHelper::fillSelectionData(GtkSelectionData* data, unsigned /* inf
         selection.setURIList(selectionDataToUTF8String(data));
     } else if (target == netscapeURLAtom) {
         String urlWithLabel(selectionDataToUTF8String(data));
-        Vector<String> pieces;
-        urlWithLabel.split('\n', pieces);
+        Vector<String> pieces = urlWithLabel.split('\n');
 
         // Give preference to text/uri-list here, as it can hold more
         // than one URI but still take  the label if there is one.
index 1e2799b..82fe471 100644 (file)
@@ -47,8 +47,6 @@ void SelectionData::setURIList(const String& uriListString)
 
     // Line separator is \r\n per RFC 2483 - however, for compatibility
     // reasons we also allow just \n here.
-    Vector<String> uriList;
-    uriListString.split('\n', uriList);
 
     // Process the input and copy the first valid URL into the url member.
     // In case no URLs can be found, subsequent calls to getData("URL")
@@ -56,8 +54,7 @@ void SelectionData::setURIList(const String& uriListString)
     // "The DragEvent and DataTransfer interfaces"). Also extract all filenames
     // from the URI list.
     bool setURL = false;
-    for (size_t i = 0; i < uriList.size(); ++i) {
-        String& line = uriList[i];
+    for (auto& line : uriListString.split('\n')) {
         line = line.stripWhiteSpace();
         if (line.isEmpty())
             continue;
index f4c0a64..302a8d6 100644 (file)
@@ -350,8 +350,7 @@ Vector<std::pair<String, String>> collectVaryingRequestHeaders(const WebCore::Re
     String varyValue = response.httpHeaderField(WebCore::HTTPHeaderName::Vary);
     if (varyValue.isEmpty())
         return { };
-    Vector<String> varyingHeaderNames;
-    varyValue.split(',', varyingHeaderNames);
+    Vector<String> varyingHeaderNames = varyValue.split(',');
     Vector<std::pair<String, String>> varyingRequestHeaders;
     varyingRequestHeaders.reserveCapacity(varyingHeaderNames.size());
     for (auto& varyHeaderName : varyingHeaderNames) {
index 71f176f..9784398 100644 (file)
@@ -277,21 +277,17 @@ std::optional<WallTime> parseHTTPDate(const String& value)
 // in a case-sensitive manner. (There are likely other bugs as well.)
 String filenameFromHTTPContentDisposition(const String& value)
 {
-    Vector<String> keyValuePairs;
-    value.split(';', keyValuePairs);
-
-    unsigned length = keyValuePairs.size();
-    for (unsigned i = 0; i < length; i++) {
-        size_t valueStartPos = keyValuePairs[i].find('=');
+    for (auto& keyValuePair : value.split(';')) {
+        size_t valueStartPos = keyValuePair.find('=');
         if (valueStartPos == notFound)
             continue;
 
-        String key = keyValuePairs[i].left(valueStartPos).stripWhiteSpace();
+        String key = keyValuePair.left(valueStartPos).stripWhiteSpace();
 
         if (key.isEmpty() || key != "filename")
             continue;
         
-        String value = keyValuePairs[i].substring(valueStartPos + 1).stripWhiteSpace();
+        String value = keyValuePair.substring(valueStartPos + 1).stripWhiteSpace();
 
         // Remove quotes if there are any
         if (value[0] == '\"')
@@ -507,11 +503,8 @@ XFrameOptionsDisposition parseXFrameOptionsHeader(const String& header)
     if (header.isEmpty())
         return result;
 
-    Vector<String> headers;
-    header.split(',', headers);
-
-    for (size_t i = 0; i < headers.size(); i++) {
-        String currentHeader = headers[i].stripWhiteSpace();
+    for (auto& currentHeader : header.split(',')) {
+        currentHeader = currentHeader.stripWhiteSpace();
         XFrameOptionsDisposition currentValue = XFrameOptionsNone;
         if (equalLettersIgnoringASCIICase(currentHeader, "deny"))
             currentValue = XFrameOptionsDeny;
@@ -777,9 +770,7 @@ size_t parseHTTPRequestBody(const char* data, size_t length, Vector<unsigned cha
 
 void parseAccessControlExposeHeadersAllowList(const String& headerValue, HTTPHeaderSet& headerSet)
 {
-    Vector<String> headers;
-    headerValue.split(',', false, headers);
-    for (auto& header : headers) {
+    for (auto& header : headerValue.split(',')) {
         String strippedHeader = header.stripWhiteSpace();
         if (!strippedHeader.isEmpty())
             headerSet.add(strippedHeader);
index d62fdbd..9495265 100644 (file)
@@ -171,9 +171,7 @@ bool parseCookieHeader(const String& cookieLine, const String& domain, Cookie& r
     bool hasMaxAge = false;
     result.session = true;
 
-    Vector<String> cookieAttributes;
-    cookieLine.split(';', true, cookieAttributes);
-    for (auto attribute : cookieAttributes)
+    for (auto attribute : cookieLine.splitAllowingEmptyEntries(';'))
         parseCookieAttributes(attribute, domain, hasMaxAge, result);
 
     return true;
index f418bc9..5518e35 100644 (file)
@@ -155,8 +155,7 @@ bool CurlCacheEntry::loadResponseHeaders()
         return false;
 
     String headerContent = String(buffer.data(), buffer.size());
-    Vector<String> headerFields;
-    headerContent.split('\n', headerFields);
+    Vector<String> headerFields = headerContent.split('\n');
 
     Vector<String>::const_iterator it = headerFields.begin();
     Vector<String>::const_iterator end = headerFields.end();
index a8deb98..43bc2e7 100644 (file)
@@ -131,8 +131,7 @@ void CurlCacheManager::loadIndex()
 
     // Create strings from buffer
     String headerContent = String(buffer.data(), buffer.size());
-    Vector<String> indexURLs;
-    headerContent.split('\n', indexURLs);
+    Vector<String> indexURLs = headerContent.split('\n');
     buffer.clear();
 
     // Add entries to index
index f49409a..5ee8761 100644 (file)
@@ -67,11 +67,8 @@ void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstPar
     SoupCookieJar* jar = session.cookieStorage();
     GSList* existingCookies = soup_cookie_jar_get_cookie_list(jar, origin.get(), TRUE);
 
-    Vector<String> cookies;
-    value.split('\n', cookies);
-    const size_t cookiesCount = cookies.size();
-    for (size_t i = 0; i < cookiesCount; ++i) {
-        GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookies[i].utf8().data(), origin.get()));
+    for (auto& cookieString : value.split('\n')) {
+        GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookieString.utf8().data(), origin.get()));
         if (!cookie)
             continue;
 
index 4efb8f1..0f91cd2 100644 (file)
@@ -166,7 +166,7 @@ void SVGAnimationElement::parseAttribute(const QualifiedName& name, const Atomic
         // Per the SMIL specification, leading and trailing white space,
         // and white space before and after semicolon separators, is allowed and will be ignored.
         // http://www.w3.org/TR/SVG11/animate.html#ValuesAttribute
-        value.string().split(';', m_values);
+        m_values = value.string().split(';');
         for (auto& value : m_values)
             value = value.stripWhiteSpace();
 
index 0cf5591..2322791 100644 (file)
@@ -519,8 +519,7 @@ void SVGToOTFFontConverter::appendOS2Table()
     const unsigned panoseSize = 10;
     char panoseBytes[panoseSize];
     if (m_fontFaceElement) {
-        Vector<String> segments;
-        m_fontFaceElement->attributeWithoutSynchronization(SVGNames::panose_1Attr).string().split(' ', segments);
+        Vector<String> segments = m_fontFaceElement->attributeWithoutSynchronization(SVGNames::panose_1Attr).string().split(' ');
         if (segments.size() == panoseSize) {
             for (auto& segment : segments) {
                 bool ok;
index fc5ef2e..0601e5c 100644 (file)
@@ -446,9 +446,7 @@ void SVGSMILElement::parseBeginOrEnd(const String& parseString, BeginOrEnd begin
     HashSet<double> existing;
     for (auto& time : timeList)
         existing.add(time.time().value());
-    Vector<String> splitString;
-    parseString.split(';', splitString);
-    for (auto& string : splitString) {
+    for (auto& string : parseString.split(';')) {
         SMILTime value = parseClockValue(string);
         if (value.isUnresolved())
             parseCondition(string, beginOrEnd);
index 9f2b23f..a7433c6 100644 (file)
@@ -198,8 +198,7 @@ RefPtr<SharedBuffer> MockCDM::sanitizeResponse(const SharedBuffer& response) con
     if (!charactersAreAllASCII(reinterpret_cast<const LChar*>(response.data()), response.size()))
         return nullptr;
 
-    Vector<String> responseArray;
-    String(response.data(), response.size()).split(" "_s, responseArray);
+    Vector<String> responseArray = String(response.data(), response.size()).split(' ');
 
     if (!responseArray.contains(String("valid-response"_s)))
         return nullptr;
@@ -304,8 +303,7 @@ void MockCDMInstance::updateLicense(const String& sessionID, LicenseType, const
         return;
     }
 
-    Vector<String> responseVector;
-    String(response.data(), response.size()).split(" "_s, responseVector);
+    Vector<String> responseVector = String(response.data(), response.size()).split(' ');
 
     if (responseVector.contains(String("invalid-format"_s))) {
         callback(false, std::nullopt, std::nullopt, std::nullopt, SuccessValue::Failed);
index fa28db2..1caf574 100644 (file)
@@ -1,3 +1,16 @@
+2018-07-26  Ross Kirsling  <ross.kirsling@sony.com>
+
+        String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
+        https://bugs.webkit.org/show_bug.cgi?id=187963
+
+        Reviewed by Alex Christensen.
+
+        * WebDriverService.cpp:
+        (WebDriver::WebDriverService::findCommand):
+        * glib/WebDriverServiceGLib.cpp:
+        (WebDriver::parseVersion):
+        Update split/splitAllowingEmptyEntries usage.
+
 2018-07-05  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK][WPE] Add --host option to WebDriver process
index b04e0cf..c33646f 100644 (file)
@@ -197,10 +197,8 @@ bool WebDriverService::findCommand(HTTPMethod method, const String& path, Comman
         if (s_commands[i].method != method)
             continue;
 
-        Vector<String> pathTokens;
-        path.split("/", pathTokens);
-        Vector<String> commandTokens;
-        String::fromUTF8(s_commands[i].uriTemplate).split("/", commandTokens);
+        Vector<String> pathTokens = path.split('/');
+        Vector<String> commandTokens = String::fromUTF8(s_commands[i].uriTemplate).split('/');
         if (pathTokens.size() != commandTokens.size())
             continue;
 
index 971caf1..595d343 100644 (file)
@@ -32,8 +32,7 @@ static bool parseVersion(const String& version, uint64_t& major, uint64_t& minor
 {
     major = minor = micro = 0;
 
-    Vector<String> tokens;
-    version.split(".", false, tokens);
+    Vector<String> tokens = version.split('.');
     bool ok;
     switch (tokens.size()) {
     case 3:
index 3157c7f..e4b95a9 100644 (file)
@@ -1,3 +1,36 @@
+2018-07-26  Ross Kirsling  <ross.kirsling@sony.com>
+
+        String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
+        https://bugs.webkit.org/show_bug.cgi?id=187963
+
+        Reviewed by Alex Christensen.
+
+        * NetworkProcess/cache/CacheStorageEngineCache.cpp:
+        (WebKit::CacheStorage::updateVaryInformation):
+        * NetworkProcess/capture/NetworkCaptureManager.cpp:
+        (WebKit::NetworkCapture::Manager::fuzzyMatchURLs):
+        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+        (WebKit::getPluginInfoFromPropertyLists):
+        (WebKit::PluginVersion::parse):
+        * Shared/Plugins/Netscape/unix/NetscapePluginModuleUnix.cpp:
+        (WebKit::NetscapePluginModule::parseMIMEDescription):
+        * Shared/Plugins/unix/PluginSearchPath.cpp:
+        (WebKit::pluginsDirectories):
+        * Shared/mac/ChildProcessMac.mm:
+        (WebKit::ChildProcess::initializeSandbox):
+        * UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp:
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::fileCanBeAcceptedForUpload):
+        * UIProcess/Launcher/glib/ProcessLauncherGLib.cpp:
+        (WebKit::ProcessLauncher::launchProcess):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::launchProcess):
+        * UIProcess/Plugins/unix/PluginProcessProxyUnix.cpp:
+        (WebKit::PluginProcessProxy::scanPlugin):
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::isTransparentSilverlightBackgroundValue):
+        Update split/splitAllowingEmptyEntries usage.
+
 2018-07-26  Alex Christensen  <achristensen@webkit.org>
 
         Fix assertions introduced in r234210
index ac8bbc2..69155ff 100644 (file)
@@ -85,7 +85,7 @@ static inline void updateVaryInformation(RecordInformation& recordInformation, c
         return;
     }
 
-    varyValue.split(',', false, [&](StringView view) {
+    varyValue.split(',', [&](StringView view) {
         if (!recordInformation.hasVaryStar && stripLeadingAndTrailingHTTPSpaces(view) == "*")
             recordInformation.hasVaryStar = true;
         String headerName = view.toString();
index 5613be8..d679cd3 100644 (file)
@@ -216,9 +216,8 @@ int Manager::fuzzyMatchURLs(const WebCore::URL& requestURL, const WebCore::URLPa
     const auto& requestPath = requestURL.path();
     const auto& resourcePath = resourceURL.path();
 
-    Vector<String> requestPathComponents, resourcePathComponents;
-    requestPath.split('/', requestPathComponents);
-    resourcePath.split('/', resourcePathComponents);
+    Vector<String> requestPathComponents = requestPath.split('/');
+    Vector<String> resourcePathComponents = resourcePath.split('/');
 
     auto updatedIterators = std::mismatch(
         std::begin(requestPathComponents), std::end(requestPathComponents),
index feea1ef..68d7c6a 100644 (file)
@@ -149,8 +149,7 @@ static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginModuleInfo&
             // The DivX plug-in lists multiple extensions in a comma separated string instead of using
             // multiple array elements in the property list. Work around this here by splitting the
             // extension string into components.
-            Vector<String> extensionComponents;
-            String(extension).convertToASCIILowercase().split(',', extensionComponents);
+            Vector<String> extensionComponents = String(extension).convertToASCIILowercase().split(',');
 
             for (auto& component : extensionComponents)
                 mimeClassInfo.extensions.append(component);
@@ -237,8 +236,7 @@ PluginVersion PluginVersion::parse(const String& versionString)
 {
     PluginVersion version;
 
-    Vector<String> versionStringComponents;
-    versionString.split('.', versionStringComponents);
+    Vector<String> versionStringComponents = versionString.split('.');
     for (size_t i = 0; i < versionStringComponents.size(); ++i) {
         bool successfullyParsed = false;
         unsigned versionComponent = versionStringComponents[i].toUInt(&successfullyParsed);
index f9eb06e..fb1d9dc 100644 (file)
@@ -74,14 +74,12 @@ void NetscapePluginModule::parseMIMEDescription(const String& mimeDescription, V
 {
     ASSERT_ARG(result, result.isEmpty());
 
-    Vector<String> types;
-    mimeDescription.convertToASCIILowercase().split(UChar(';'), false, types);
+    Vector<String> types = mimeDescription.convertToASCIILowercase().split(';');
     result.reserveInitialCapacity(types.size());
 
     size_t mimeInfoCount = 0;
     for (size_t i = 0; i < types.size(); ++i) {
-        Vector<String> mimeTypeParts;
-        types[i].split(UChar(':'), true, mimeTypeParts);
+        Vector<String> mimeTypeParts = types[i].splitAllowingEmptyEntries(':');
         if (mimeTypeParts.size() <= 0)
             continue;
 
@@ -90,7 +88,7 @@ void NetscapePluginModule::parseMIMEDescription(const String& mimeDescription, V
         mimeInfo.type = mimeTypeParts[0];
 
         if (mimeTypeParts.size() > 1)
-            mimeTypeParts[1].split(UChar(','), false, mimeInfo.extensions);
+            mimeInfo.extensions = mimeTypeParts[1].split(',');
 
         if (mimeTypeParts.size() > 2)
             mimeInfo.desc = mimeTypeParts[2];
index 34205ad..e8af960 100644 (file)
@@ -38,8 +38,7 @@ Vector<String> pluginsDirectories()
 #if ENABLE(NETSCAPE_PLUGIN_API)
     String mozillaPaths(getenv("MOZ_PLUGIN_PATH"));
     if (!mozillaPaths.isEmpty()) {
-        Vector<String> paths;
-        mozillaPaths.split(UChar(':'), /* allowEmptyEntries */ false, paths);
+        Vector<String> paths = mozillaPaths.split(':');
         result.appendVector(paths);
     }
 
index b085ff9..88636a8 100644 (file)
@@ -134,9 +134,8 @@ void ChildProcess::initializeSandbox(const ChildProcessInitializationParameters&
         }
     }
 
-    Vector<String> osVersionParts;
     String osSystemMarketingVersion = systemMarketingVersion();
-    osSystemMarketingVersion.split('.', false, osVersionParts);
+    Vector<String> osVersionParts = osSystemMarketingVersion.split('.');
     if (osVersionParts.size() < 2) {
         WTFLogAlways("%s: Couldn't find OS Version\n", getprogname());
         exit(EX_NOPERM);
index 1917c19..b266a95 100644 (file)
@@ -44,8 +44,7 @@ public:
     void didPostMessage(WebPageProxy& page, const FrameInfoData&, WebCore::SerializedScriptValue& serializedScriptValue) override
     {
         String message = serializedScriptValue.toString();
-        Vector<String> tokens;
-        message.split(":", tokens);
+        Vector<String> tokens = message.split(':');
         if (tokens.size() != 2)
             return;
 
index 77878aa..c36f3cd 100644 (file)
@@ -806,8 +806,7 @@ static bool fileCanBeAcceptedForUpload(const String& filename, const HashSet<Str
         return true;
 
     // Fall back to checking for a MIME type wildcard if an exact match is not found.
-    Vector<String> components;
-    mappedMIMEType.split('/', false, components);
+    Vector<String> components = mappedMIMEType.split('/');
     if (components.size() != 2)
         return false;
 
index ead3d1b..5291697 100644 (file)
@@ -114,9 +114,7 @@ void ProcessLauncher::launchProcess()
 #if ENABLE(DEVELOPER_MODE)
     Vector<CString> prefixArgs;
     if (!m_launchOptions.processCmdPrefix.isNull()) {
-        Vector<String> splitArgs;
-        m_launchOptions.processCmdPrefix.split(' ', splitArgs);
-        for (auto& arg : splitArgs)
+        for (auto& arg : m_launchOptions.processCmdPrefix.split(' '))
             prefixArgs.append(arg.utf8());
         nargs += prefixArgs.size();
     }
index 5e40f26..b47f7d0 100644 (file)
@@ -128,9 +128,7 @@ void ProcessLauncher::launchProcess()
     auto languagesIterator = m_launchOptions.extraInitializationData.find("OverrideLanguages");
     if (languagesIterator != m_launchOptions.extraInitializationData.end()) {
         auto languages = adoptOSObject(xpc_array_create(nullptr, 0));
-        Vector<String> languageVector;
-        languagesIterator->value.split(",", false, languageVector);
-        for (auto& language : languageVector)
+        for (auto& language : languagesIterator->value.split(','))
             xpc_array_set_string(languages.get(), XPC_ARRAY_APPEND, language.utf8().data());
         xpc_dictionary_set_value(initializationMessage.get(), "OverrideLanguages", languages.get());
     }
index af0341c..f9ef2ca 100644 (file)
@@ -137,8 +137,7 @@ bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData&
         return false;
     }
 
-    Vector<String> lines;
-    String::fromUTF8(stdOut.get()).split(UChar('\n'), true, lines);
+    Vector<String> lines = String::fromUTF8(stdOut.get()).splitAllowingEmptyEntries('\n');
 
     if (lines.size() < 3) {
         WTFLogAlways("Error scanning plugin %s, too few lines of output provided", argv[2]);
index d1c3684..68fb71a 100644 (file)
@@ -601,8 +601,7 @@ static bool isTransparentSilverlightBackgroundValue(const String& lowercaseBackg
             return true;
         }
     } else if (lowercaseBackgroundValue.startsWith("sc#")) {
-        Vector<String> components;
-        lowercaseBackgroundValue.substring(3).split(',', components);
+        Vector<String> components = lowercaseBackgroundValue.substring(3).split(',');
 
         // An ScRGB value with alpha transparency, in the form sc#A,R,G,B.
         if (components.size() == 4) {
index 49e1ef5..a73dfef 100644 (file)
@@ -1,3 +1,14 @@
+2018-07-26  Ross Kirsling  <ross.kirsling@sony.com>
+
+        String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
+        https://bugs.webkit.org/show_bug.cgi?id=187963
+
+        Reviewed by Alex Christensen.
+
+        * Plugins/PluginPackageWin.cpp:
+        (WebCore::PluginPackage::fetchInfo):
+        Update split/splitAllowingEmptyEntries usage.
+
 2018-07-18  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Interpolation between font-styles with a keyword value should be discrete
index eb57273..94bba6a 100644 (file)
@@ -190,20 +190,16 @@ bool PluginPackage::fetchInfo()
     if (isPluginBlacklisted())
         return false;
 
-    Vector<String> types;
-    getVersionInfo(versionInfoData.data(), "MIMEType").split('|', types);
-    Vector<String> extensionLists;
-    getVersionInfo(versionInfoData.data(), "FileExtents").split('|', extensionLists);
-    Vector<String> descriptions;
-    getVersionInfo(versionInfoData.data(), "FileOpenName").split('|', descriptions);
+    Vector<String> types = getVersionInfo(versionInfoData.data(), "MIMEType").split('|');
+    Vector<String> extensionLists = getVersionInfo(versionInfoData.data(), "FileExtents").split('|');
+    Vector<String> descriptions = getVersionInfo(versionInfoData.data(), "FileOpenName").split('|');
 
     for (unsigned i = 0; i < types.size(); i++) {
         String type = types[i].convertToASCIILowercase();
         String description = i < descriptions.size() ? descriptions[i] : "";
         String extensionList = i < extensionLists.size() ? extensionLists[i] : "";
 
-        Vector<String> extensionsVector;
-        extensionList.split(',', extensionsVector);
+        Vector<String> extensionsVector = extensionList.split(',');
 
         // Get rid of the extension list that may be at the end of the description string.
         int pos = description.find("(*");
index f092bc9..b787df3 100644 (file)
@@ -1,3 +1,18 @@
+2018-07-26  Ross Kirsling  <ross.kirsling@sony.com>
+
+        String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter
+        https://bugs.webkit.org/show_bug.cgi?id=187963
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/WTF/WTFString.cpp:
+        Add tests for String::split and String::splitAllowingEmptyEntries.
+
+        * TestWebKitAPI/Tests/WTF/StringView.cpp:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::updateTestOptionsFromTestHeader):
+        Update split/splitAllowingEmptyEntries usage.
+
 2018-07-26  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r234181 and r234189.
index c8bb114..b751f68 100644 (file)
@@ -297,7 +297,7 @@ TEST(WTF, StringViewSplitWithConsecutiveSeparators)
     for (size_t i = 0; i < actual.size(); ++i)
         EXPECT_STREQ(expected[i].utf8().data(), actual[i].utf8().data()) << "Vectors differ at index " << i;
 
-    actual = vectorFromSplitResult(a.split(' ', StringView::AllowEmptyEntries));
+    actual = vectorFromSplitResult(a.splitAllowingEmptyEntries(' '));
     expected = { "", "This", "", "", "", "", "is", "", "a", "", "", "", "", "", "", "sentence.", "" };
     ASSERT_EQ(expected.size(), actual.size());
     for (size_t i = 0; i < actual.size(); ++i)
index 5cb6c76..8ecc4d4 100644 (file)
@@ -499,4 +499,21 @@ TEST(WTF, StringFormatWithArguments)
     testWithFormatAndArguments("hello -17890.5 world", "%s %.1f %s", "hello", -17890.5, "world");
 }
 
+TEST(WTF, StringSplitWithConsecutiveSeparators)
+{
+    String string { " This     is  a       sentence. " };
+
+    Vector<String> actual = string.split(' ');
+    Vector<String> expected { "This", "is", "a", "sentence." };
+    ASSERT_EQ(expected.size(), actual.size());
+    for (auto i = 0u; i < actual.size(); ++i)
+        EXPECT_STREQ(expected[i].utf8().data(), actual[i].utf8().data()) << "Vectors differ at index " << i;
+
+    actual = string.splitAllowingEmptyEntries(' ');
+    expected = { "", "This", "", "", "", "", "is", "", "a", "", "", "", "", "", "", "sentence.", "" };
+    ASSERT_EQ(expected.size(), actual.size());
+    for (auto i = 0u; i < actual.size(); ++i)
+        EXPECT_STREQ(expected[i].utf8().data(), actual[i].utf8().data()) << "Vectors differ at index " << i;
+}
+
 } // namespace TestWebKitAPI
index 3ea3c0a..75d2ddb 100644 (file)
@@ -1088,7 +1088,7 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std:
         auto key = pairString.substr(pairStart, equalsLocation - pairStart);
         auto value = pairString.substr(equalsLocation + 1, pairEnd - (equalsLocation + 1));
         if (key == "language")
-            String(value.c_str()).split(",", false, testOptions.overrideLanguages);
+            testOptions.overrideLanguages = String(value.c_str()).split(',');
         else if (key == "useThreadedScrolling")
             testOptions.useThreadedScrolling = parseBooleanTestHeaderValue(value);
         else if (key == "useAcceleratedDrawing")