WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-176236.diff (text/plain), 27.06 KB, created by
Don Olmstead
on 2022-01-20 14:47:01 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Don Olmstead
Created:
2022-01-20 14:47:01 PST
Size:
27.06 KB
patch
obsolete
>diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index e65d1c7a2281..7a2288902891 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,32 @@ >+2022-01-20 Don Olmstead <don.olmstead@sony.com> >+ >+ Add a ResourceBundle abstraction >+ https://bugs.webkit.org/show_bug.cgi?id=176236 >+ >+ Reviewed by Yusuke Suzuki. >+ >+ Adds an abstraction over a CFBundle. If CoreFoundation isn't available then it emulates >+ CFBundle's behavior using FileSystem APIs. >+ >+ * WTF.xcodeproj/project.pbxproj: >+ * wtf/CMakeLists.txt: >+ * wtf/PlatformWin.cmake: >+ * wtf/ResourceBundle.cpp: Added. >+ (WTF::ResourceBundle::create): >+ (WTF::ResourceBundle::ResourceBundle): >+ (WTF::ResourceBundle::bundlePath const): >+ (WTF::ResourceBundle::bundleURL const): >+ (WTF::ResourceBundle::resourcePath const): >+ (WTF::ResourceBundle::resourceURL const): >+ * wtf/ResourceBundle.h: Added. >+ * wtf/cf/ResourceBundleCF.cpp: Added. >+ (WTF::ResourceBundle::create): >+ (WTF::ResourceBundle::ResourceBundle): >+ (WTF::ResourceBundle::bundlePath const): >+ (WTF::ResourceBundle::bundleURL const): >+ (WTF::ResourceBundle::resourcePath const): >+ (WTF::ResourceBundle::resourceURL const): >+ > 2022-01-19 Yusuke Suzuki <ysuzuki@apple.com> > > [JSC] Implement Temporal.Now.instant() >diff --git a/Source/WTF/WTF.xcodeproj/project.pbxproj b/Source/WTF/WTF.xcodeproj/project.pbxproj >index 582ca62fde6e..ab11c13e4ef3 100644 >--- a/Source/WTF/WTF.xcodeproj/project.pbxproj >+++ b/Source/WTF/WTF.xcodeproj/project.pbxproj >@@ -108,12 +108,14 @@ > 93B5B45122171EEA004B7AA7 /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B5B45022171EE9004B7AA7 /* Logger.cpp */; }; > 93F1993E19D7958D00C2390B /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1993D19D7958D00C2390B /* StringView.cpp */; }; > 9BC70F05176C379D00101DEC /* AtomStringTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC70F04176C379D00101DEC /* AtomStringTable.cpp */; }; >+ A310F79E279A0A1400CDD259 /* ResourceBundleCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A310F79D279A0A1400CDD259 /* ResourceBundleCF.cpp */; }; > A32D8FA521FFFAB400780662 /* ThreadingPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */; }; > A331D95B21F24992009F02AA /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95A21F24992009F02AA /* FileSystem.cpp */; }; > A331D95D21F249E4009F02AA /* FileSystemCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95C21F249E4009F02AA /* FileSystemCF.cpp */; }; > A331D95F21F249F6009F02AA /* FileSystemCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A331D95E21F249F6009F02AA /* FileSystemCocoa.mm */; }; > A331D96121F24A0A009F02AA /* FileSystemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A331D96021F24A0A009F02AA /* FileSystemMac.mm */; }; > A331D96721F24ABD009F02AA /* FileSystemPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */; }; >+ A3A9BDFA2798DDE800C1DD06 /* ResourceBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3A9BDF82798DDDF00C1DD06 /* ResourceBundle.cpp */; }; > A3B725EC987446AD93F1A440 /* RandomDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */; }; > A3E4DD931F3A803400DED0B4 /* TextStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3E4DD911F3A803400DED0B4 /* TextStream.cpp */; }; > A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */; }; >@@ -553,6 +555,7 @@ > A1B89B87221E000F00EB4CEA /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; }; > A30D412C1F0DE0BA00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; }; > A30D412D1F0DE13F00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; }; >+ A310F79D279A0A1400CDD259 /* ResourceBundleCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceBundleCF.cpp; sourceTree = "<group>"; }; > A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPOSIX.cpp; sourceTree = "<group>"; }; > A331D95921F24992009F02AA /* FileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystem.h; sourceTree = "<group>"; }; > A331D95A21F24992009F02AA /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = "<group>"; }; >@@ -561,6 +564,8 @@ > A331D96021F24A0A009F02AA /* FileSystemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSystemMac.mm; sourceTree = "<group>"; }; > A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemPOSIX.cpp; sourceTree = "<group>"; }; > A36E16F7216FF828008DD87E /* WTFSemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFSemaphore.h; sourceTree = "<group>"; }; >+ A3A9BDF82798DDDF00C1DD06 /* ResourceBundle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceBundle.cpp; sourceTree = "<group>"; }; >+ A3A9BDF92798DDDF00C1DD06 /* ResourceBundle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ResourceBundle.h; sourceTree = "<group>"; }; > A3D273B921F2EE9100866971 /* MetadataSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetadataSPI.h; sourceTree = "<group>"; }; > A3E4DD911F3A803400DED0B4 /* TextStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextStream.cpp; sourceTree = "<group>"; }; > A3E4DD921F3A803400DED0B4 /* TextStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextStream.h; sourceTree = "<group>"; }; >@@ -887,6 +892,7 @@ > 5C1F05922164356B0039302C /* CFURLExtras.h */, > A331D95C21F249E4009F02AA /* FileSystemCF.cpp */, > C2BCFC411F61D61600C9222C /* LanguageCF.cpp */, >+ A310F79D279A0A1400CDD259 /* ResourceBundleCF.cpp */, > 2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */, > A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */, > BC3FEB5D267FCD340054006A /* SpanCF.h */, >@@ -1293,6 +1299,8 @@ > A8A47302151A825B004123FF /* RefCountedLeakCounter.h */, > 86F46F5F1A2840EE00CCBF22 /* RefCounter.h */, > A8A47303151A825B004123FF /* RefPtr.h */, >+ A3A9BDF82798DDDF00C1DD06 /* ResourceBundle.cpp */, >+ A3A9BDF92798DDDF00C1DD06 /* ResourceBundle.h */, > FE3842342325CC80009DD445 /* ResourceUsage.h */, > A8A47305151A825B004123FF /* RetainPtr.h */, > E3C583C826127ADD00C57568 /* RobinHoodHashMap.h */, >@@ -1862,6 +1870,7 @@ > A3EE5C4021FFACA200FABD61 /* SchedulePairMac.mm in Sources */, > 0F66B28E1DC97BAB004A1D3F /* Seconds.cpp in Sources */, > 0FA6F38F20CC580F00A03DCD /* SegmentedVector.cpp in Sources */, >+ A3A9BDFA2798DDE800C1DD06 /* ResourceBundle.cpp in Sources */, > A8A47421151A825B004123FF /* SHA1.cpp in Sources */, > 5311BD531EA71CAD00525281 /* Signals.cpp in Sources */, > A748745217A0BDAE00FA04CB /* SixCharacterHash.cpp in Sources */, >@@ -1901,6 +1910,7 @@ > 521CC6B424A27809004377D6 /* TranslatedProcess.cpp in Sources */, > 0FA6F39520CCACE900A03DCD /* UniqueArray.cpp in Sources */, > 5CC0EE7621629F1900A1A842 /* URL.cpp in Sources */, >+ A310F79E279A0A1400CDD259 /* ResourceBundleCF.cpp in Sources */, > 5C1F0595216437B30039302C /* URLCF.cpp in Sources */, > 5CC0EE892162BC2200A1A842 /* URLCocoa.mm in Sources */, > 5FAD3AE221B9636600BEE178 /* URLHelpers.cpp in Sources */, >diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt >index 49e0c7669936..38eda06b8149 100644 >--- a/Source/WTF/wtf/CMakeLists.txt >+++ b/Source/WTF/wtf/CMakeLists.txt >@@ -225,6 +225,7 @@ set(WTF_PUBLIC_HEADERS > RefCountedLeakCounter.h > RefCounter.h > RefPtr.h >+ ResourceBundle.h > ResourceUsage.h > RetainPtr.h > RobinHoodHashMap.h >@@ -460,6 +461,7 @@ set(WTF_SOURCES > ReadWriteLock.cpp > RefCounted.cpp > RefCountedLeakCounter.cpp >+ ResourceBundle.cpp > RunLoop.cpp > SHA1.cpp > SafeStrerror.cpp >diff --git a/Source/WTF/wtf/PlatformWin.cmake b/Source/WTF/wtf/PlatformWin.cmake >index cc43a21c8eff..3b2803d459f5 100644 >--- a/Source/WTF/wtf/PlatformWin.cmake >+++ b/Source/WTF/wtf/PlatformWin.cmake >@@ -45,6 +45,7 @@ if (USE_CF) > list(APPEND WTF_SOURCES > cf/CFURLExtras.cpp > cf/FileSystemCF.cpp >+ cf/ResourceBundleCF.cpp > cf/URLCF.cpp > > text/cf/AtomStringImplCF.cpp >diff --git a/Source/WTF/wtf/ResourceBundle.cpp b/Source/WTF/wtf/ResourceBundle.cpp >new file mode 100644 >index 000000000000..7db10aa06aed >--- /dev/null >+++ b/Source/WTF/wtf/ResourceBundle.cpp >@@ -0,0 +1,75 @@ >+/* >+ * Copyright (C) 2022 Sony Interactive Entertainment Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/ResourceBundle.h> >+ >+#if !USE(CF) >+ >+#include <wtf/FileSystem.h> >+#include <wtf/URL.h> >+ >+namespace WTF { >+ >+std::unique_ptr<ResourceBundle> ResourceBundle::create(StringView path) >+{ >+ auto pathString = path.toString(); >+ if (!FileSystem::fileExists(pathString)) >+ return nullptr; >+ >+ return std::unique_ptr<ResourceBundle>(new ResourceBundle(pathString)); >+} >+ >+ResourceBundle::ResourceBundle(String root) >+ : m_root(root) >+{ } >+ >+String ResourceBundle::bundlePath() const >+{ >+ return m_root; >+} >+ >+URL ResourceBundle::bundleURL() const >+{ >+ return URL::fileURLWithFileSystemPath(m_root); >+} >+ >+String ResourceBundle::resourcePath(StringView name, StringView type, StringView directory) const >+{ >+ auto fileName = makeString(name, "."_s, type); >+ return FileSystem::pathByAppendingComponents(m_root, { directory, fileName }); >+} >+ >+URL ResourceBundle::resourceURL(StringView name, StringView type, StringView directory) const >+{ >+ return URL::fileURLWithFileSystemPath(resourcePath(name, type, directory)); >+} >+ >+} // namespace WTF >+ >+#endif // !USE(CF) >diff --git a/Source/WTF/wtf/ResourceBundle.h b/Source/WTF/wtf/ResourceBundle.h >new file mode 100644 >index 000000000000..47724cf7fdc4 >--- /dev/null >+++ b/Source/WTF/wtf/ResourceBundle.h >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2022 Sony Interactive Entertainment Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/Forward.h> >+ >+#if USE(CF) >+#include <wtf/RetainPtr.h> >+typedef struct __CFBundle* CFBundleRef; >+#else >+#include <wtf/text/WTFString.h> >+#endif >+ >+namespace WTF { >+ >+class ResourceBundle final { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ WTF_EXPORT_PRIVATE static std::unique_ptr<ResourceBundle> create(StringView); >+ >+#if USE(CF) >+ inline operator CFBundleRef() const { return m_bundle.get(); } >+#endif >+ >+ WTF_EXPORT_PRIVATE String bundlePath() const; >+ WTF_EXPORT_PRIVATE URL bundleURL() const; >+ >+ WTF_EXPORT_PRIVATE String resourcePath(StringView name, StringView type, StringView directory) const; >+ WTF_EXPORT_PRIVATE URL resourceURL(StringView name, StringView type, StringView directory) const; >+ >+private: >+#if USE(CF) >+ ResourceBundle(CFBundleRef); >+ RetainPtr<CFBundleRef> m_bundle; >+#else >+ ResourceBundle(String); >+ String m_root; >+#endif >+}; >+ >+} // namespace WTF >diff --git a/Source/WTF/wtf/cf/ResourceBundleCF.cpp b/Source/WTF/wtf/cf/ResourceBundleCF.cpp >new file mode 100644 >index 000000000000..28fdc13109db >--- /dev/null >+++ b/Source/WTF/wtf/cf/ResourceBundleCF.cpp >@@ -0,0 +1,91 @@ >+/* >+ * Copyright (C) 2022 Sony Interactive Entertainment Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/ResourceBundle.h> >+ >+#include <CoreFoundation/CFBundle.h> >+#include <wtf/URL.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WTF { >+ >+std::unique_ptr<ResourceBundle> ResourceBundle::create(StringView path) >+{ >+ auto url = CFURLCreateWithFileSystemPath( >+ kCFAllocatorDefault, >+ path.createCFString().get(), >+#if PLATFORM(WIN) >+ kCFURLWindowsPathStyle, >+#else >+ kCFURLPOSIXPathStyle, >+#endif >+ false); >+ >+ auto bundle = CFBundleCreate(kCFAllocatorDefault, url); >+ if (!bundle) >+ return nullptr; >+ >+ return std::unique_ptr<ResourceBundle>(new ResourceBundle(bundle)); >+} >+ >+ResourceBundle::ResourceBundle(CFBundleRef bundle) >+ : m_bundle(adoptCF(bundle)) >+{ } >+ >+String ResourceBundle::bundlePath() const >+{ >+ return bundleURL().fileSystemPath(); >+} >+ >+URL ResourceBundle::bundleURL() const >+{ >+ return URL(CFBundleCopyBundleURL(m_bundle.get())); >+} >+ >+String ResourceBundle::resourcePath(StringView name, StringView type, StringView directory) const >+{ >+ RetainPtr<CFURLRef> requestedURLRef = CFBundleCopyResourceURL(m_bundle.get(), name.createCFString().get(), type.createCFString().get(), directory.createCFString().get()); >+ if (!requestedURLRef) >+ return String(); >+ >+ static constexpr size_t maxPathSize = 4096; >+ UInt8 requestedFilePath[maxPathSize]; >+ >+ if (!CFURLGetFileSystemRepresentation(requestedURLRef.get(), false, requestedFilePath, maxPathSize)) >+ return String(); >+ >+ return String(requestedFilePath); >+} >+ >+URL ResourceBundle::resourceURL(StringView name, StringView type, StringView directory) const >+{ >+ return URL(CFBundleCopyResourceURL(m_bundle.get(), name.createCFString().get(), type.createCFString().get(), directory.createCFString().get())); >+} >+ >+} // namespace WTF >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index a2240a358081..7e69819c68fb 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2022-01-20 Don Olmstead <don.olmstead@sony.com> >+ >+ Add a ResourceBundle abstraction >+ https://bugs.webkit.org/show_bug.cgi?id=176236 >+ >+ Reviewed by Yusuke Suzuki. >+ >+ Add tests for WTF::ResourceBundle. >+ >+ * TestWebKitAPI/CMakeLists.txt: >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WTF/ResourceBundle.cpp: Added. >+ (TestWebKitAPI::TEST_F): >+ > 2022-01-20 Angelos Oikonomopoulos <angelos@igalia.com> > > [JSC] Further unification in run-jsc-stress-tests >diff --git a/Tools/TestWebKitAPI/CMakeLists.txt b/Tools/TestWebKitAPI/CMakeLists.txt >index a1a9142ffa8b..96c938cbf0ee 100644 >--- a/Tools/TestWebKitAPI/CMakeLists.txt >+++ b/Tools/TestWebKitAPI/CMakeLists.txt >@@ -79,6 +79,7 @@ set(TestWTF_SOURCES > Tests/WTF/RefCounter.cpp > Tests/WTF/RefLogger.cpp > Tests/WTF/RefPtr.cpp >+ Tests/WTF/ResourceBundle.cpp > Tests/WTF/RobinHoodHashMap.cpp > Tests/WTF/RobinHoodHashSet.cpp > Tests/WTF/RunLoop.cpp >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 5a50dfb2f025..08cfe501da16 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -832,6 +832,7 @@ > A1FB504322A213A300D4D979 /* apple-pay-can-make-payment.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1FB504222A2138F00D4D979 /* apple-pay-can-make-payment.html */; }; > A1FB504522A2157100D4D979 /* apple-pay.js in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1FB504422A2154B00D4D979 /* apple-pay.js */; }; > A310827221F296FF00C28B97 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A310827121F296EC00C28B97 /* FileSystem.cpp */; }; >+ A3A9BDFC2798DE2D00C1DD06 /* ResourceBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3A9BDFB2798DE2D00C1DD06 /* ResourceBundle.cpp */; }; > A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; }; > A57D54F31F338C3600A97AA7 /* NeverDestroyed.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57D54F21F338C3600A97AA7 /* NeverDestroyed.cpp */; }; > A57D54F61F3395D000A97AA7 /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57D54F41F3395D000A97AA7 /* Logger.cpp */; }; >@@ -2653,6 +2654,7 @@ > A1FB504422A2154B00D4D979 /* apple-pay.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = "apple-pay.js"; sourceTree = "<group>"; }; > A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCreateCGImageCrash.cpp; sourceTree = "<group>"; }; > A310827121F296EC00C28B97 /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = "<group>"; }; >+ A3A9BDFB2798DE2D00C1DD06 /* ResourceBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceBundle.cpp; sourceTree = "<group>"; }; > A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageVisibilityStateWithWindowChanges.mm; sourceTree = "<group>"; }; > A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = PageVisibilityStateWithWindowChanges.html; sourceTree = "<group>"; }; > A57D54F21F338C3600A97AA7 /* NeverDestroyed.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NeverDestroyed.cpp; sourceTree = "<group>"; }; >@@ -4574,6 +4576,7 @@ > 442BBF681C91CAD90017087F /* RefLogger.cpp */, > 93A427AD180DA60F00CD24D7 /* RefLogger.h */, > 93A427A8180D9B0700CD24D7 /* RefPtr.cpp */, >+ A3A9BDFB2798DE2D00C1DD06 /* ResourceBundle.cpp */, > E355A6312615718F001C1129 /* RobinHoodHashMap.cpp */, > E355A62F26157174001C1129 /* RobinHoodHashSet.cpp */, > E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */, >@@ -5351,6 +5354,7 @@ > 7C83DF021D0A590C00FEBCF3 /* OSObjectPtr.cpp in Sources */, > 44449DC22718B4B700E821B5 /* OSObjectPtrCocoa.mm in Sources */, > 44449DC12718B4B700E821B5 /* OSObjectPtrCocoaARC.mm in Sources */, >+ A3A9BDFC2798DE2D00C1DD06 /* ResourceBundle.cpp in Sources */, > E32B549222810AC4008AD702 /* Packed.cpp in Sources */, > E38D65CA23A45FAA0063D69A /* PackedRef.cpp in Sources */, > E38D65CB23A45FAA0063D69A /* PackedRefPtr.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WTF/ResourceBundle.cpp b/Tools/TestWebKitAPI/Tests/WTF/ResourceBundle.cpp >new file mode 100644 >index 000000000000..0dfe8a147f16 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WTF/ResourceBundle.cpp >@@ -0,0 +1,94 @@ >+/* >+ * Copyright (C) 2022 Sony Interactive Entertainment Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#include "Test.h" >+#include <wtf/FileSystem.h> >+#include <wtf/ResourceBundle.h> >+#include <wtf/URL.h> >+ >+namespace TestWebKitAPI { >+ >+class ResourceBundleTest : public testing::Test { >+public: >+ void SetUp() override >+ { >+ // Create a temp directory to make a bundle in >+ FileSystem::PlatformFileHandle handle; >+ m_root = FileSystem::openTemporaryFile("WebKit.resources", handle); >+ FileSystem::closeFile(handle); >+ FileSystem::deleteFile(m_root); >+ >+ // Create the bundle structure >+ FileSystem::makeAllDirectories(FileSystem::pathByAppendingComponents(m_root, { "WebInspectorUI", "Protocol" })); >+ auto inspectorBackendFile = FileSystem::openFile(FileSystem::pathByAppendingComponents(m_root, { "WebInspectorUI", "Protocol", "InspectorBackendCommands.js" }), FileSystem::FileOpenMode::Write); >+ FileSystem::closeFile(inspectorBackendFile); >+ } >+ >+ void TearDown() override >+ { >+ FileSystem::deleteNonEmptyDirectory(m_root); >+ } >+ >+protected: >+ String m_root; >+}; >+ >+TEST_F(ResourceBundleTest, BundlePath) >+{ >+ auto bundle = WTF::ResourceBundle::create(m_root); >+ auto actual = bundle->bundlePath(); >+ EXPECT_TRUE(m_root == actual); >+} >+ >+TEST_F(ResourceBundleTest, BundleURL) >+{ >+ auto bundle = WTF::ResourceBundle::create(m_root); >+ auto actual = bundle->bundleURL(); >+ EXPECT_TRUE(URL::fileURLWithFileSystemPath(StringView(m_root)) == actual); >+} >+ >+TEST_F(ResourceBundleTest, ResourcePath) >+{ >+ auto bundle = WTF::ResourceBundle::create(m_root); >+ auto actual = bundle->resourcePath("InspectorBackendCommands", "js", FileSystem::pathByAppendingComponent("WebInspectorUI"_s, "Protocol"_s)); >+ auto expected = FileSystem::pathByAppendingComponents(m_root, { "WebInspectorUI", "Protocol", "InspectorBackendCommands.js" }); >+ EXPECT_TRUE(expected == actual); >+} >+ >+TEST_F(ResourceBundleTest, ResourceURL) >+{ >+ auto bundle = WTF::ResourceBundle::create(m_root); >+ auto actual = bundle->resourceURL("InspectorBackendCommands", "js", FileSystem::pathByAppendingComponent("WebInspectorUI"_s, "Protocol"_s)); >+ auto expected = FileSystem::pathByAppendingComponents(m_root, { "WebInspectorUI", "Protocol", "InspectorBackendCommands.js" }); >+ >+ EXPECT_TRUE(URL::fileURLWithFileSystemPath(StringView(expected)) == actual); >+} >+ >+} // namespace TestWebKitAPI
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
darin
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 176236
:
449527
|
449548
|
449551
|
449606
|
449612
|
449660
|
449666
|
449677
|
449678