Title: [293202] trunk
Revision
293202
Author
[email protected]
Date
2022-04-21 17:17:19 -0700 (Thu, 21 Apr 2022)

Log Message

[WTF] Add string concatenate adapter for UUID
https://bugs.webkit.org/show_bug.cgi?id=239590

Reviewed by Chris Dumez and Darin Adler.

This patch adds string concatenate adapter for UUID.
UUID's stringifier consists of multiple string concatenate adapters.
This patch adds WTF::handleWithAdapters so that we can define adapters
once, and we can semi-automatically define length() and writeTo method for UUID.

And we use UUID + makeString instead of createVersion4UUIDString. This is more
efficient since we do not need to allocate string twice.

* Source/WTF/wtf/UUID.cpp:
(WTF::UUID::generateWeakRandomUUIDVersion4):
(WTF::createVersion4UUIDString):
(WTF::generateWeakRandomUUIDVersion4): Deleted.
(WTF::UUID::toString const): Deleted.
(WTF::createVersion4UUIDStringWeak): Deleted.
* Source/WTF/wtf/UUID.h:
(WTF::UUID::createVersion4Weak):
(WTF::UUID::isHashTableDeletedValue const):
(WTF::UUID::data const):
(WTF::StringTypeAdapter<UUID>::StringTypeAdapter):
(WTF::StringTypeAdapter<UUID>::length const):
(WTF::StringTypeAdapter<UUID>::is8Bit const):
(WTF::StringTypeAdapter<UUID>::writeTo const):
* Source/WebCore/animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::copyPropertiesFromSource):
(WebCore::KeyframeEffect::updateBlendingKeyframes):
(WebCore::KeyframeEffect::computeCSSTransitionBlendingKeyframes):
* Tools/TestWebKitAPI/Tests/WTF/UUID.cpp:
(TEST):

Canonical link: https://commits.webkit.org/249873@main

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (293201 => 293202)


--- trunk/Source/WTF/ChangeLog	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WTF/ChangeLog	2022-04-22 00:17:19 UTC (rev 293202)
@@ -1,3 +1,37 @@
+2022-04-20  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Add string concatenate adapter for UUID
+        https://bugs.webkit.org/show_bug.cgi?id=239590
+
+        Reviewed by Chris Dumez and Darin Adler.
+
+        This patch adds string concatenate adapter for UUID.
+        UUID's stringifier consists of multiple string concatenate adapters.
+        This patch adds WTF::handleWithAdapters so that we can define adapters
+        once, and we can semi-automatically define length() and writeTo method for UUID.
+
+        And we use UUID + makeString instead of createVersion4UUIDString. This is more
+        efficient since we do not need to allocate string twice.
+
+        * wtf/URL.cpp:
+        (WTF::URL::fakeURLWithRelativePart):
+        * wtf/UUID.cpp:
+        (WTF::UUID::generateWeakRandomUUIDVersion4):
+        (WTF::UUID::toString const):
+        (WTF::createVersion4UUIDString):
+        (WTF::generateWeakRandomUUIDVersion4): Deleted.
+        (WTF::createVersion4UUIDStringWeak): Deleted.
+        * wtf/UUID.h:
+        (WTF::UUID::createVersion4Weak):
+        (WTF::UUID::data const):
+        (WTF::StringTypeAdapter<UUID>::StringTypeAdapter):
+        (WTF::StringTypeAdapter<UUID>::handle const):
+        (WTF::StringTypeAdapter<UUID>::length const):
+        (WTF::StringTypeAdapter<UUID>::is8Bit const):
+        (WTF::StringTypeAdapter<UUID>::writeTo const):
+        * wtf/text/StringConcatenate.h:
+        (WTF::handleWithAdapters):
+
 2022-04-21  Brent Fulgham  <[email protected]>
 
         Remove XSS Auditor: Part 4 (Settings)

Modified: trunk/Source/WTF/wtf/URL.cpp (293201 => 293202)


--- trunk/Source/WTF/wtf/URL.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WTF/wtf/URL.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -1048,13 +1048,13 @@
 
 URL URL::fakeURLWithRelativePart(StringView relativePart)
 {
-    return URL(makeString("webkit-fake-url://", createVersion4UUIDString(), '/', relativePart));
+    return URL(makeString("webkit-fake-url://"_s, UUID::createVersion4(), '/', relativePart));
 }
 
 URL URL::fileURLWithFileSystemPath(StringView path)
 {
     return URL(makeString(
-        "file://",
+        "file://"_s,
         path.startsWith('/') ? "" : "/",
         escapePathWithoutCopying(path)
     ));

Modified: trunk/Source/WTF/wtf/UUID.cpp (293201 => 293202)


--- trunk/Source/WTF/wtf/UUID.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WTF/wtf/UUID.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -62,7 +62,7 @@
     return convertRandomUInt128ToUUIDVersion4(buffer);
 }
 
-static UInt128 generateWeakRandomUUIDVersion4()
+UInt128 UUID::generateWeakRandomUUIDVersion4()
 {
     static Lock lock;
     UInt128 buffer { 0 };
@@ -83,21 +83,7 @@
 
 String UUID::toString() const
 {
-    auto high = static_cast<uint64_t>(m_data >> 64);
-    auto low = static_cast<uint64_t>(m_data & 0xffffffffffffffff);
-
-    // Format as Version 4 UUID.
-    return makeString(
-        hex(high >> 32, 8, Lowercase),
-        '-',
-        hex((high >> 16) & 0xffff, 4, Lowercase),
-        '-',
-        hex(high & 0xffff, 4, Lowercase),
-        '-',
-        hex(low >> 48, 4, Lowercase),
-        '-',
-        hex(low & 0xffffffffffff, 12, Lowercase)
-    );
+    return makeString(*this);
 }
 
 std::optional<UUID> UUID::parse(StringView value)
@@ -163,14 +149,9 @@
 
 String createVersion4UUIDString()
 {
-    return UUID::createVersion4().toString();
+    return makeString(UUID::createVersion4());
 }
 
-String createVersion4UUIDStringWeak()
-{
-    return UUID(generateWeakRandomUUIDVersion4()).toString();
-}
-
 String bootSessionUUIDString()
 {
 #if OS(DARWIN)

Modified: trunk/Source/WTF/wtf/UUID.h (293201 => 293202)


--- trunk/Source/WTF/wtf/UUID.h	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WTF/wtf/UUID.h	2022-04-22 00:17:19 UTC (rev 293202)
@@ -31,6 +31,7 @@
 #pragma once
 
 #include <wtf/Hasher.h>
+#include <wtf/HexNumber.h>
 #include <wtf/Int128.h>
 #include <wtf/text/WTFString.h>
 
@@ -49,6 +50,11 @@
         return UUID { };
     }
 
+    static UUID createVersion4Weak()
+    {
+        return UUID { generateWeakRandomUUIDVersion4() };
+    }
+
     static std::optional<UUID> parse(StringView);
     WTF_EXPORT_PRIVATE static std::optional<UUID> parseVersion4(StringView);
 
@@ -87,10 +93,14 @@
 
     operator bool() const { return !!m_data; }
 
+    UInt128 data() const { return m_data; }
+
 private:
     WTF_EXPORT_PRIVATE UUID();
     friend void add(Hasher&, UUID);
 
+    WTF_EXPORT_PRIVATE static UInt128 generateWeakRandomUUIDVersion4();
+
     UInt128 m_data;
 };
 
@@ -148,14 +158,62 @@
 // 9, A, or B for y.
 
 WTF_EXPORT_PRIVATE String createVersion4UUIDString();
-WTF_EXPORT_PRIVATE String createVersion4UUIDStringWeak();
 
 WTF_EXPORT_PRIVATE String bootSessionUUIDString();
 WTF_EXPORT_PRIVATE bool isVersion4UUID(StringView);
 
+template<>
+class StringTypeAdapter<UUID> {
+public:
+    StringTypeAdapter(UUID uuid)
+        : m_uuid { uuid }
+    {
+    }
+
+    template<typename Func>
+    auto handle(Func&& func) const -> decltype(auto)
+    {
+        UInt128 data = ""
+        auto high = static_cast<uint64_t>(data >> 64);
+        auto low = static_cast<uint64_t>(data);
+        return handleWithAdapters(std::forward<Func>(func),
+            hex(high >> 32, 8, Lowercase),
+            '-',
+            hex((high >> 16) & 0xffff, 4, Lowercase),
+            '-',
+            hex(high & 0xffff, 4, Lowercase),
+            '-',
+            hex(low >> 48, 4, Lowercase),
+            '-',
+            hex(low & 0xffffffffffff, 12, Lowercase));
+    }
+
+    unsigned length() const
+    {
+        return handle([](auto&&... adapters) -> unsigned {
+            auto sum = checkedSum<int32_t>(adapters.length()...);
+            if (sum.hasOverflowed())
+                return UINT_MAX;
+            return sum;
+        });
+    }
+
+    bool is8Bit() const { return true; }
+
+    template<typename CharacterType>
+    void writeTo(CharacterType* destination) const
+    {
+        handle([&](auto&&... adapters) {
+            stringTypeAdapterAccumulator(destination, std::forward<decltype(adapters)>(adapters)...);
+        });
+    }
+
+private:
+    UUID m_uuid;
+};
+
 }
 
 using WTF::UUID;
 using WTF::createVersion4UUIDString;
-using WTF::createVersion4UUIDStringWeak;
 using WTF::bootSessionUUIDString;

Modified: trunk/Source/WTF/wtf/text/StringConcatenate.h (293201 => 293202)


--- trunk/Source/WTF/wtf/text/StringConcatenate.h	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WTF/wtf/text/StringConcatenate.h	2022-04-22 00:17:19 UTC (rev 293202)
@@ -457,6 +457,12 @@
     return resultImpl;
 }
 
+template<typename Func, typename... StringTypes>
+auto handleWithAdapters(Func&& func, StringTypes&& ...strings) -> decltype(auto)
+{
+    return func(StringTypeAdapter<StringTypes>(std::forward<StringTypes>(strings))...);
+}
+
 template<typename StringTypeAdapter, typename... StringTypeAdapters>
 String tryMakeStringFromAdapters(StringTypeAdapter adapter, StringTypeAdapters ...adapters)
 {

Modified: trunk/Source/WebCore/ChangeLog (293201 => 293202)


--- trunk/Source/WebCore/ChangeLog	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/ChangeLog	2022-04-22 00:17:19 UTC (rev 293202)
@@ -1,3 +1,25 @@
+2022-04-20  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Add string concatenate adapter for UUID
+        https://bugs.webkit.org/show_bug.cgi?id=239590
+
+        Reviewed by Chris Dumez and Darin Adler.
+
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::generateDatabaseFileName):
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::copyPropertiesFromSource):
+        (WebCore::KeyframeEffect::updateBlendingKeyframes):
+        (WebCore::KeyframeEffect::computeCSSTransitionBlendingKeyframes):
+        * dom/Document.cpp:
+        (WebCore::Document::originIdentifierForPasteboard const):
+        * fileapi/BlobURL.cpp:
+        (WebCore::BlobURL::createBlobURL):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::updateAnimations):
+
 2022-04-21  Chris Dumez  <[email protected]>
 
         Simplify FrameSelection::textWasReplaced() and callers

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (293201 => 293202)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -300,7 +300,7 @@
 
 static String generateDatabaseFileName()
 {
-    return makeString(createVersion4UUIDString(), ".db");
+    return makeString(UUID::createVersion4(), ".db"_s);
 }
 
 String DatabaseTracker::fullPathForDatabaseNoLock(const SecurityOriginData& origin, const String& name, bool createIfNotExists)

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (293201 => 293202)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -585,7 +585,7 @@
     setIterationDuration(source->iterationDuration());
     updateStaticTimingProperties();
 
-    KeyframeList keyframeList("keyframe-effect-" + createVersion4UUIDStringWeak());
+    KeyframeList keyframeList(makeString("keyframe-effect-"_s, UUID::createVersion4Weak()));
     keyframeList.copyKeyframes(source->m_blendingKeyframes);
     setBlendingKeyframes(keyframeList);
 }
@@ -811,7 +811,7 @@
     if (!m_blendingKeyframes.isEmpty() || !m_target)
         return;
 
-    KeyframeList keyframeList("keyframe-effect-" + createVersion4UUIDStringWeak());
+    KeyframeList keyframeList(makeString("keyframe-effect-"_s, UUID::createVersion4Weak()));
     auto& styleResolver = m_target->styleResolver();
 
     for (auto& keyframe : m_parsedKeyframes) {
@@ -1037,7 +1037,7 @@
     if (m_target)
         Style::loadPendingResources(*toStyle, *document(), m_target.get());
 
-    KeyframeList keyframeList("keyframe-effect-" + createVersion4UUIDStringWeak());
+    KeyframeList keyframeList(makeString("keyframe-effect-"_s, UUID::createVersion4Weak()));
     keyframeList.addProperty(property);
 
     KeyframeValue fromKeyframeValue(0, RenderStyle::clonePtr(*oldStyle));

Modified: trunk/Source/WebCore/dom/Document.cpp (293201 => 293202)


--- trunk/Source/WebCore/dom/Document.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -6261,7 +6261,7 @@
     if (origin != "null")
         return origin;
     if (!m_uniqueIdentifier)
-        m_uniqueIdentifier = "null:" + createVersion4UUIDString();
+        m_uniqueIdentifier = makeString("null:"_s, UUID::createVersion4());
     return m_uniqueIdentifier;
 }
 

Modified: trunk/Source/WebCore/fileapi/BlobURL.cpp (293201 => 293202)


--- trunk/Source/WebCore/fileapi/BlobURL.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/fileapi/BlobURL.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -89,10 +89,10 @@
     return SecurityOrigin::isSecure(url);
 }
 
-URL BlobURL::createBlobURL(const String& originString)
+URL BlobURL::createBlobURL(StringView originString)
 {
     ASSERT(!originString.isEmpty());
-    String urlString = "blob:" + originString + '/' + createVersion4UUIDString();
+    String urlString = makeString("blob:"_s, originString, '/', UUID::createVersion4());
     return URL({ }, urlString);
 }
 

Modified: trunk/Source/WebCore/fileapi/BlobURL.h (293201 => 293202)


--- trunk/Source/WebCore/fileapi/BlobURL.h	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/fileapi/BlobURL.h	2022-04-22 00:17:19 UTC (rev 293202)
@@ -54,7 +54,7 @@
     static bool isSecureBlobURL(const URL&);
 
 private:
-    static URL createBlobURL(const String& originString);
+    static URL createBlobURL(StringView originString);
     BlobURL() { }
 };
 

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp (293201 => 293202)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -1277,10 +1277,7 @@
     String fullPath;
     
     do {
-        path = makeString(FileSystem::encodeForFileName(createVersion4UUIDString()), fileExtension);
-        // Guard against the above function being called on a platform which does not implement
-        // createVersion4UUIDString().
-        ASSERT(!path.isEmpty());
+        path = makeString(UUID::createVersion4(), fileExtension);
         if (path.isEmpty())
             return false;
         

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (293201 => 293202)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -3106,7 +3106,7 @@
         caAnimationGroup->setDuration(infiniteDuration);
         caAnimationGroup->setAnimations(animations);
 
-        auto animationGroup = LayerPropertyAnimation(WTFMove(caAnimationGroup), "group-" + createVersion4UUIDString(), property, 0, 0, 0_s);
+        auto animationGroup = LayerPropertyAnimation(WTFMove(caAnimationGroup), makeString("group-"_s, UUID::createVersion4()), property, 0, 0, 0_s);
         animationGroup.m_beginTime = animationGroupBeginTime;
 
         setAnimationOnLayer(animationGroup);
@@ -3154,7 +3154,7 @@
         caAnimation->setFromValue(matrix);
         caAnimation->setToValue(matrix);
 
-        auto animation = LayerPropertyAnimation(WTFMove(caAnimation), "base-transform-" + createVersion4UUIDString(), property, 0, 0, 0_s);
+        auto animation = LayerPropertyAnimation(WTFMove(caAnimation), makeString("base-transform-"_s, UUID::createVersion4()), property, 0, 0, 0_s);
         if (delay)
             animation.m_beginTime = currentTime - animationGroupBeginTime;
 

Modified: trunk/Source/WebKit/ChangeLog (293201 => 293202)


--- trunk/Source/WebKit/ChangeLog	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKit/ChangeLog	2022-04-22 00:17:19 UTC (rev 293202)
@@ -1,3 +1,24 @@
+2022-04-20  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Add string concatenate adapter for UUID
+        https://bugs.webkit.org/show_bug.cgi?id=239590
+
+        Reviewed by Chris Dumez and Darin Adler.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::addStorageSession):
+        * NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
+        (WebKit::NetworkMDNSRegister::registerMDNSName):
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::handleForWebPageProxy):
+        (WebKit::WebAutomationSession::handleForWebFrameID):
+        * UIProcess/gtk/WaylandCompositor.cpp:
+        (WebKit::WaylandCompositor::WaylandCompositor):
+        * UIProcess/ios/WKModelView.mm:
+        (-[WKModelView createFileForModel:]):
+        * WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm:
+        (WebKit::ARKitInlinePreviewModelPlayerMac::createFile):
+
 2022-04-21  Chris Dumez  <[email protected]>
 
         Adopt RobinHoodHashMap / RobinHoodHashSet more broadly in WebCore

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (293201 => 293202)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -419,7 +419,7 @@
 
     auto identifierBase = makeString(uiProcessBundleIdentifier(), '.', sessionID.toUInt64());
     RetainPtr<CFURLStorageSessionRef> storageSession;
-    auto cfIdentifier = makeString(identifierBase, ".PrivateBrowsing.", createVersion4UUIDString()).createCFString();
+    auto cfIdentifier = makeString(identifierBase, ".PrivateBrowsing."_s, UUID::createVersion4()).createCFString();
     if (sessionID.isEphemeral())
         storageSession = createPrivateStorageSession(cfIdentifier.get(), std::nullopt, WebCore::NetworkStorageSession::ShouldDisableCFURLCache::Yes);
     else if (sessionID != PAL::SessionID::defaultSessionID())

Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp (293201 => 293202)


--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -106,7 +106,7 @@
 
 void NetworkMDNSRegister::registerMDNSName(MDNSRegisterIdentifier requestIdentifier, WebCore::ScriptExecutionContextIdentifier documentIdentifier, const String& ipAddress)
 {
-    auto name = makeString(createVersion4UUIDString(), ".local");
+    auto name = makeString(UUID::createVersion4(), ".local"_s);
 
     DNSServiceRef service;
     auto iterator = m_services.find(documentIdentifier);
@@ -172,7 +172,7 @@
 void NetworkMDNSRegister::registerMDNSName(MDNSRegisterIdentifier requestIdentifier, WebCore::ScriptExecutionContextIdentifier documentIdentifier, const String& ipAddress)
 {
     MDNS_RELEASE_LOG("registerMDNSName not implemented");
-    auto name = makeString(createVersion4UUIDString(), ".local");
+    auto name = makeString(UUID::createVersion4(), ".local"_s);
 
     m_connection.connection().send(Messages::WebMDNSRegister::FinishedRegisteringMDNSName { requestIdentifier, name, WebCore::MDNSRegisterError::NotImplemented }, 0);
 }

Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (293201 => 293202)


--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -190,7 +190,7 @@
     if (iter != m_webPageHandleMap.end())
         return iter->value;
 
-    String handle = "page-" + createVersion4UUIDString().convertToASCIIUppercase();
+    String handle = makeString("page-"_s, createVersion4UUIDString().convertToASCIIUppercase());
 
     auto firstAddResult = m_webPageHandleMap.add(webPageProxy.identifier(), handle);
     RELEASE_ASSERT(firstAddResult.isNewEntry);
@@ -239,7 +239,7 @@
     if (iter != m_webFrameHandleMap.end())
         return iter->value;
 
-    String handle = "frame-" + createVersion4UUIDString().convertToASCIIUppercase();
+    String handle = makeString("frame-"_s, createVersion4UUIDString().convertToASCIIUppercase());
 
     auto firstAddResult = m_webFrameHandleMap.add(*frameID, handle);
     RELEASE_ASSERT(firstAddResult.isNewEntry);

Modified: trunk/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp (293201 => 293202)


--- trunk/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -501,7 +501,7 @@
         return;
     }
 
-    String displayName = "webkitgtk-wayland-compositor-" + createVersion4UUIDString();
+    String displayName = makeString("webkitgtk-wayland-compositor-"_s, UUID::createVersion4());
     if (wl_display_add_socket(display.get(), displayName.utf8().data()) == -1) {
         WTFLogAlways("Nested Wayland compositor could not create display socket");
         return;

Modified: trunk/Source/WebKit/UIProcess/ios/WKModelView.mm (293201 => 293202)


--- trunk/Source/WebKit/UIProcess/ios/WKModelView.mm	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKit/UIProcess/ios/WKModelView.mm	2022-04-22 00:17:19 UTC (rev 293202)
@@ -102,7 +102,7 @@
         return NO;
     }
 
-    String fileName = FileSystem::encodeForFileName(createVersion4UUIDString()) + ".usdz";
+    String fileName = makeString(UUID::createVersion4(), ".usdz"_s);
     auto filePath = FileSystem::pathByAppendingComponent(pathToDirectory, fileName);
     auto file = FileSystem::openFile(filePath, FileSystem::FileOpenMode::Write);
     if (file <= 0)

Modified: trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm (293201 => 293202)


--- trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm	2022-04-22 00:17:19 UTC (rev 293202)
@@ -107,7 +107,7 @@
     }
 
     // We need to support .reality files as well, https://bugs.webkit.org/show_bug.cgi?id=227568.
-    String fileName = FileSystem::encodeForFileName(createVersion4UUIDString()) + ".usdz";
+    String fileName = makeString(UUID::createVersion4(), ".usdz"_s);
     auto filePath = FileSystem::pathByAppendingComponent(pathToDirectory, fileName);
     auto file = FileSystem::openFile(filePath, FileSystem::FileOpenMode::Write);
     if (file <= 0)

Modified: trunk/Source/WebKitLegacy/ChangeLog (293201 => 293202)


--- trunk/Source/WebKitLegacy/ChangeLog	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKitLegacy/ChangeLog	2022-04-22 00:17:19 UTC (rev 293202)
@@ -1,3 +1,13 @@
+2022-04-20  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Add string concatenate adapter for UUID
+        https://bugs.webkit.org/show_bug.cgi?id=239590
+
+        Reviewed by Chris Dumez and Darin Adler.
+
+        * WebCoreSupport/NetworkStorageSessionMap.cpp:
+        (NetworkStorageSessionMap::ensureSession):
+
 2022-04-18  Elliott Williams  <[email protected]>
 
         [XCBuild] Use XCBuild for all command-line and project builds

Modified: trunk/Source/WebKitLegacy/WebCoreSupport/NetworkStorageSessionMap.cpp (293201 => 293202)


--- trunk/Source/WebKitLegacy/WebCoreSupport/NetworkStorageSessionMap.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Source/WebKitLegacy/WebCoreSupport/NetworkStorageSessionMap.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -64,7 +64,7 @@
 {
 #if PLATFORM(COCOA) || USE(CFURLCONNECTION)
     // Session name should be short enough for shared memory region name to be under the limit, otherwise sandbox rules won't work (see <rdar://problem/13642852>).
-    auto session = WebCore::createPrivateStorageSession(makeString("WebKit Test-", getCurrentProcessID()).createCFString().get());
+    auto session = WebCore::createPrivateStorageSession(makeString("WebKit Test-"_s, getCurrentProcessID()).createCFString().get());
 
     RetainPtr<CFHTTPCookieStorageRef> cookieStorage;
     if (WebCore::NetworkStorageSession::processMayUseCookieAPI()) {
@@ -84,7 +84,7 @@
     if (!addResult.isNewEntry)
         return;
 
-    auto identifier = makeString(identifierBase, ".PrivateBrowsing.", createVersion4UUIDString()).createCFString();
+    auto identifier = makeString(identifierBase, ".PrivateBrowsing."_s, UUID::createVersion4()).createCFString();
 
     RetainPtr<CFURLStorageSessionRef> storageSession;
     if (sessionID.isEphemeral())

Modified: trunk/Tools/ChangeLog (293201 => 293202)


--- trunk/Tools/ChangeLog	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Tools/ChangeLog	2022-04-22 00:17:19 UTC (rev 293202)
@@ -1,3 +1,13 @@
+2022-04-20  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Add string concatenate adapter for UUID
+        https://bugs.webkit.org/show_bug.cgi?id=239590
+
+        Reviewed by Chris Dumez and Darin Adler.
+
+        * TestWebKitAPI/Tests/WTF/UUID.cpp:
+        (TEST):
+
 2022-04-21  Simon Fraser  <[email protected]>
 
         <body> with overflow:hidden CSS is scrollable on iOS standalone web app

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/UUID.cpp (293201 => 293202)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/UUID.cpp	2022-04-22 00:09:20 UTC (rev 293201)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/UUID.cpp	2022-04-22 00:17:19 UTC (rev 293202)
@@ -84,3 +84,14 @@
     String testAd12 = "6ef944c1-5cb8-48aa-Ad12-C5f823f005c3"_s;
     EXPECT_EQ(parseAndStringifyUUID(testAd12), testAd12.convertToASCIILowercase());
 }
+
+TEST(WTF, TestUUIDVersion4MakeString)
+{
+    String testNormal = "12345678-9abc-4de0-89ab-0123456789ab"_s;
+    auto uuid = UUID::parseVersion4(testNormal);
+    EXPECT_TRUE(!!uuid);
+    EXPECT_EQ(makeString(uuid.value()), testNormal);
+    EXPECT_EQ(makeString("keyframe-", uuid.value()), String("keyframe-" + testNormal));
+
+    EXPECT_EQ(WTF::StringTypeAdapter<UUID>(uuid.value()).length(), 36U);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to