2021-08-21 Myles C. Maxfield overwriteCodePoint() in createAndFillGlyphPage() is wrong https://bugs.webkit.org/show_bug.cgi?id=215643 Reviewed by Alan Bujtas. * wtf/unicode/CharacterNames.h: 2021-08-21 Sihui Liu IndexedDB: crash when triggering IDBOpenRequest completion back on a worker thread https://bugs.webkit.org/show_bug.cgi?id=229375 Protect callee in CrossThreadTask if it inherits from ThreadSafeRefCounted. Reviewed by Brady Eidson. * wtf/CrossThreadTask.h: 2021-08-20 Mark Lam Make ptrTagName and tagForPtr WTF_EXPORT_PRIVATE. https://bugs.webkit.org/show_bug.cgi?id=229328 Reviewed by Yusuke Suzuki. If ptrTagName and tagForPtr are defined, make them WTF_EXPORT_PRIVATE instead of static functions. This allows us to call them from the debugger during interactive debugging sessions. * wtf/PtrTag.cpp: (WTF::tagForPtr): (WTF::ptrTagName): * wtf/PtrTag.h: 2021-08-20 Mark Lam Remove assertIsTagged and assertIsNullOrTagged. https://bugs.webkit.org/show_bug.cgi?id=229329 rdar://82162851 Reviewed by Yusuke Suzuki. These assertion utility functions rely on tagged pointers always having non-zero PAC bits. This is an incorrect assumption. A tagged pointer can have PAC bits that are completely zero. Hence, these assert functions cannot be made to work reliably. We should remove them to prevent them from being used, and potentially resulting in flaky assertion failures that will be hard to debug later. Note: assertIsNotTagged is fine to keep. It asserts that PAC bits of a pointer are all 0. As a result, this assertion can have false positives where it may think a tagged pointer is an untagged pointer. However, this is rare because it is not common to have 0 PAC bits in tagged pointers. False positives on this assertion won't result in flaky test failures that will waste our time later. Hence, keeping the assertion will do more good (it will tend to help us find bugs) than bad (it will rarely let false positives thru). As a result, I'm opting to not remove it. * wtf/PtrTag.h: (WTF::assertIsTagged): Deleted. (WTF::assertIsNullOrTagged): Deleted. 2021-08-19 Antti Koivisto [:has() pseudo-class] Basic support https://bugs.webkit.org/show_bug.cgi?id=228894 Reviewed by Simon Fraser. * Scripts/Preferences/WebPreferencesExperimental.yaml: Add off-by-default HasPseudoClassEnabled preference value. 2021-08-19 Myles C. Maxfield [Cocoa] Stop treating the system font as a non-variable font https://bugs.webkit.org/show_bug.cgi?id=228176 Reviewed by Sam Weinig. * wtf/PlatformUse.h: 2021-08-19 Aditya Keerthi Remove __has_include guard for _UIDatePickerOverlayPresentation https://bugs.webkit.org/show_bug.cgi?id=227298 rdar://79970171 Reviewed by Tim Horton. * wtf/PlatformHave.h: 2021-08-19 David Kilzer [WTF] Fix static analyzer warnings for clang tidy bugprone-move-forwarding-reference checker Reviewed by Darin Adler. * wtf/Deque.h: (WTF::inlineCapacity>::appendAndBubble): * wtf/Scope.h: (WTF::ScopeExit::ScopeExit): * wtf/ScopedLambda.h: (WTF::scopedLambda): * wtf/SharedTask.h: (WTF::createSharedTask): - Replace WTFMove() with std::forward<>(). 2021-08-19 Alex Christensen Remove more non-inclusive language from Source https://bugs.webkit.org/show_bug.cgi?id=229230 Reviewed by Myles C. Maxfield. * icu/unicode/uspoof.h: This comment change comes from upstream ICU. * wtf/URL.h: 2021-08-18 Ryosuke Niwa [ iOS Debug ] 12 TestWebKitAPI.WebKitLegacy. tests are crashing https://bugs.webkit.org/show_bug.cgi?id=229250 Reviewed by Wenson Hsieh. Disable the assertion when Web Thread is enabled for now. * wtf/CheckedRef.h: (WTF::SingleThreadIntegralWrapper::assertThread const): 2021-08-18 Megan Gardner Remove unneeded UIKitSPI declarations https://bugs.webkit.org/show_bug.cgi?id=210075 Reviewed by Wenson Hsieh. Remove unneeded feature define. * wtf/PlatformHave.h: 2021-08-18 Xabier Rodriguez Calvar [GStreamer][EME] Try to parse XML init datas that could possibly come from MPD manifests https://bugs.webkit.org/show_bug.cgi?id=229145 Reviewed by Alicia Boya Garcia. * wtf/glib/GUniquePtr.h: Added deleter for GMarkupParseContext. 2021-08-16 Alex Christensen Enable PerformanceNavigationAPI by default https://bugs.webkit.org/show_bug.cgi?id=227336 Reviewed by Chris Dumez. It passes WPT tests except the following: navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html and navigation-timing/nav2_test_redirect_xserver.html pass when run from wpt.live, and other browsers also don't pass when run from our local hosting infrastructure, which doesn't have a good cross-domain redirect. nav2_test_attributes_values.html fails in Chrome and Firefox. There's something wrong with the port detection in the test. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-08-16 Ryosuke Niwa Add thread safe version of CanMakeCheckedPtr https://bugs.webkit.org/show_bug.cgi?id=229018 Reviewed by Geoffrey Garen. Introduce CanMakeThreadSafeCheckedPtr which is a thread safe version of CanMakeCheckedPtr. * wtf/CheckedRef.h: (WTF::CanMakeCheckedPtrBase): Extracted from CanMakeCheckedPtr. (WTF::CanMakeCheckedPtrBase::~CanMakeCheckedPtrBase): (WTF::CanMakeCheckedPtrBase::ptrCount const): (WTF::SingleThreadIntegralWrapper): Added. (WTF::SingleThreadIntegralWrapper::SingleThreadIntegralWrapper): (WTF::SingleThreadIntegralWrapper::operator IntegralType const): (WTF::SingleThreadIntegralWrapper::operator! const): (WTF::SingleThreadIntegralWrapper::operator++): (WTF::SingleThreadIntegralWrapper::operator--): (WTF::SingleThreadIntegralWrapper::assertThread const): (WTF::CanMakeCheckedPtr): Redefined using CanMakeCheckedPtrBase and SimpleNonAtomicType. (WTF::CanMakeThreadSafeCheckedPtr): Added. 2021-08-16 David Kilzer ThreadSanitizer: ignore uninteresting data races for reference counting of static WTF::StringImpl objects Reviewed by Chris Dumez. * wtf/text/StringImpl.h: (WTF::StringImpl::isStatic const): - Add SUPPRESS_TSAN attribute since the 0x1 bit is set at construction and refcounting occurs in increments of 0x2, so the static bit never changes. (WTF::StringImpl::ref): (WTF::StringImpl::deref): - Return early for static WTF::StringImpl objects to prevent TSan from reporting data races for m_refCount. 2021-08-15 Miguel Gomez [GTK][WPE] Add API to pass WebKitMemoryPressureHandler parameters to the network processes https://bugs.webkit.org/show_bug.cgi?id=228227 Reviewed by Carlos Garcia Campos. Added a new method to MemoryPressureHandler to set the configuration by copying the parameter instead of moving it. * wtf/MemoryPressureHandler.h: (WTF::MemoryPressureHandler::setConfiguration): 2021-08-11 Chris Dumez Add initial support for Cross-Origin-Embedder-Policy (COEP) https://bugs.webkit.org/show_bug.cgi?id=228754 Reviewed by Alex Christensen. Add experimental feature flag for Cross-Origin-Embedder-Policy (COEP), off by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-08-11 Darin Adler Add deduction guide to RetainPtr, use constexpr a bit more, and streamline the implementation https://bugs.webkit.org/show_bug.cgi?id=228852 Reviewed by Sam Weinig. * wtf/RetainPtr.h: Sort includes. Made many functions constexpr including the move constructors and adoptCF. Use using instead of typedef in most places. Use remove_pointer_t, conditional_t, is_convertible_v, is_same_v, and other such templates to simplify expressions. Initialize the m_ptr data member and use the default constructor. Removed unneeded StorageType synonym for CFTypeRef. Move some inline function bodies out of the class template definition. Use if constexpr to get rid of the need for the overloaded autoreleaseHelper function. Added a deduction guide so we can use expressions with the type RetainPtr on the left side, and an Objective-C pointer or CFTypeRef on the right side, and have the appropriate RetainPtr type deduced. 2021-08-11 Sihui Liu Suspend WorkQueue of ResourceLoadStatistics and LocalStorage sooner https://bugs.webkit.org/show_bug.cgi?id=228748 Reviewed by Chris Dumez. Add SuspendableWorkQueue that would perform suspend check before each task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Forward.h: * wtf/SuspendableWorkQueue.cpp: Added. (WTF::SuspendableWorkQueue::create): (WTF::SuspendableWorkQueue::SuspendableWorkQueue): (WTF::SuspendableWorkQueue::suspend): (WTF::SuspendableWorkQueue::resume): (WTF::SuspendableWorkQueue::dispatch): (WTF::SuspendableWorkQueue::dispatchAfter): (WTF::SuspendableWorkQueue::dispatchSync): (WTF::SuspendableWorkQueue::invokeAllSuspensionCompletionHandlers): (WTF::SuspendableWorkQueue::suspendIfNeeded): * wtf/SuspendableWorkQueue.h: Added. * wtf/WorkQueue.h: (): Deleted. 2021-08-11 Youenn Fablet Enable WebRTC relay by default https://bugs.webkit.org/show_bug.cgi?id=229000 Reviewed by Eric Carlson. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-08-10 Peng Liu Disable SYSTEM_FEATURE_FLAGS on iOS 14 https://bugs.webkit.org/show_bug.cgi?id=228979 Reviewed by Tim Horton. Stop using feature flags mechanism on iOS 14 to avoid some issues on iOS simulators. * wtf/PlatformHave.h: 2021-08-10 Stephan Szabo [WTF][PlayStation] REGRESSION(r280795) error: undefined symbol: WTF::logLevelString() https://bugs.webkit.org/show_bug.cgi?id=228959 Reviewed by Fujii Hironori. As per followup win fix, for declspec platforms, LoggingUnix needs to include LogInitialization to get the export declaration. * wtf/unix/LoggingUnix.cpp: 2021-08-10 Keith Miller CallFrame::returnPC should untag the return address before passing it to ReturnAddressPtr https://bugs.webkit.org/show_bug.cgi?id=228931 Reviewed by Mark Lam. Add a new helper to untag the return pc from a stack frame. * wtf/PtrTag.h: (WTF::untagReturnPC): 2021-08-09 Fujii Hironori [GTK][WPE] REGRESSION(r280795): MemoryPressureHandlerUnix.cpp:45:28: error: ‘LogMemoryPressure’ was not declared in this scope https://bugs.webkit.org/show_bug.cgi?id=228938 Unreviewed build fix. * wtf/unix/MemoryPressureHandlerUnix.cpp: 2021-08-09 Fujii Hironori [WTF][Win] REGRESSION(r280795) error LNK2019: unresolved external symbol "class WTF::String __cdecl WTF::logLevelString(void)" https://bugs.webkit.org/show_bug.cgi?id=228937 Unresolved build fix. The previous attempt (r280819) didn't actually fix the build error. LoggingWin.cpp has to include LogInitialization.h. * wtf/win/LoggingWin.cpp: 2021-08-09 Fujii Hironori [WTF][Win] REGRESSION(r280795) error LNK2019: unresolved external symbol "class WTF::String __cdecl WTF::logLevelString(void)" https://bugs.webkit.org/show_bug.cgi?id=228937 Unreviewed build fix. > error LNK2019: unresolved external symbol "class WTF::String __cdecl WTF::logLevelString(void)" (?logLevelString@WTF@@YA?AVString@1@XZ) > referenced in function "private: void __cdecl WebKit::GPUProcessProxy::platformInitializeGPUProcessParameters(struct WebKit::GPUProcessCreationParameters &)" > (?platformInitializeGPUProcessParameters@GPUProcessProxy@WebKit@@AEAAXAEAUGPUProcessCreationParameters@2@@Z) > bin64\WebKit2.dll : fatal error LNK1120: 1 unresolved externals * wtf/LogInitialization.h: Added WTF_EXPORT_PRIVATE for logLevelString. 2021-08-09 Myles C. Maxfield Create a Language log channel https://bugs.webkit.org/show_bug.cgi?id=228764 Reviewed by Simon Fraser. There have been a variety of bug reports over the past months/years about the procedure by which we determine navigator.language. It's actually somewhat convoluted, so this patch adds a (debug) log channel for it so we can follow what it's doing easily. To enable all the logging, run these commands: % defaults write com.apple.WebKit.WebContent.Development WTFLogging Language % defaults write com.apple.WebKit.WebContent.Development WebKit2Logging Language % defaults write com.apple.WebKit.WebContent WTFLogging Language % defaults write com.apple.WebKit.WebContent WebKit2Logging Language % defaults write -g WTFLogging Language % defaults write -g WebKit2Logging Language % defaults write /Users/$USER/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari.plist WTFLogging Language % defaults write /Users/$USER/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari.plist WebKit2Logging Language * wtf/Language.cpp: (WTF::defaultLanguage): (WTF::overrideUserPreferredLanguages): (WTF::userPreferredLanguages): * wtf/Logging.cpp: * wtf/Logging.h: * wtf/cf/LanguageCF.cpp: (WTF::platformUserPreferredLanguages): * wtf/cocoa/LanguageCocoa.mm: (WTF::minimizedLanguagesFromLanguages): 2021-08-09 Myles C. Maxfield Support WTF logging channels https://bugs.webkit.org/show_bug.cgi?id=228768 This patch builds on top of https://bugs.webkit.org/show_bug.cgi?id=228809, which added shared infrastructure for logging. This patch simply triggers that shared infrastructure for WTF. There is no change in behavior - the existing WTF logging channels currently are all implemented independently in custom ways, so this patch just migrates them over to use the shared infrastructure. Reviewed by Fujii Hironori. * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.h: * wtf/CMakeLists.txt: * wtf/LogInitialization.cpp: Added. (WTF::logChannels): * wtf/LogInitialization.h: Added. * wtf/Logging.cpp: Added. * wtf/Logging.h: Added. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::singleton): * wtf/MemoryPressureHandler.h: * wtf/PlatformFTW.cmake: * wtf/PlatformGTK.cmake: * wtf/PlatformJSCOnly.cmake: * wtf/PlatformMac.cmake: * wtf/PlatformPlayStation.cmake: * wtf/PlatformWPE.cmake: * wtf/PlatformWin.cmake: * wtf/RefCountedLeakCounter.cpp: * wtf/cocoa/LoggingCocoa.mm: Copied from Source/WebKit/UIProcess/Cocoa/GPUProcessProxyCocoa.mm. (WTF::logLevelString): * wtf/cocoa/MachSendRight.cpp: * wtf/cocoa/MainThreadCocoa.mm: * wtf/cocoa/MemoryPressureHandlerCocoa.mm: * wtf/unix/LoggingUnix.cpp: Added. (WTF::logLevelString): * wtf/win/LoggingWin.cpp: Added. (WTF::logLevelString): 2021-08-07 Myles C. Maxfield Deduplicate logging channel algorithms https://bugs.webkit.org/show_bug.cgi?id=228809 Reviewed by Fujii Hironori. The current infrastructure (before this patch) had the following duplicated for each framework: - A .cpp file declared the list of logging channels for that framework - The .cpp file also had algorithms to search, modify, and initialize these logging channels Each framework's .cpp file had duplicate algorithms. (The initialization algorithm was even duplicated 3 times!) Because the algorithms directly name their specific list of logging channels, a naive deduplication would have had to add new parameters to these algorithms to pass in the appropriate framework's list. That's fine, but this is exactly the sort of thing classes were designed for - classes are an association of algorithms and data. The algorithms are shared but the data isn't, which really just means we should have 3 instances of a shared class - one for the 3 sets of data. So, this patch creates the LogChannels class which contains the deduplicated algorithms, and each framework has a NeverDestroyed singleton instance of that class. There is a single virtual method in the class, so the appropriate "default write" variable can be queried for each framework. The instances cannot be declared in the Logging.h files in the frameworks, because certain WebKit2 files want to initialize all 3 instances of LogChannels, but you can't #include multiple Logging.h files at the same time because their LOG_CHANNEL_PREFIX #defines will collide with each other. Luckily, LogInitialization.h files exist exactly to solve this purpose, so that's where the LogChannels instances are declared in. After this change, the Logging.h files are just for the declarations of the logging channels themselves, and the LogInitialization.h files are for the LogChannels instances which contain the searching/modifying/initializing algorithms on the list of logging channels. If you just want to LOG(...) something, #include the relevant Logging.h file, and if you want to search/modify/initialize across the entire list of channels, then #include the relevant LogInitialization.h file. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/LogChannels.cpp: Copied from Source/WebCore/platform/Logging.cpp. (WTF::LogChannels::isLogChannelEnabled): (WTF::LogChannels::setLogChannelToAccumulate): (WTF::LogChannels::clearAllLogChannelsToAccumulate): (WTF::LogChannels::initializeLogChannelsIfNecessary): (WTF::LogChannels::getLogChannel): * wtf/LogChannels.h: Copied from Source/WebCore/platform/LogInitialization.h. 2021-08-07 Commit Queue Unreviewed, reverting r280756. https://bugs.webkit.org/show_bug.cgi?id=228897 Broke gtk build Reverted changeset: "Deduplicate logging channel algorithms" https://bugs.webkit.org/show_bug.cgi?id=228809 https://commits.webkit.org/r280756 2021-08-07 Myles C. Maxfield Deduplicate logging channel algorithms https://bugs.webkit.org/show_bug.cgi?id=228809 Reviewed by Fujii Hironori. The current infrastructure (before this patch) had the following duplicated for each framework: - A .cpp file declared the list of logging channels for that framework - The .cpp file also had algorithms to search, modify, and initialize these logging channels Each framework's .cpp file had duplicate algorithms. (The initialization algorithm was even duplicated 3 times!) Because the algorithms directly name their specific list of logging channels, a naive deduplication would have had to add new parameters to these algorithms to pass in the appropriate framework's list. That's fine, but this is exactly the sort of thing classes were designed for - classes are an association of algorithms and data. The algorithms are shared but the data isn't, which really just means we should have 3 instances of a shared class - one for the 3 sets of data. So, this patch creates the LogChannels class which contains the deduplicated algorithms, and each framework has a NeverDestroyed singleton instance of that class. There is a single virtual method in the class, so the appropriate "default write" variable can be queried for each framework. The instances cannot be declared in the Logging.h files in the frameworks, because certain WebKit2 files want to initialize all 3 instances of LogChannels, but you can't #include multiple Logging.h files at the same time because their LOG_CHANNEL_PREFIX #defines will collide with each other. Luckily, LogInitialization.h files exist exactly to solve this purpose, so that's where the LogChannels instances are declared in. After this change, the Logging.h files are just for the declarations of the logging channels themselves, and the LogInitialization.h files are for the LogChannels instances which contain the searching/modifying/initializing algorithms on the list of logging channels. If you just want to LOG(...) something, #include the relevant Logging.h file, and if you want to search/modify/initialize across the entire list of channels, then #include the relevant LogInitialization.h file. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/LogChannels.cpp: Copied from Source/WebCore/platform/Logging.cpp. (WTF::LogChannels::isLogChannelEnabled): (WTF::LogChannels::setLogChannelToAccumulate): (WTF::LogChannels::clearAllLogChannelsToAccumulate): (WTF::LogChannels::initializeLogChannelsIfNecessary): (WTF::LogChannels::getLogChannel): * wtf/LogChannels.h: Copied from Source/WebCore/platform/LogInitialization.h. 2021-08-05 Michael Catanzaro GCC 11 builds should use -Wno-array-bounds, -Wno-nonnull https://bugs.webkit.org/show_bug.cgi?id=228601 Reviewed by Carlos Garcia Campos. * wtf/Bitmap.h: (WTF::WordType>::clear): * wtf/Compiler.h: * wtf/Packed.h: (WTF::PackedAlignedPtr::get const): * wtf/RefPtr.h: (WTF::DefaultRefDerefTraits::derefIfNotNull): 2021-08-05 Zan Dobersek Avoid reinterpret_cast alignment increase warnings with GCC on CPU(RISCV64) https://bugs.webkit.org/show_bug.cgi?id=228818 Reviewed by Adrian Perez de Castro. * wtf/StdLibExtras.h: As with 32-bit ARM and MIPS targets, RISC-V 64-bit builds with GCC also spawn warnings when the use of reinterpret_cast causes an increase in alignment. Workaround via reinterpret_cast_ptr is thus required for CPU(RISCV64). 2021-08-03 Myles C. Maxfield [Cocoa] Tweak the formatting for passing NSArrays to TextStreams https://bugs.webkit.org/show_bug.cgi?id=228766 Reviewed by Simon Fraser. Instead of using -[NSArray description], which puts its output on multiple lines, instead use the same formatting as WTF::Vector, which puts its output on a single line. We can also use this opportunity to tweak the implementation of operator<<(id) to allow it to be called with Core Foundation types in raw C++ code. * wtf/text/TextStream.h: * wtf/text/cocoa/TextStreamCocoa.mm: (WTF::TextStream::operator<<): 2021-08-03 Risul Islam Add functions for parsing URL query string https://bugs.webkit.org/show_bug.cgi?id=228122 Reviewed by Darin Adler. Added parsing of URL query strings. * wtf/KeyValuePair.h: (WTF::operator== const): * wtf/URL.cpp: (WTF::URL::differingQueryParameters): (WTF::lengthOfURLIgnoringQueryAndFragments): (WTF::URL::isEqualIgnoringQueryAndFragments): (WTF::URL::removeQueryParameters): * wtf/URL.h: 2021-08-03 Youenn Fablet RealtimeMediaSource::audioSamplesAvailable is calling malloc as part of locking in audio thread https://bugs.webkit.org/show_bug.cgi?id=228688 Reviewed by Eric Carlson. Allow allocations in lockSlow since allocations might happen in rare case and not for each lockSlow call. * wtf/Lock.cpp: (WTF::Lock::lockSlow): (WTF::Lock::unlockSlow): (WTF::Lock::unlockFairlySlow): 2021-08-02 Ryosuke Niwa Add CheckedRef https://bugs.webkit.org/show_bug.cgi?id=227164 Reviewed by Geoffrey Garen. Like r278344, this patch introduces a new type of smart pointer, CheckedRef, which lets each object keep track of pointers pointing to the object. As with CheckedPtr, the purpose of the internal counter for CheckedRef is to release assert that there is no outstanding pointer at the time of destruction instead of keeping the object alive when there is one. This patch also removes makeCheckedPtr in favor of using CheckedPtr with template argument deduction in C++17. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CheckedPtr.h: (WTF::CheckedPtr::CheckedPtr): Added variants which take CheckedRef as arguments. (WTF::makeCheckedPtr): Deleted. (WTF::CanMakeCheckedPtr): Moved to CheckedRef.h * wtf/CheckedRef.h: Added. (WTF::CheckedRef::~CheckedRef): Added. (WTF::CheckedRef::CheckedRef): Added. (WTF::CheckedRef::isHashTableDeletedValue const): Added. (WTF::CheckedRef::isHashTableEmptyValue const): Added. (WTF::CheckedRef::hashTableEmptyValue): Added. (WTF::CheckedRef::ptrAllowingHashTableEmptyValue const): Added. (WTF::CheckedRef::ptrAllowingHashTableEmptyValue): Added. (WTF::CheckedRef::ptr const): Added. (WTF::CheckedRef::ptr): Added. (WTF::CheckedRef::get const): Added. (WTF::CheckedRef::get): Added. (WTF::CheckedRef::operator-> const): Added. (WTF::CheckedRef::operator->): Added. (WTF::CheckedRef::operator const T& const): Added. (WTF::CheckedRef::operator T&): Added. (WTF::CheckedRef::operator! const): Added. (WTF::CheckedRef::operator=): Added. (WTF::CheckedRef::releasePtr): Added. Returns m_ptr without calling decrementPtrCount. This is equivalent of leakPtr in Ref but we don't call this that since CheckedRef or CheckedPtr is generally not used to manage the object lifetime. (WTF::CheckedRef::poison): Added. (WTF::CheckedRef::unpoison): Added. (WTF::is): Added. (WTF::CheckedRefHashTraits): Added. (WTF::CheckedRefHashTraits::emptyValue): Added. (WTF::CheckedRefHashTraits::constructEmptyValue): Added. (WTF::CheckedRefHashTraits::isEmptyValue): Added. (WTF::CheckedRefHashTraits::peek): Added. (WTF::CheckedRefHashTraits::take): Added. (WTF::CanMakeCheckedPtr): Moved from CheckedPtr.h * wtf/Forward.h: 2021-08-02 Devin Rousso [Live Text] SPI for machine readable codes is only available on iOS https://bugs.webkit.org/show_bug.cgi?id=228711 Reviewed by Tim Horton. * wtf/PlatformEnableCocoa.h: * wtf/PlatformHave.h: 2021-08-02 Youenn Fablet Enable WebRTCPlatformUDPSocketsEnabled experimental feature by default https://bugs.webkit.org/show_bug.cgi?id=228689 Reviewed by Eric Carlson. Enable WebRTCPlatformUDPSocketsEnabled experimental feature by default, WebRTC proxying being off by default for now. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-08-02 Yusuke Suzuki [JSC] Yarr should use Bitmap instead of ByteVector for BoyerMoore search https://bugs.webkit.org/show_bug.cgi?id=228676 Reviewed by Saam Barati. * wtf/Bitmap.h: 2021-08-01 Youenn Fablet Introduce an experimental feature to toggle WebRTC socket proxying https://bugs.webkit.org/show_bug.cgi?id=228681 Reviewed by Eric Carlson. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-07-31 Yusuke Suzuki [JSC] Move JIT_UNICODE_EXPRESSIONS to ENABLE(YARR_JIT_UNICODE_EXPRESSIONS) in PlatformEnable.h https://bugs.webkit.org/show_bug.cgi?id=228669 Reviewed by Alexey Shvayka. * wtf/PlatformEnable.h: 2021-07-30 Rob Buis [css-overflow] Implement clip value for overflow https://bugs.webkit.org/show_bug.cgi?id=198230 Reviewed by Simon Fraser. Add preference for overflow: clip support. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-07-30 Chris Dumez Add initial support for 'Cross-Origin-Opener-Policy' HTTP header https://bugs.webkit.org/show_bug.cgi?id=192193 Reviewed by Geoff Garen. Add experimental feature flag for 'Cross-Origin-Opener-Policy' HTTP header support. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-07-29 Myles C. Maxfield Stop building WebGPU and the WHLSL compiler to decrease binary size https://bugs.webkit.org/show_bug.cgi?id=228179 Reviewed by Dean Jackson, Robin Morisset, and Devin Rousso. * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnable.h: * wtf/PlatformEnableCocoa.h: 2021-07-29 Devin Rousso [Payment Request] `additionalShippingMethods` are not used if a `paymentMethodType` is provided https://bugs.webkit.org/show_bug.cgi?id=228599 Reviewed by Andy Estes. r275169 made it so that `paymentMethodType` is no longer `required` so that `additionalShippingMethods` can be specified without having to limit it to a specific payment method type. While this works in theory, WebKit doesn't know about the user's selected payment method type until the user actually selects a payment method, meaning that until then the `additionalShippingMethods` are not used. Unfortunately (until now) `PKPaymentRequestPaymentMethodUpdate` did not support providing a `NSArray *`, so there was no way to update the list of shipping methods when the user changed their selected payment method, meaning that WebKit would have to wait/rely on the user to change their shipping address _after_ selecting a payment method in order for `additionalShippingMethods` to take effect. This also fixes an issue with WebKit's implementation of the W3C Payment Request API by allowing any generic (i.e. things not specific to Apple Pay) `shippingOptions` provided in `PaymentDetailsUpdate` to actually be used and update the Apple Pay sheet accordingly. * wtf/PlatformHave.h: * wtf/PlatformEnableCocoa.h: Add new compile flags for PassKit supporting modifying shipping methods with any update. 2021-07-28 Yusuke Suzuki [JSC] Yarr should perform BoyerMoore search https://bugs.webkit.org/show_bug.cgi?id=228301 Reviewed by Saam Barati. * wtf/BitVector.cpp: (WTF::BitVector::dump const): * wtf/Bitmap.h: (WTF::WordType>::dump const): * wtf/UniqueRef.h: (WTF::makeUniqueRefFromNonNullUniquePtr): (WTF::UniqueRef::UniqueRef): 2021-07-29 Kate Cheney REGRESSION (r278877) [Cocoa] WebAuthn stopped working for non-Safari browsers https://bugs.webkit.org/show_bug.cgi?id=228116 Patch by Brent Fulgham. Reviewed by Per Arne Vollan. Add new SPI header for code signing features. * WTF.xcodeproj/project.pbxproj: * wtf/spi/cocoa/SecuritySPI.h: * wtf/spi/darwin/CodeSignSPI.h: Added. 2021-07-29 Eric Carlson [iOS] Don't set capture attribution dynamically in the simulator https://bugs.webkit.org/show_bug.cgi?id=228596 rdar://81176531 Reviewed by Jer Noble. * wtf/PlatformHave.h: Don't define HAVE_SYSTEM_STATUS for the simulator. 2021-07-29 Kate Cheney GetIdentifierStringForPreferredVoiceInListWithLocale() is deprecated in Monterey Patch by David Kilzer. Reviewed by David Kilzer. * wtf/PlatformHave.h: - Add HAVE(SPEECHSYNTHESIS_MONTEREY_SPI). 2021-07-28 Jean-Yves Avenard [WebAudio] Add webm/opus container support https://bugs.webkit.org/show_bug.cgi?id=227110 Reviewed by Jer Noble. Add WebMWebAudioEnabled preference to make canPlayType return probably for mimetype: "audio/webm; codecs=opus" Disabled by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-07-28 Ryosuke Niwa makeWeakPtr should support Ref and RefPtr as the argument https://bugs.webkit.org/show_bug.cgi?id=228574 Reviewed by Wenson Hsieh. This patch adds variants of makeWeakPtr which take Ref and RefPtr. Tests: TestWebKitAPI.WTF_WeakPtr.MakeWeakPtrTakesRef TestWebKitAPI.WTF_WeakPtr.MakeWeakPtrTakesRefPtr * wtf/WeakPtr.h: (WTF::makeWeakPtr): 2021-07-28 Myles C. Maxfield [Cocoa] macOS Monterey and parallel OSes no longer need r280103 https://bugs.webkit.org/show_bug.cgi?id=228539 Reviewed by Alan Bujtas. Core Text's behavior changed on these OSes. * wtf/PlatformUse.h: 2021-07-26 Yusuke Suzuki Unreviewed, speculative revert of r280193 https://bugs.webkit.org/show_bug.cgi?id=228142 * wtf/Vector.h: (WTF::Malloc>::shrinkCapacity): (WTF::Malloc>::shrinkToBestFit): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::UCharBufferTranslator::equal): (WTF::LCharBufferTranslator::equal): (WTF::BufferFromStaticDataTranslator::equal): * wtf/text/StringView.h: (WTF::StringView::stripLeadingMatchedCharacters): Deleted. 2021-07-26 Jer Noble [Cocoa] WebKit is making GroupActivities API calls for all WebKit clients https://bugs.webkit.org/show_bug.cgi?id=228299 Reviewed by Eric Carlson. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-07-26 Per Arne The layout test fast/images/heic-as-background-image.html is a constant failure https://bugs.webkit.org/show_bug.cgi?id=228195 Reviewed by Said Abou-Hallawa. Add HAVE macro for the system function CMPhotoIsTileDecoderAvailable. * wtf/PlatformHave.h: 2021-07-26 Jer Noble [iOS] All home screen web apps resume when any home screen web app is foregrounded https://bugs.webkit.org/show_bug.cgi?id=228246 Reviewed by Eric Carlson. * Scripts/Preferences/WebPreferences.yaml: 2021-07-23 Chris Dumez SharedBuffer::takeData() is a bit dangerous https://bugs.webkit.org/show_bug.cgi?id=228161 Reviewed by Darin Adler. Add Vector::uncheckedAppend() overload that takes in a Span. * wtf/Vector.h: (WTF::Vector::uncheckedAppend): (WTF::Malloc>::uncheckedAppend): 2021-07-23 Robert Jenner Unreviewed, reverting r280205. Broke multiple WebAuthn tests. Reverted changeset: "REGRESSION (r278877) [Cocoa] WebAuthn stopped working for non-Safari browsers" https://bugs.webkit.org/show_bug.cgi?id=228116 https://commits.webkit.org/r280205 2021-07-23 Philippe Normand [GLib] Remove libportal dependency https://bugs.webkit.org/show_bug.cgi?id=228056 Reviewed by Carlos Garcia Campos. * Scripts/Preferences/WebPreferencesExperimental.yaml: Enable screen capture on GStreamer ports. The PIPEWIRE ifdef is redundant. 2021-07-22 Brent Fulgham REGRESSION (r278877) [Cocoa] WebAuthn stopped working for non-Safari browsers https://bugs.webkit.org/show_bug.cgi?id=228116 Reviewed by Per Arne Vollan. Add new SPI header for code signing features. * WTF.xcodeproj/project.pbxproj: * wtf/spi/cocoa/SecuritySPI.h: Move some SecTask calls out of PLATFORM(MAC). * wtf/spi/darwin/CodeSignSPI.h: Added. 2021-07-22 Saam Barati Fix uses of Dependency::fence with respect to the compiler outsmarting us https://bugs.webkit.org/show_bug.cgi?id=227757 Reviewed by Robin Morisset. * wtf/Atomics.h: (WTF::opaque): (WTF::Dependency::loadAndFence): 2021-07-22 Yusuke Suzuki Unreviewed, follow-up after r280193 https://bugs.webkit.org/show_bug.cgi?id=228142 I accidentally reverted auto change when switching branches. * wtf/text/AtomStringImpl.cpp: (WTF::UCharBufferTranslator::equal): (WTF::LCharBufferTranslator::equal): (WTF::BufferFromStaticDataTranslator::equal): 2021-07-22 Yusuke Suzuki Micro-optimize innerHTML https://bugs.webkit.org/show_bug.cgi?id=228142 Reviewed by Simon Fraser. * wtf/Vector.h: (WTF::Malloc>::shrinkToBestFit): This shrinks the backing storage to "appropriate for the living Vector". * wtf/text/AtomStringImpl.cpp: (WTF::UCharBufferTranslator::equal): WTF::equal for String does not check hash. This is because computing hash is expensive and we would like to avoid that if it is not necessary. But when inserting string into AtomStringTable, we can use hash value since they must be already computed because of HashMap's requirement. So let's use it before calling WTF::equal. (WTF::LCharBufferTranslator::equal): (WTF::BufferFromStaticDataTranslator::equal): * wtf/text/StringView.h: (WTF::StringView::stripLeadingMatchedCharacters): Add this and use it in HTMLTreeBuilder. 2021-07-22 Alex Christensen XHR.send(Document) should replace mismatched surrogates with replacement character before sending https://bugs.webkit.org/show_bug.cgi?id=228170 Reviewed by Chris Dumez. * wtf/text/WTFString.cpp: (WTF::replaceUnpairedSurrogatesWithReplacementCharacter): * wtf/text/WTFString.h: Move from WebCore, rename as suggested, update spec link to one that works. 2021-07-22 Zan Dobersek Add CPU(RISCV64) https://bugs.webkit.org/show_bug.cgi?id=228178 Reviewed by Adrian Perez de Castro. Detect when compiling for the RISC-V 64-bit architecture and define the WTF_CPU_RISCV64 macro under that condition, enabling use of CPU(RISCV64) build guards. * wtf/PageBlock.h: Use 4 kB as the page size ceiling for CPU(RISCV64). * wtf/PlatformCPU.h: 2021-07-21 Miguel Gomez [GTK][WPE] Allow the user to configure the MemoryPressureHandler inside the web process https://bugs.webkit.org/show_bug.cgi?id=222738 Reviewed by Carlos Garcia Campos. Add a configuration structure to MemoryPressureHandler, with the methods to encode/decode it. Also add a method to set a configuration structure to a MemoryPressureHandler instance, and modify the behavior so the the configuration is used when checking the memory used by the process. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor): (WTF::MemoryPressureHandler::thresholdForMemoryKill): (WTF::MemoryPressureHandler::thresholdForPolicy): (WTF::MemoryPressureHandler::policyForFootprint): (WTF::MemoryPressureHandler::Configuration::Configuration): * wtf/MemoryPressureHandler.h: (WTF::MemoryPressureHandler::Configuration::encode const): (WTF::MemoryPressureHandler::Configuration::decode): (WTF::MemoryPressureHandler::setConfiguration): 2021-07-21 Chris Dumez Unreviewed, reverting r280129. Broke the internal Monterey build bots Reverted changeset: "GetIdentifierStringForPreferredVoiceInListWithLocale() is deprecated in Monterey" https://bugs.webkit.org/show_bug.cgi?id=228066 https://commits.webkit.org/r280129 2021-07-21 David Kilzer GetIdentifierStringForPreferredVoiceInListWithLocale() is deprecated in Monterey Reviewed by Alexey Proskuryakov. * wtf/PlatformHave.h: - Add HAVE(SPEECHSYNTHESIS_MONTEREY_SPI). 2021-07-20 Myles C. Maxfield r280103 is not necessary on all operating systems https://bugs.webkit.org/show_bug.cgi?id=228136 Reviewed by Alan Bujtas. * wtf/PlatformUse.h: 2021-07-16 Alexander Mikhaylenko [GTK][WPE] Support color-schemes CSS property https://bugs.webkit.org/show_bug.cgi?id=208204 Reviewed by Adrian Perez de Castro. * wtf/PlatformHave.h: Enable HAVE_OS_DARK_MODE_SUPPORT for GTK and WPE. 2021-07-15 Jean-Yves Avenard [Wk1] media/media-source/media-webm-opus-partial.html is a consistent failure (Enable VP8/VP9/Vorbis/Opus in WebKitLegacy) https://bugs.webkit.org/show_bug.cgi?id=228005 rdar://80346720 Reviewed by Jer Noble. * Scripts/Preferences/WebPreferencesExperimental.yaml: Enable VP8/VP9/Vorbis/Opus codecs for WebKitLegacy, no reasons they weren't already enabled. 2021-07-15 Joonghun Park Unreviewed. Fix the build warning below since r279895. warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare] * wtf/URL.cpp: (WTF::URL::setPath): 2021-07-15 Chris Dumez Add initial support for BroadcastChannel behind a runtime flag https://bugs.webkit.org/show_bug.cgi?id=227924 Reviewed by Sam Weinig. Add experimental feature flag for BroadcastChannel, off by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-07-15 Philippe Normand [GStreamer][Pipewire] Implement getDisplayMedia() backend https://bugs.webkit.org/show_bug.cgi?id=210926 Reviewed by Xabier Rodriguez-Calvar. * Scripts/Preferences/WebPreferencesExperimental.yaml: Enable screen-capture if libportal was found. 2021-07-14 Jer Noble Unreviewed build fix after r279912 (239661@main); Add a HAVE(SYSTEM_STATUS) macro. * wtf/PlatformHave.h: 2021-07-13 Alex Christensen Update and fix URL WPT tests https://bugs.webkit.org/show_bug.cgi?id=227820 Reviewed by Chris Dumez. There was an edge case where if we set a path to an empty string, it would add a slash. No more. * wtf/URL.cpp: (WTF::URL::setPath): 2021-07-13 Michael Catanzaro Remove USE_64KB_PAGE_BLOCK https://bugs.webkit.org/show_bug.cgi?id=227905 Reviewed by Yusuke Suzuki. * wtf/PageBlock.h: 2021-07-12 Filip Pizlo and Yusuke Suzuki New malloc algorithm https://bugs.webkit.org/show_bug.cgi?id=226404 Reviewed by Yusuke Suzuki. Introduce flags for using libpas as the ExecutableAllocator. Explicitly ask for gigacage initialization, since libpas prefers it this way right now. * wtf/FastTLS.h: * wtf/PlatformUse.h: * wtf/Threading.cpp: (WTF::initialize): 2021-07-12 Wenson Hsieh [Cocoa] Turn on `USE(OS_STATE)` when building with a non-Apple-internal SDK https://bugs.webkit.org/show_bug.cgi?id=227884 Reviewed by Tim Horton. Enable the compile-time flag for all Cocoa builds. * wtf/PlatformUse.h: 2021-07-12 Chris Fleizach AX: Make WebKit observe spatial audio accessibility settings https://bugs.webkit.org/show_bug.cgi?id=227848 Reviewed by Sam Weinig. This flag was using the wrong format for a HAVE setting, so the code wasn't being compiled in. * wtf/PlatformHave.h: 2021-07-12 Simon Fraser Add a StyleSheets log channel and some logging https://bugs.webkit.org/show_bug.cgi?id=227880 Reviewed by Alan Bujtas. Make it possible to feed Ref<> and RefPtr<> into TextStream. * wtf/text/TextStream.h: (WTF::operator<<): 2021-07-09 Jer Noble [Cocoa] Make Coordinator playback commands more precise https://bugs.webkit.org/show_bug.cgi?id=227756 Reviewed by Eric Carlson. Add a method to convert from a MonotonicTime to a MachAbsoluteTime. * wtf/CurrentTime.cpp: (WTF::machTimebaseInfo): (WTF::MonotonicTime::fromMachAbsoluteTime): (WTF::MonotonicTime::toMachAbsoluteTime const): * wtf/MonotonicTime.h: * wtf/PlatformHave.h: 2021-07-08 Alex Christensen Fix some whitespace handling issues in URL setters https://bugs.webkit.org/show_bug.cgi?id=227806 Reviewed by Chris Dumez. Setters should ignore tabs and newlines like the main parser does. The protocol setter is problematic, which I reported in https://github.com/whatwg/url/issues/620 * wtf/URL.cpp: (WTF::URL::setFragmentIdentifier): * wtf/URLParser.cpp: (WTF::URLParser::isSpecialScheme): (WTF::URLParser::parse): * wtf/URLParser.h: The URL.hash setter should allow trailing C0 and control characters, which we would otherwise trim. Rather than introduce a new parameter, use a sentinel value for when we need to do this. 2021-07-08 Brent Fulgham [Cocoa] Expose SPI to opt out of Extensible SSO authentication https://bugs.webkit.org/show_bug.cgi?id=227729 Reviewed by Tim Horton. Create new WKPreference to allow WebKit clients to opt out of Extensible SSO authentication. * Scripts/Preferences/WebPreferences.yaml: 2021-07-07 Alex Christensen URL host setter should pass host to URLParser instead of trying to encode it itself https://bugs.webkit.org/show_bug.cgi?id=227749 Reviewed by Chris Dumez. For non-special schemes, the host is percent-encoded instead of punycode-encoded. Allowing the URL parser to handle all input directly does the right thing for non-special schemes. * wtf/URL.cpp: (WTF::URL::setHost): (WTF::URL::setHostAndPort): 2021-07-07 Alex Christensen URL path setter should add "./" before non-empty path and after empty host for URLs with non-special schemes https://bugs.webkit.org/show_bug.cgi?id=227750 Reviewed by Chris Dumez. This is related to r267837 but in the path setter, too. This helps preserve idempotence in parsed URLs. This is an edge case that will rarely be hit in practice, but now the path setter matches the parser. * wtf/URL.cpp: (WTF::URL::setPath): 2021-07-07 Christopher Reid [PlayStation] Don't assume 4KB block size when estimating Network Cache disk usage https://bugs.webkit.org/show_bug.cgi?id=227502 Reviewed by Chris Dumez. Add getVolumeFileBlockSize to fetch the block size from the filesystem. Currently only implemented for Windows and POSIX filesystems. * wtf/FileSystem.cpp: * wtf/FileSystem.h: * wtf/playstation/FileSystemPlayStation.cpp: 2021-07-07 Alex Christensen Use more Span https://bugs.webkit.org/show_bug.cgi?id=227606 Reviewed by Darin Adler. New is always better, right? * wtf/FileSystem.cpp: (WTF::FileSystemImpl::mapToFile): * wtf/FileSystem.h: * wtf/persistence/PersistentCoders.cpp: (WTF::Persistence::Coder::encode): (WTF::Persistence::Coder::decode): (WTF::Persistence::Coder::encode): (WTF::Persistence::decodeStringText): (WTF::Persistence::Coder::encode): (WTF::Persistence::Coder::decode): * wtf/persistence/PersistentCoders.h: * wtf/persistence/PersistentDecoder.cpp: (WTF::Persistence::Decoder::Decoder): (WTF::Persistence::Decoder::bufferIsLargeEnoughToContain const): (WTF::Persistence::Decoder::bufferPointerForDirectRead): (WTF::Persistence::Decoder::decodeFixedLengthData): (WTF::Persistence::Decoder::decodeNumber): (WTF::Persistence::Decoder::verifyChecksum): * wtf/persistence/PersistentDecoder.h: (WTF::Persistence::Decoder::length const): (WTF::Persistence::Decoder::currentOffset const): * wtf/persistence/PersistentEncoder.cpp: (WTF::Persistence::Encoder::updateChecksumForData): (WTF::Persistence::Encoder::encodeFixedLengthData): (WTF::Persistence::Encoder::encodeChecksum): * wtf/persistence/PersistentEncoder.h: 2021-07-05 Yusuke Suzuki [JSC] Optimize Object.assign and putDirectInternal https://bugs.webkit.org/show_bug.cgi?id=227677 Reviewed by Filip Pizlo. * wtf/HashMap.h: * wtf/HashSet.h: * wtf/HashTable.h: (WTF::HashTable::isNullStorage const): 2021-07-02 Brent Fulgham [macOS] Only use WebGL on Metal by default on safe versions of macOS https://bugs.webkit.org/show_bug.cgi?id=227633 Reviewed by Dean Jackson. Tested by WebGL test suite. * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformHave.h: 2021-07-01 Youenn Fablet Disable relay for UDP sockets when not needed https://bugs.webkit.org/show_bug.cgi?id=227253 Reviewed by Eric Carlson. * wtf/PlatformHave.h: Add a macro for new NW methods. 2021-07-01 Antoine Quint [Model] Restrict IPC calls to ARKit SPI availability and runtime flag https://bugs.webkit.org/show_bug.cgi?id=227581 Reviewed by Tim Horton. Define a new compile-time flag when either of the iOS or macOS ARKit SPIs are available. * wtf/PlatformHave.h: 2021-07-01 Aditya Keerthi [iOS] in watchOS 8 https://bugs.webkit.org/show_bug.cgi?id=226955 Reviewed by Darin Adler. Add compile-time flags to guard the presence of `PUICQuickboardController` and `PUICButtonTypePill`. * wtf/PlatformHave.h: 2021-06-11 Ryosuke Niwa Add WeakHashMap https://bugs.webkit.org/show_bug.cgi?id=226872 Reviewed by Geoffrey Garen. Added WeakHashMap which deletes entries during rehashing and amortized over time (based on the number of read & write accesses done on a given WeakHashMap instance). * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/WeakHashMap.h: Added. (WTF::WeakHashMap): Added. (WTF::WeakHashMap::PeekKeyValuePairTraits): Added. (WTF::WeakHashMap::PeekType): Added. (WTF::WeakHashMap::PeekPtrType): Added. Unlike a regular HashMap, we need to fake the iterator pointer value with this struct since key-value pair doesn't exist in HashTable itself as it stores Ref instead. (WTF::WeakHashMap::WeakHashMapIteratorBase): Added. Has a bunch of helper functions so that WeakHashMapIterator and WeakHashMapConstIterator can share the code. (WTF::WeakHashMap::WeakHashMapIterator): Added. (WTF::WeakHashMap::WeakHashMapConstIterator): Added. (WTF::WeakHashMap::AddResult): Added. (WTF::WeakHashMap::begin): Added. (WTF::WeakHashMap::end): Added. (WTF::WeakHashMap::add): Added. (WTF::WeakHashMap::set): Added. (WTF::WeakHashMap::find): Added. (WTF::WeakHashMap::contains): Added. (WTF::WeakHashMap::get): Added. (WTF::WeakHashMap::remove): Added. (WTF::WeakHashMap::removeIf): Added. (WTF::WeakHashMap::clear): Added. (WTF::WeakHashMap::capacity): Added. (WTF::WeakHashMap::isEmptyIgnoringNullReferences): Added. This is akin to WeakHashSet::computesEmpty. Per prior discussion, we intend to rename WeakHashSet's version to this name as well for clarity. Note that this function will clear the hash table completely if the map is semantically empty but HashTable contains null references as keys. (WTF::WeakHashMap::hasNullReferences): Added. Triggers amortized cleanup based on the number of iterations performed. If there are no null references, it resets m_operationCountSinceLastCleanup. (WTF::WeakHashMap::computeSize): Added. (WTF::WeakHashMap::removeNullReferences): Added. Since WeakHashMap doesn't eagerly delete the value when the key goes away, this function should be called when values held onto by WeakRefImpl with the nullptr back pointer should be deleted en masse. (WTF::WeakHashMap::checkConsistency): Added. (WTF::WeakHashMap::makeKeyImpl): Added. (WTF::WeakHashMap::keyImplIfExists): Added. * wtf/WeakPtr.h: 2021-06-11 Jonathan Bedard [Monterey] Support building WebKit https://bugs.webkit.org/show_bug.cgi?id=226846 Reviewed by Tim Horton. * wtf/PlatformHave.h: Add HAVE(VK_IMAGE_ANALYSIS). * wtf/spi/cocoa/SecuritySPI.h: 2021-06-09 Chris Dumez Avoid some calls to StringView::toString() / StringView::toStringWithoutCopying() https://bugs.webkit.org/show_bug.cgi?id=226803 Reviewed by Darin Adler. Add support to TextStream for printing a StringView directly, without having to convert it to a String first. * wtf/text/TextStream.cpp: (WTF::TextStream::operator<<): * wtf/text/TextStream.h: 2021-06-09 Alicia Boya García [WTF][GStreamer] Add RAII lockers for 3rd party locks https://bugs.webkit.org/show_bug.cgi?id=225650 Reviewed by Xabier Rodriguez-Calvar. This patch introduces WTF::ExternalLocker, which allows to lock 3rd party mutexes in a RAII fashion, very similar to WTF::Locker. This is used also in WebCore to provide RAII lockers for GStreamer. * wtf/Locker.h: (WTF::unlockFunction): 2021-06-08 Alex Christensen Move PrivacyStance code from WebKitAdditions https://bugs.webkit.org/show_bug.cgi?id=226774 Reviewed by Jer Noble. * wtf/PlatformHave.h: 2021-06-08 Ben Nham Use access instead of stat in some filesystem functions https://bugs.webkit.org/show_bug.cgi?id=226667 Reviewed by Chris Dumez. We are spending a bit more time in WTF::FileSystemImpl functions after the move to std::filesystem (https://bugs.webkit.org/show_bug.cgi?id=225255). In particular, several std::filesystem functions (like the ones called by fileExists and makeAllDirectories) prefer to use stat() over access() for file existence checks. Since our sandbox has a fast path for access(path, F_OK) but not for stat, we ended up spending more time in sandbox evaluation in the kernel after the move to std::filesystem. Note that the two checks don't do exactly the same thing. access(path, F_OK) only checks for path existence, while stat(path) additionally fetches metadata, which requires checking the file-read-metadata permission. But in practice our code was written to be fine with just checking for existence. To work around this, I've re-introduced some of the old WTF::FileSystemImpl functions from FileSystemPosix.cpp. They are the ones that are called by NetworkCache, which seems to be the biggest consumer of these functions. The rest of the functions are still implemented using std::filesystem. * wtf/FileSystem.cpp: (WTF::FileSystemImpl::fileExists): (WTF::FileSystemImpl::deleteFile): (WTF::FileSystemImpl::makeAllDirectories): (WTF::FileSystemImpl::pathByAppendingComponent): (WTF::FileSystemImpl::pathByAppendingComponents): * wtf/PlatformEnableCocoa.h: * wtf/posix/FileSystemPOSIX.cpp: (WTF::FileSystemImpl::fileExists): (WTF::FileSystemImpl::deleteFile): (WTF::FileSystemImpl::makeAllDirectories): (WTF::FileSystemImpl::pathByAppendingComponent): (WTF::FileSystemImpl::pathByAppendingComponents): 2021-06-08 Devin Rousso [Payment Request] upstream new features https://bugs.webkit.org/show_bug.cgi?id=226740 Reviewed by Andy Estes. - recurring line items (`HAVE_PASSKIT_RECURRING_SUMMARY_ITEM` and `ENABLE_APPLE_PAY_RECURRING_LINE_ITEM`) - deferred line items (`HAVE_PASSKIT_DEFERRED_SUMMARY_ITEM` and `ENABLE_APPLE_PAY_DEFERRED_LINE_ITEM`) - estimated shipping dates (`HAVE_PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE` and `ENABLE_APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE`) - coupon code entry (`HAVE_PASSKIT_COUPON_CODE` and `ENABLE_APPLE_PAY_COUPON_CODE`) - shipped vs in-store pickup (`HAVE_PASSKIT_SHIPPING_CONTACT_EDITING_MODE` and `ENABLE_APPLE_PAY_SHIPPING_CONTACT_EDITING_MODE`) * wtf/PlatformHave.h: * wtf/PlatformEnableCocoa.h: 2021-06-08 Chris Dumez Reduce use of reinterpret_cast<> in the codebase https://bugs.webkit.org/show_bug.cgi?id=226743 Reviewed by Darin Adler. * wtf/CryptographicallyRandomNumber.cpp: * wtf/FastMalloc.h: (WTF::FastAllocator::allocate): * wtf/SHA1.h: (WTF::SHA1::addBytes): * wtf/StackCheck.h: (WTF::StackCheck::Scope::Scope): (WTF::StackCheck::StackCheck): * wtf/URLHelpers.cpp: (WTF::URLHelpers::userVisibleURL): * wtf/URLParser.cpp: (WTF::URLParser::formURLDecode): * wtf/cf/URLCF.cpp: (WTF::URL::createCFURL const): * wtf/cocoa/URLCocoa.mm: (WTF::URL::createCFURL const): * wtf/persistence/PersistentCoders.cpp: (WTF::Persistence::Coder::encode): (WTF::Persistence::Coder::encode): * wtf/text/CString.h: * wtf/text/WTFString.cpp: (WTF::String::latin1 const): * wtf/text/cf/StringImplCF.cpp: (WTF::StringImpl::createCFString): 2021-06-08 Devin Rousso [Modern Media Controls] upstream new features https://bugs.webkit.org/show_bug.cgi?id=226736 Reviewed by Eric Carlson. - bring the "Audio"/"Languages" tracks menu to iOS - add a new "Playback Speed" menu on iOS and macOS in the overflow menu - add support for showing the most relevant `` in the overflow menu * wtf/PlatformEnableCocoa.h: 2021-06-08 Sam Weinig Add copy of std::span so that we can use it pre-moving to c++20 https://bugs.webkit.org/show_bug.cgi?id=226351 Reviewed by Alex Christensen. Imports a copy of Tristan Brindle's Boost licensed implementation of std::span from 5d8d366eca918d0ed3d2d196cbeae6abfd874736 of https://github.com/tcbrindle/span. It has been further modified to rename tcb::span to WTF::Span. * LICENSE_1_0-Boost.txt: Added. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Span.h: Added. 2021-06-07 Alex Christensen Adopt SecTrustGetCertificateAtIndex replacement where available https://bugs.webkit.org/show_bug.cgi?id=225893 Reviewed by Chris Dumez. rdar://74752046 introduced a new way to access the same thing. * wtf/PlatformHave.h: 2021-06-07 Chris Dumez Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): 2021-06-07 Wenson Hsieh Upstream WebKit support for Live Text https://bugs.webkit.org/show_bug.cgi?id=226706 Reviewed by Tim Horton. * wtf/PlatformEnableCocoa.h: Move the feature flag out of WebKitAdditions and into OpenSource as IMAGE_ANALYSIS. 2021-06-07 Alicia Boya García [WTF][GStreamer] Fix clang TSA warnings in WTF::DataMutex https://bugs.webkit.org/show_bug.cgi?id=226719 Reviewed by Xabier Rodriguez-Calvar. Fix the remaning clang thread safety warnings in WTF::DataMutex. The goal of this patch is to reduce the number of warnings in the GStreamer codebase. Whether DataMutex should be deprecated in favor of Locker with the clang TSA annotations is outside of the scope of this patch. * wtf/DataMutex.h: 2021-06-07 Alicia Boya García [GStreamer] Remove spurious assert in WTF::DataMutex https://bugs.webkit.org/show_bug.cgi?id=226714 Reviewed by Michael Catanzaro. Remove DATA_MUTEX_CHECK(!mutex().isHeld()); from the DataMutexLocker constructor, introduced in r278248. Trying to lock a currently held mutex is not an error condition that should crash the process, it will just wait for its turn to lock it. * wtf/DataMutex.h: 2021-06-06 Chris Dumez Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): 2021-06-04 Chris Dumez FileSystem::readFromFile() should return data as `void*` https://bugs.webkit.org/show_bug.cgi?id=226671 Reviewed by Darin Adler. FileSystem::readFromFile() should return data as `void*` instead of `char*`. This is more flexible and consistent with FileSystem::writeToFile(). * wtf/FileSystem.cpp: (WTF::FileSystemImpl::appendFileContentsToFileHandle): (WTF::FileSystemImpl::readOrMakeSalt): * wtf/FileSystem.h: * wtf/glib/FileSystemGlib.cpp: (WTF::FileSystemImpl::readFromFile): * wtf/posix/FileSystemPOSIX.cpp: (WTF::FileSystemImpl::readFromFile): * wtf/win/FileSystemWin.cpp: (WTF::FileSystemImpl::readFromFile): 2021-06-04 Alex Christensen Implement off-by-default experimental feature for PerformanceResourceTiming.transferSize, encodedBodySize, and decodedBodySize https://bugs.webkit.org/show_bug.cgi?id=226629 Reviewed by Brady Eidson. * Scripts/Preferences/WebPreferencesExperimental.yaml: 2021-06-04 Devin Rousso Add a way to prefix output of `WTFReportBacktrace` to make log filtering easier https://bugs.webkit.org/show_bug.cgi?id=226390 Reviewed by Megan Gardner. Often times while debugging I add `WTFLogAlways(" ...")` to various places as indicators that "logic has reached here". This is especially useful when debugging iOS as unlike macOS there's no console output from `run-safari`, meaning that I have to use system logging, which is often a deluge of unrelated information. Having "" as a prefix makes filtering through the system logging trivial as I can ignore logs that don't have it. Unfortunately, `WTFReportBacktrace` does not have a way to add this prefix, so it becomes much harder to find in the logs. This patch enables adding a prefix to each line of `WTFReportBacktrace` via a new function `WTFReportBactraceWithPrefix`. * wtf/Assertions.h: * wtf/Assertions.cpp: (WTFReportBacktraceWithPrefix): Added. (WTFPrintBacktraceWithPrefix): Added. * wtf/StackTrace.h: (WTF::StackTrace::StackTrace): * wtf/StackTrace.cpp: (WTF::StackTrace::dump const): 2021-06-04 Michael Catanzaro Fix more GCC warnings https://bugs.webkit.org/show_bug.cgi?id=226193 Reviewed by Adrian Perez de Castro. Add missing static_cast required to suppress GCC's -Wclass-memaccess warning when intentionally not running constructors/destructors. There's already a static_assert to ensure this is safe, which is better than usual for us. * wtf/SmallSet.h: 2021-06-03 Chris Dumez Unreviewed build fix after r277881. Fix warning about unused function. * wtf/cocoa/FileSystemCocoa.mm: 2021-06-03 Michael Catanzaro REGRESSION(r277744): Broke build on s390x mainframes https://bugs.webkit.org/show_bug.cgi?id=226497 Reviewed by Darin Adler. The problem is we have a template defined in a C++ source file, used by multiple source files. This is not valid C++, so let's split the templates defined in StringBuilder.cpp out into a new StringBuilderInternals.h that we can #include in both StringBuilder.cpp and StringBuilderJSON.cpp. Ideally we would move the template defined in StringBuilderJSON.cpp as well, and then eliminate StringBuilderJSON.cpp since there would only be one function left. But that file has an MPL license. It's easier to leave it be to keep the license situation simpler. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/text/StringBuilder.cpp: (WTF::StringBuilder::expandedCapacity): (WTF::expandedCapacity): Deleted. (WTF::StringBuilder::allocateBuffer): Deleted. (WTF::StringBuilder::extendBufferForAppending): Deleted. (WTF::StringBuilder::extendBufferForAppendingSlowCase): Deleted. * wtf/text/StringBuilder.h: * wtf/text/StringBuilderInternals.h: Added. (WTF::StringBuilder::allocateBuffer): (WTF::StringBuilder::reallocateBuffer): (WTF::StringBuilder::extendBufferForAppending): (WTF::StringBuilder::extendBufferForAppendingSlowCase): * wtf/text/StringBuilderJSON.cpp: 2021-06-02 Chris Dumez Drop WTF::Vector overloads taking index as Checked https://bugs.webkit.org/show_bug.cgi?id=226553 Reviewed by Geoffrey Garen. Drop WTF::Vector overloads taking index as Checked. They are no longer needed now that Checked can implicitly get converted to size_t (r278338). * wtf/Vector.h: (WTF::Vector::at const): (WTF::Vector::operator[] const): 2021-06-02 Chris Dumez Drop Checked::safeGet() https://bugs.webkit.org/show_bug.cgi?id=226537 Reviewed by Geoffrey Garen. Drop Checked::safeGet() and replace with uses of Checked::operator T() or Checked::value(). safeGet() is a bit akward, having both a return value and an out-parameter. * wtf/CheckedArithmetic.h: (WTF::Checked::value const): (WTF::operator+): (WTF::operator-): (WTF::operator*): (WTF::operator/): 2021-06-02 Antti Koivisto Style::Scope should use CheckedPtr https://bugs.webkit.org/show_bug.cgi?id=226530 Reviewed by Sam Weinig. * wtf/CMakeLists.txt: 2021-06-02 Chris Dumez Use Checked aliases instead of Checked https://bugs.webkit.org/show_bug.cgi?id=226535 Reviewed by Keith Miller. * wtf/URLHelpers.cpp: (WTF::URLHelpers::userVisibleURL): * wtf/URLParser.cpp: (WTF::URLParser::parseIPv4Piece): * wtf/cocoa/NSURLExtras.mm: (WTF::dataWithUserTypedString): * wtf/glib/SocketConnection.cpp: (WTF::SocketConnection::sendMessage): 2021-05-23 Ryosuke Niwa Add CheckedPtr https://bugs.webkit.org/show_bug.cgi?id=226158 Reviewed by Antti Koivisto. This patch introduces a new type of smart pointer, CheckedPtr, which behaves like RefPtr and let each object keep track of pointers pointing to the object. Unlike CheckedPtr, the purpose of this internal counter is to release assert that there is no outstanding pointer at the time of destruction instead of keeping the object alive when there is one. * WTF.xcodeproj/project.pbxproj: * wtf/CheckedPtr.h: Added. (WTF::CheckedPtr): Added. (WTF::CheckedPtr::CheckedPtr): Added. (WTF::CheckedPtr::~CheckedPtr): Added. (WTF::CheckedPtr::isHashTableDeletedValue const): Added. (WTF::CheckedPtr::operator UnspecifiedBoolType const): Added. (WTF::CheckedPtr::operator! const): Added. (WTF::CheckedPtr::get const): Added. (WTF::CheckedPtr::get): Added. (WTF::CheckedPtr::operator* const): Added. (WTF::CheckedPtr::operator*): Added. (WTF::CheckedPtr::operator-> const): Added. (WTF::CheckedPtr::operator->): Added. (WTF::CheckedPtr::operator== const): Added. (WTF::CheckedPtr::operator=): Added. (WTF::CheckedPtr::unspecifiedBoolTypeInstance const): Added. (WTF::CheckedPtr::refIfNotNull): Added. (WTF::CheckedPtr::derefIfNotNull): Added. (WTF::makeCheckedPtr): Added. (WTF::is): Added. (WTF::CanMakeCheckedPtr): Added. (WTF::CanMakeCheckedPtr::~CanMakeCheckedPtr): Added. Release assert that m_ptrCount is 0. (WTF::CanMakeCheckedPtr::ptrCount const): Added. (WTF::CanMakeCheckedPtr::incrementPtrCount): Added. (WTF::CanMakeCheckedPtr::decrementPtrCount): Added. Note that we don't do anything when m_ptrCount becomes 0 unlike RefPtr. (WTF::HashTraits>): Added. (WTF::HashTraits>::emptyValue): Added. (WTF::HashTraits>::peek): Added. (WTF::HashTraits>::customDeleteBucket): Added. 2021-06-01 Darin Adler Remove https://bugs.webkit.org/show_bug.cgi?id=226437 Reviewed by Chris Dumez. * : Removed include of . * WTF.xcodeproj/project.pbxproj: Removed Optional.h. * wtf/Markable.h: Added include of . * wtf/OptionSet.h: Ditto. * wtf/Optional.h: Emptied this file. On the Windows build system, we can't seem to build successfully without an empty file here. The copied forwarding header seems to linger even if we remove the original. Until we fix the Windows build system, if we want to support incremental builds, we need to keep this empty file around. * wtf/PrintStream.h: Added include of . * wtf/Seconds.h: Ditto. * wtf/StackTrace.h: Ditto. * wtf/StdLibExtras.h: Moved the valueOrCompute function here from Optional.h. Re-sorted the "using" at the bottom of the file. * wtf/URLHelpers.h: Added include of . * wtf/Vector.h: Ditto. 2021-06-01 Chris Dumez Rename Checked::unsafeGet() to Checked::value() https://bugs.webkit.org/show_bug.cgi?id=226514 Reviewed by Darin Adler. Rename Checked::unsafeGet() to Checked::value(). The "unsafeGet" naming is confusing as this function isn't really unsafe since it will crash if the value has overflowed. Also add an `operator T()` to implicitly convert a Checked to its underlying type without needing to call value(). * wtf/CheckedArithmetic.h: (WTF::Checked::operator! const): (WTF::Checked::operator bool const): (WTF::Checked::operator T const): (WTF::Checked::value const): (WTF::Checked::operator==): (WTF::Checked::operator< const): (WTF::Checked::operator<= const): (WTF::Checked::operator> const): (WTF::Checked::operator>= const): * wtf/ConcurrentBuffer.h: * wtf/FastMalloc.cpp: (WTF::fastCalloc): (WTF::tryFastCalloc): * wtf/Gigacage.cpp: (Gigacage::tryMallocArray): * wtf/URLHelpers.cpp: (WTF::URLHelpers::userVisibleURL): * wtf/URLParser.cpp: (WTF::URLParser::parseIPv4Piece): * wtf/UniqueArray.h: * wtf/cocoa/NSURLExtras.mm: (WTF::dataWithUserTypedString): * wtf/glib/SocketConnection.cpp: (WTF::SocketConnection::readMessage): (WTF::SocketConnection::sendMessage): * wtf/text/CString.cpp: (WTF::CStringBuffer::createUninitialized): * wtf/text/StringBuffer.h: (WTF::StringBuffer::StringBuffer): * wtf/text/StringBuilderJSON.cpp: (WTF::StringBuilder::appendQuotedJSONString): * wtf/text/StringConcatenate.h: (WTF::tryMakeStringFromAdapters): * wtf/text/StringImpl.h: (WTF::StringImpl::allocationSize): * wtf/text/StringToIntegerConversion.h: (WTF::parseInteger): 2021-06-01 Chris Dumez Unreviewed build fix after r277881. Silence unused parameter warnings. * wtf/cocoa/FileSystemCocoa.mm: (WTF::FileSystemImpl::setAllowsMaterializingDatalessFiles): (WTF::FileSystemImpl::allowsMaterializingDatalessFiles): Deleted. (WTF::FileSystemImpl::isSafeToUseMemoryMapForPath): Deleted. (WTF::FileSystemImpl::makeSafeToUseMemoryMapForPath): Deleted. 2021-06-01 Adrian Perez de Castro [WPE][GTK] Support building against uClibc https://bugs.webkit.org/show_bug.cgi?id=226244 Reviewed by Michael Catanzaro. * wtf/PlatformRegisters.h: Use the header instead of , which is enough to gain access to the type definitions for CPU registers and is available on every libc. On the other hand, uClibc does not have , so this fixes the build in that case. 2021-05-30 Chris Dumez Drop UncheckedCondition / UncheckedLock https://bugs.webkit.org/show_bug.cgi?id=226432 Reviewed by Darin Adler. Drop UncheckedCondition / UncheckedLock now that the whole codebase has been ported to Condition / Lock, which support Clang thread safety analysis. * wtf/Condition.h: * wtf/Forward.h: * wtf/Lock.cpp: (WTF::Lock::lockSlow): (WTF::Lock::unlockSlow): (WTF::Lock::unlockFairlySlow): (WTF::Lock::safepointSlow): * wtf/Lock.h: (WTF::assertIsHeld): (WTF::WTF_ASSERTS_ACQUIRED_LOCK): 2021-05-30 Darin Adler Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. * : Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. 2021-05-29 Chris Dumez Stop using UncheckedLock in JSC::VMInspector https://bugs.webkit.org/show_bug.cgi?id=226427 Reviewed by Mark Lam. Add Lock::tryLockWithTimeout(), similar to tryLock() but gives up after a specified timeout. This used to be implemented in VMInspector but I think Lock is a better place for it. * wtf/Lock.cpp: (WTF::Lock::tryLockWithTimeout): * wtf/Lock.h: 2021-05-29 Chris Dumez Adopt clang thread safety annotations in WTF::DataMutex https://bugs.webkit.org/show_bug.cgi?id=226431 Reviewed by Darin Adler. Adopt clang thread safety annotations in WTF::DataMutex. This allows us to stop using UncheckedCondition in a few places. * wtf/DataMutex.h: (WTF::DataMutex::DataMutex): 2021-05-28 Darin Adler Clients of optional should use has_value instead of relying on hasValue macro https://bugs.webkit.org/show_bug.cgi?id=226395 Reviewed by Chris Dumez. * wtf/Hasher.h: Use has_value. * wtf/Optional.h: Remove hasValue macro. Not needed any more, but also a bit dangerous because of how widespread the use of hasValue is for things other than WTF::Optional. 2021-05-28 Alex Christensen Punycode encode U+0BE6 when not in context of other Tamil characters https://bugs.webkit.org/show_bug.cgi?id=226409 Reviewed by Tim Horton. It has quite legitimate use, so we don't want to always punycode encode it, but when used in the context of non-Tamil characters we want to punycode encode it. * wtf/URLHelpers.cpp: (WTF::URLHelpers::isLookalikeCharacterOfScriptType): (WTF::URLHelpers::isLookalikeCharacterOfScriptType): (WTF::URLHelpers::isOfScriptType): (WTF::URLHelpers::isLookalikeSequence): (WTF::URLHelpers::isLookalikeCharacter): (WTF::URLHelpers::isArmenianLookalikeCharacter): Deleted. (WTF::URLHelpers::isArmenianScriptCharacter): Deleted. (WTF::URLHelpers::isArmenianLookalikeSequence): Deleted. 2021-05-28 Chris Dumez Stop using UncheckedLock in WTF::MetaAllocator https://bugs.webkit.org/show_bug.cgi?id=226396 Reviewed by Darin Adler. Stop using UncheckedLock in WTF::MetaAllocator, as it is being phased out in favor on Lock, which supports Clang thread safety analysis. * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocator::MetaAllocator): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::currentStatistics): * wtf/MetaAllocator.h: 2021-05-28 Robin Morisset Fix LikelyDenseUnsignedIntegerSet::clear() https://bugs.webkit.org/show_bug.cgi?id=226388 Reviewed by Mark Lam. There are two problems with it: 1) It calls BitVector::clearAll(), which does not free any memory. Instead, it should call BitVector::~BitVector(), then do a placement new of a fresh BitVector (to get it back to its inline condition) 2) More problematically, it changes m_size before calling isBitVector() which relies crucially on the value of m_size. So it is going to believe that it is in BitVector mode even when it is actually in HashSet mode. * wtf/LikelyDenseUnsignedIntegerSet.h: (WTF::LikelyDenseUnsignedIntegerSet::clear): 2021-05-28 Sam Weinig Add stub implementation of CA separated portal bits for GraphicsLayer https://bugs.webkit.org/show_bug.cgi?id=226343 Reviewed by Simon Fraser. * wtf/PlatformHave.h: Add HAVE_CORE_ANIMATION_SEPARATED_PORTALS. 2021-05-28 Chris Dumez Unreviewed build fix after r277881. Deal with IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES potentially not being defined on older OSes. * wtf/cocoa/FileSystemCocoa.mm: (WTF::FileSystemImpl::setAllowsMaterializingDatalessFiles): (WTF::FileSystemImpl::allowsMaterializingDatalessFiles): 2021-05-28 Chris Dumez Unreviewed build fix after r277881. Add missing header include. * wtf/cocoa/FileSystemCocoa.mm: 2021-05-27 Said Abou-Hallawa Values of keySplines control points must all be in the range 0 to 1 https://bugs.webkit.org/show_bug.cgi?id=226336 Reviewed by Sam Weinig. * wtf/MathExtras.h: (isInRange): There are a least couple of implementations of this function in WebCore. The next step is to remove the redundant code in WebCore and use this one. 2021-05-27 Robin Morisset AirAllocateStackByGraphColoring should use the optimized interference graphs from AirAllocateRegistersByGraphColoring https://bugs.webkit.org/show_bug.cgi?id=226258 Reviewed by Phil Pizlo. I moved the interference graphs datastructures from AirAllocateRegistersByGraphColoring to their own wtf/InterferenceGraph.h file. There are three of them: - SmallInterferenceGraph, best for n < 400 - LargeInterferenceGraph, for n < 2**16 - HugeInterferenceGraph, for n up to 2**32 I also added "Iterable" versions of them, that have an operator[] method whose result you can iterate on to get all the indices which interfere with a given index. SmallIterableInterferenceGraph is the same as the non-iterable version, but the Large and Huge versions are a bit slower than their counterparts and use 2x memory. All of these were tested by running JetStream2 with the TEST_OPTIMIZED_INTERFERENCE_GRAPH set to 1. This flag makes the optimized datastructures run in parallel with a reference implementation, and their results are checked for equality on every method call. There is one small difference allowed: iteration is not guaranteed to go through elements in the same order. I also added a clear() method to LikelyDenseUnsignedIntegerSet, and added the NotNull flag to its various uses of placement new. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/HashSet.h: (WTF::W>::memoryUse const): * wtf/InterferenceGraph.h: Added. (WTF::InterferenceBitVector::contains): (WTF::InterferenceBitVector::addAndReturnIsNewEntry): (WTF::InterferenceBitVector::add): (WTF::InterferenceBitVector::clear): (WTF::InterferenceBitVector::mayClear): (WTF::InterferenceBitVector::setMaxIndex): (WTF::InterferenceBitVector::forEach): (WTF::InterferenceBitVector::size const): (WTF::InterferenceBitVector::memoryUse const): (WTF::InterferenceBitVector::dumpMemoryUseInKB const): (WTF::InterferenceBitVector::Iterable::iterator::operator++): (WTF::InterferenceBitVector::Iterable::iterator::operator* const): (WTF::InterferenceBitVector::Iterable::iterator::operator== const): (WTF::InterferenceBitVector::Iterable::iterator::operator!= const): (WTF::InterferenceBitVector::Iterable::begin const): (WTF::InterferenceBitVector::Iterable::end const): (WTF::InterferenceBitVector::operator[] const): (WTF::InterferenceBitVector::index const): (WTF::InterferenceVector::contains): (WTF::InterferenceVector::addAndReturnIsNewEntry): (WTF::InterferenceVector::add): (WTF::InterferenceVector::clear): (WTF::InterferenceVector::mayClear): (WTF::InterferenceVector::setMaxIndex): (WTF::InterferenceVector::forEach): (WTF::InterferenceVector::size const): (WTF::InterferenceVector::memoryUse const): (WTF::InterferenceVector::dumpMemoryUseInKB const): (WTF::InterferenceVector::Iterable::begin const): (WTF::InterferenceVector::Iterable::end const): (WTF::InterferenceVector::operator[] const): (WTF::UndirectedEdgesDuplicatingAdapter::contains): (WTF::UndirectedEdgesDuplicatingAdapter::addAndReturnIsNewEntry): (WTF::UndirectedEdgesDuplicatingAdapter::add): (WTF::UndirectedEdgesDuplicatingAdapter::clear): (WTF::UndirectedEdgesDuplicatingAdapter::mayClear): (WTF::UndirectedEdgesDuplicatingAdapter::setMaxIndex): (WTF::UndirectedEdgesDuplicatingAdapter::forEach): (WTF::UndirectedEdgesDuplicatingAdapter::size const): (WTF::UndirectedEdgesDuplicatingAdapter::memoryUse const): (WTF::UndirectedEdgesDuplicatingAdapter::dumpMemoryUseInKB const): (WTF::UndirectedEdgesDuplicatingAdapter::operator[] const): (WTF::UndirectedEdgesDedupAdapter::contains): (WTF::UndirectedEdgesDedupAdapter::addAndReturnIsNewEntry): (WTF::UndirectedEdgesDedupAdapter::add): (WTF::UndirectedEdgesDedupAdapter::clear): (WTF::UndirectedEdgesDedupAdapter::mayClear): (WTF::UndirectedEdgesDedupAdapter::setMaxIndex): (WTF::UndirectedEdgesDedupAdapter::forEach): (WTF::UndirectedEdgesDedupAdapter::size const): (WTF::UndirectedEdgesDedupAdapter::memoryUse const): (WTF::UndirectedEdgesDedupAdapter::dumpMemoryUseInKB const): (WTF::InterferenceHashSet::contains): (WTF::InterferenceHashSet::addAndReturnIsNewEntry): (WTF::InterferenceHashSet::add): (WTF::InterferenceHashSet::clear): (WTF::InterferenceHashSet::setMaxIndex): (WTF::InterferenceHashSet::forEach): (WTF::InterferenceHashSet::size const): (WTF::InterferenceHashSet::memoryUse const): (WTF::InterferenceHashSet::dumpMemoryUseInKB const): (WTF::InstrumentedInterferenceGraph::contains): (WTF::InstrumentedInterferenceGraph::addAndReturnIsNewEntry): (WTF::InstrumentedInterferenceGraph::add): (WTF::InstrumentedInterferenceGraph::clear): (WTF::InstrumentedInterferenceGraph::mayClear): (WTF::InstrumentedInterferenceGraph::setMaxIndex): (WTF::InstrumentedInterferenceGraph::forEach): (WTF::InstrumentedInterferenceGraph::size const): (WTF::InstrumentedInterferenceGraph::memoryUse const): (WTF::InstrumentedInterferenceGraph::dumpMemoryUseInKB const): (WTF::InstrumentedIterableInterferenceGraph::Iterable::Iterable): (WTF::InstrumentedIterableInterferenceGraph::Iterable::begin const): (WTF::InstrumentedIterableInterferenceGraph::Iterable::end const): (WTF::InstrumentedIterableInterferenceGraph::operator[] const): * wtf/LikelyDenseUnsignedIntegerSet.h: (WTF::LikelyDenseUnsignedIntegerSet::LikelyDenseUnsignedIntegerSet): (WTF::LikelyDenseUnsignedIntegerSet::clear): (WTF::LikelyDenseUnsignedIntegerSet::add): (WTF::LikelyDenseUnsignedIntegerSet::estimateHashSetSize): (WTF::LikelyDenseUnsignedIntegerSet::transitionToHashSet): (WTF::LikelyDenseUnsignedIntegerSet::transitionToBitVector): 2021-05-27 Darin Adler Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. * : Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. 2021-05-27 Sihui Liu Abandon pending tasks on background thread when WebIDBServer is closed https://bugs.webkit.org/show_bug.cgi?id=226295 Reviewed by Chris Dumez. Make the wait end with either a new message or queue being killed. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue::waitForMessage): * wtf/CrossThreadTask.h: (WTF::CrossThreadTask::operator bool const): * wtf/CrossThreadTaskHandler.cpp: (WTF::CrossThreadTaskHandler::taskRunLoop): 2021-05-27 Don Olmstead [CMake] Add check for timingsafe_bcmp https://bugs.webkit.org/show_bug.cgi?id=226347 Reviewed by Chris Dumez. Use HAVE(TIMINGSAFE_BCMP) in CryptographicUtilities code. Set its value in PlatformHave for platforms not using CMake. * wtf/CryptographicUtilities.cpp: * wtf/CryptographicUtilities.h: * wtf/PlatformHave.h: 2021-05-27 Mikhail R. Gadelha Increase NumberToStringBuffer to account for negative number https://bugs.webkit.org/show_bug.cgi?id=226014 Reviewed by Robin Morisset. In r250389, NumberToStringBuffer length was increased from 96 to 123 because: <21 digits> + decimal point + <100 digits> + null char = 123. however, a = -100000000000000000000 a.toFixed(100) is a valid conversion and it is 124 chars long, because of the "-" sign. So this patch increases the length of NumberToStringBuffer to 124 and adds new test cases. Reviewed by Ryosuke Niwa. * wtf/dtoa.h: 2021-05-27 Alex Christensen Revert r277344 https://bugs.webkit.org/show_bug.cgi?id=225602 * wtf/PlatformHave.h: 2021-05-27 Devin Rousso Use `NSLocale` SPI for comparing language identifiers instead of string comparison https://bugs.webkit.org/show_bug.cgi?id=226252 Reviewed by Wenson Hsieh. The existing `indexOfBestMatchingLanguageInList` logic uses (sub)string comparison of BCP47 language tags (e.g. looking for a `'-'` and comparing the substring before and after in the input language and each item in the language list). While this does work for some languages, it's really not the correct way to compare BCP47 language tags. Additionally, it basically ignores the text after the first `'-'`, unless there's an exact match with the input language. This leads to `"zh-CN"` and `"zh-HK"` being considered a (not exact) match, which isn't ideal. * wtf/Language.cpp: * wtf/cocoa/LanguageCocoa.mm: (WTF::indexOfBestMatchingLanguageInList): Added. * wtf/spi/cocoa/NSLocaleSPI.h: 2021-05-26 Cameron McCormack Prevent sbix glyphs from being rendered in the GPU process https://bugs.webkit.org/show_bug.cgi?id=226159 Reviewed by Darin Adler. * wtf/PlatformHave.h: Add HAVE_CORE_TEXT_SBIX_IMAGE_SIZE_FUNCTIONS. 2021-05-26 Chris Dumez Leverage the new Vector(const T*, size_t) constructor https://bugs.webkit.org/show_bug.cgi?id=226304 Reviewed by Darin Adler. Leverage the new Vector(const T*, size_t) constructor in existing code. * wtf/text/WTFString.cpp: (asciiDebug): 2021-05-26 Chris Dumez Use timingsafe_bcmp() in WTF::constantTimeMemcmp() when available https://bugs.webkit.org/show_bug.cgi?id=226294 Reviewed by Darin Adler. Follow-up to r278140 to address post-landing feedback. * wtf/CryptographicUtilities.cpp: (WTF::constantTimeMemcmp): * wtf/CryptographicUtilities.h: (WTF::constantTimeMemcmp): 2021-05-26 Chris Dumez Use timingsafe_bcmp() in WTF::constantTimeMemcmp() when available https://bugs.webkit.org/show_bug.cgi?id=226294 Reviewed by Alex Christensen. Use timingsafe_bcmp() in WTF::constantTimeMemcmp() when available (iOS, macOS, FreeBSD, OpenBSD), instead of our own custom implementation. * wtf/CryptographicUtilities.cpp: (WTF::constantTimeMemcmp): 2021-05-26 Chris Dumez [Hardening] Have the Ref<> destructor null out its pointer https://bugs.webkit.org/show_bug.cgi?id=226293 Reviewed by Geoffrey Garen. * wtf/Ref.h: (WTF::Ref::~Ref): 2021-05-26 Alex Christensen URL path setter messes up UTF-8 encoding after ? https://bugs.webkit.org/show_bug.cgi?id=226136 Reviewed by Chris Dumez. escapePathWithoutCopying needs to tell percentEncodeCharacters to percent encode all non-ASCII characters in the output of UTF-8 encoding in addition to ? and #. Otherwise, we take the output of UTF-8 encoding and append each code unit to the input of URL parsing as if it were Latin-1. This matches Chrome, Firefox, and reason. Covered by a newly passing WPT test. Other callers of percentEncodeCharacters use functions that already encode all non-ASCII characters. * wtf/URL.cpp: (WTF::escapePathWithoutCopying): 2021-05-26 Chris Dumez Stop using UncheckedLock in WTF::AutomaticThread https://bugs.webkit.org/show_bug.cgi?id=226255 Reviewed by Keith Miller. Stop using UncheckedLock in WTF::AutomaticThread as it is being phased out in favor of Lock, which supports Clang thread safety analysis. * wtf/AutomaticThread.cpp: (WTF::AutomaticThreadCondition::wait): (WTF::AutomaticThreadCondition::waitFor): (WTF::AutomaticThread::AutomaticThread): * wtf/AutomaticThread.h: * wtf/ParallelHelperPool.cpp: (WTF::ParallelHelperClient::~ParallelHelperClient): (WTF::ParallelHelperClient::finish): (WTF::ParallelHelperClient::finishWithLock): (WTF::ParallelHelperPool::ParallelHelperPool): * wtf/ParallelHelperPool.h: (WTF::ParallelHelperPool::numberOfThreads const): * wtf/WorkerPool.cpp: (WTF::WorkerPool::WorkerPool): * wtf/WorkerPool.h: 2021-05-25 Chris Dumez Use UncheckedLock less in JavaScriptCore https://bugs.webkit.org/show_bug.cgi?id=226212 Reviewed by Saam Barati. Add support for unlockEarly() to Locker specialization, for consistency with the generic Locker. * wtf/Lock.h: 2021-05-25 Devin Rousso [Modern Media Controls] REGRESSION(r254389) media controls needs the full list of language preferences for ordering tracks https://bugs.webkit.org/show_bug.cgi?id=226038 Reviewed by Myles C. Maxfield and Eric Carlson. Media controls need access to the full list of language preferences in order to properly sort/order the list of tracks in the controls UI. For example, if a `