haikuwebkit/Source/WTF/wtf/NeverDestroyed.h

202 lines
6.8 KiB
C
Raw Permalink Normal View History

/*
[iOS] WebKit should consult the navigation response policy delegate before previewing a QuickLook document https://bugs.webkit.org/show_bug.cgi?id=196433 <rdar://problem/49293305> Reviewed by Tim Horton. Source/WebCore: When ResourceLoader would encounter a response with a MIME type that QuickLook supports, the response would be implicitly allowed and a QuickLook preview would be generated. After generating, the client's navigation response policy delegate would be notified of the preview response, but not the underlying response. Notably, the preview response has a URL scheme of "x-apple-ql-id", does not include any underlying HTTP headers, and usually has a MIME type of "text/html" or "application/pdf" rather than the underlying response MIME type. To allow clients to make better navigation response policy decisions, this patch changes the above behavior for WKWebView clients that have linked against a version of WebKit that includes this change. Rather than notifying the client's navigation response policy delegate of the preview response, we notify the client of the underlying response. Only if the client responds with a policy of "allow" will the QuickLook preview response be loaded (without another call to the navigation response policy delegate). Non-WKWebView clients and clients that have linked against a version of WebKit that does not include this change will retain the original behavior. Covered by existing layout tests and new and existing API tests. * WebCore.xcodeproj/project.pbxproj: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::shouldCreatePreviewLoaderForResponse const): (WebCore::SubresourceLoader::didReceiveResponse): * loader/ios/PreviewLoader.h: * loader/ios/PreviewLoader.mm: (-[WebPreviewLoader initWithResourceLoader:resourceResponse:]): (-[WebPreviewLoader _loadPreviewIfNeeded]): (-[WebPreviewLoader connection:didReceiveData:lengthReceived:]): (-[WebPreviewLoader connectionDidFinishLoading:]): (-[WebPreviewLoader connection:didFailWithError:]): (WebCore::PreviewLoader::create): (WebCore::PreviewLoader::didReceiveResponse): (-[WebPreviewLoader _sendDidReceiveResponseIfNecessary]): Deleted. (WebCore::PreviewLoader::shouldCreateForMIMEType): Deleted. * page/Settings.yaml: * platform/MIMETypeRegistry.cpp: (WebCore::MIMETypeRegistry::canShowMIMEType): * platform/network/ios/PreviewConverter.h: * platform/network/ios/PreviewConverter.mm: (WebCore::PreviewConverter::supportsMIMEType): Source/WebKit: Added WKWebViewConfiguration SPI for setting the QuickLook navigation response policy decision behavior. The configuration setting defaults to YES for clients linked on or after this WebKit change and NO otherwise. * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions): * Shared/WebPreferences.yaml: * Shared/ios/QuickLookDocumentData.cpp: (WebKit::QuickLookDocumentData::isEmpty const): * Shared/ios/QuickLookDocumentData.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _initializeWithConfiguration:]): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (defaultShouldDecidePolicyBeforeLoadingQuickLookPreview): (-[WKWebViewConfiguration init]): (-[WKWebViewConfiguration encodeWithCoder:]): (-[WKWebViewConfiguration initWithCoder:]): (-[WKWebViewConfiguration copyWithZone:]): (-[WKWebViewConfiguration _shouldDecidePolicyBeforeLoadingQuickLookPreview]): (-[WKWebViewConfiguration _setShouldDecidePolicyBeforeLoadingQuickLookPreview:]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: * UIProcess/Cocoa/VersionChecks.h: * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp: (WebKit::WebPreviewLoaderClient::didReceiveDataArray): Source/WTF: * wtf/NeverDestroyed.h: (WTF::NeverDestroyed::operator->): (WTF::NeverDestroyed::operator-> const): Tools: Enhanced API test coverage to include all navigation response policy decisions in both linked-before and linked-on-or-after modes. Also added new expectations for all tests. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebCore/ios/PreviewConverter.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/ios/PreviewLoader.cpp. (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm: (readFile): (-[QuickLookDelegate initWithExpectedFileURL:responsePolicy:]): (-[QuickLookDelegate initWithExpectedFileURL:previewMIMEType:responsePolicy:]): (-[QuickLookDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[QuickLookDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): (-[QuickLookDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): (-[QuickLookDelegate webView:didFailProvisionalNavigation:withError:]): (-[QuickLookDelegate _webViewWebProcessDidCrash:]): (-[QuickLookDelegate _downloadDidStart:]): (-[QuickLookDelegate _download:didReceiveResponse:]): (-[QuickLookDelegate _download:didReceiveData:]): (-[QuickLookDelegate _download:decideDestinationWithSuggestedFilename:completionHandler:]): (-[QuickLookDelegate _downloadDidFinish:]): (-[QuickLookDelegate _download:didFailWithError:]): (-[QuickLookDelegate _downloadDidCancel:]): (-[QuickLookDelegate verifyDownload]): (runTest): (runTestDecideBeforeLoading): (runTestDecideAfterLoading): (TEST): (-[QuickLookAsyncDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[QuickLookPasswordDelegate _webViewDidRequestPasswordForQuickLookDocument:]): (-[QuickLookFrameLoadDelegate webView:didFinishLoadForFrame:]): (-[QuickLookNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): Deleted. (-[QuickLookNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): Deleted. (-[QuickLookNavigationDelegate webView:didFinishNavigation:]): Deleted. (-[QuickLookAsyncNavigationDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): Deleted. (-[QuickLookAsyncNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): Deleted. (-[QuickLookAsyncNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): Deleted. (-[QuickLookAsyncNavigationDelegate webView:didFinishNavigation:]): Deleted. (-[QuickLookDecidePolicyDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): Deleted. (-[QuickLookDecidePolicyDelegate webView:didFailProvisionalNavigation:withError:]): Deleted. (-[QuickLookDecidePolicyDelegate _webViewWebProcessDidCrash:]): Deleted. (-[QuickLookPasswordNavigationDelegate _webViewDidRequestPasswordForQuickLookDocument:]): Deleted. Canonical link: https://commits.webkit.org/210698@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-31 17:37:45 +00:00
* Copyright (C) 2013-2019 Apple Inc. All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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.
*/
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
#pragma once
#include <type_traits>
#include <utility>
#include <wtf/ForbidHeapAllocation.h>
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
#include <wtf/MainThread.h>
#include <wtf/RefCounted.h>
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
// NeverDestroyed is a smart-pointer-like class that ensures that the destructor
// for the given object is never called, but doesn't use the heap to allocate it.
// It's useful for static local variables, and can be used like so:
//
// MySharedGlobal& mySharedGlobal()
// {
// static NeverDestroyed<MySharedGlobal> myGlobal("Hello", 42);
// return myGlobal;
// }
namespace WTF {
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
struct AnyThreadsAccessTraits {
static void assertAccess()
{
}
};
struct MainThreadAccessTraits {
static void assertAccess()
{
ASSERT(isMainThread());
}
};
template<typename T, typename AccessTraits> class NeverDestroyed {
WTF_MAKE_NONCOPYABLE(NeverDestroyed);
WTF_FORBID_HEAP_ALLOCATION;
public:
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
template<typename... Args> NeverDestroyed(Args&&... args)
{
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
AccessTraits::assertAccess();
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
MaybeRelax<T>(new (storagePointer()) T(std::forward<Args>(args)...));
}
NeverDestroyed(NeverDestroyed&& other)
{
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
AccessTraits::assertAccess();
Move-constructing NeverDestroyed should move construct underlying object instead of copy constructing it https://bugs.webkit.org/show_bug.cgi?id=187971 Reviewed by Saam Barati. Source/WTF: Fixes an issue where move constructing a NeverDestroyed<T> would always copy construct T into the destination storage buffer regardless of whether T is move constructable. For example: { static NeverDestroyed<T> x; static NeverDestroyed<T> y { WTFMove(x) }; // currently makes a copy of x's T even if T is move constructable } Currently the NeverDestroyed<T> instantiates T into the destination storage buffer by WTFMove()ing the NeverDestroyed<T> into it, implicitly converting it to const T& by way of const T& conversion operator. As a result the compiler picks the copy constructor for T to invoke instead of evaluating whether T can be move constructed. Instead we should explicitly WTFMove() the underlying T so that the compiler can choose to either move-construct T or copy construct it. A side benefit of this change it is now possible to invoke makeNeverDestroyed() with the result of a function that returns a move-only type (e.g. RenderStyle): static auto sharedStyle = makeNeverDestroyed([] { auto style = RenderStyle::create(); ... return style; }()); * wtf/NeverDestroyed.h: (WTF::NeverDestroyed::NeverDestroyed): Tools: Add unit tests to cover move constructing a NeverDestroyed with a non-const and const data type as well as invoking makeNeverDestroyed() with the result of a function that returns a move-only data type. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MoveOnlyLifecycleLogger.cpp: Added. (TestWebKitAPI::MoveOnlyLifecycleLogger::MoveOnlyLifecycleLogger): (TestWebKitAPI::MoveOnlyLifecycleLogger::~MoveOnlyLifecycleLogger): (TestWebKitAPI::MoveOnlyLifecycleLogger::operator=): (TestWebKitAPI::MoveOnlyLifecycleLogger::setName): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/MoveOnlyLifecycleLogger.h: Added. * TestWebKitAPI/Tests/WTF/NeverDestroyed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/203153@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234179 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-07-24 23:29:50 +00:00
MaybeRelax<T>(new (storagePointer()) T(WTFMove(*other.storagePointer())));
}
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
operator T&() { return *storagePointer(); }
T& get() { return *storagePointer(); }
[iOS] WebKit should consult the navigation response policy delegate before previewing a QuickLook document https://bugs.webkit.org/show_bug.cgi?id=196433 <rdar://problem/49293305> Reviewed by Tim Horton. Source/WebCore: When ResourceLoader would encounter a response with a MIME type that QuickLook supports, the response would be implicitly allowed and a QuickLook preview would be generated. After generating, the client's navigation response policy delegate would be notified of the preview response, but not the underlying response. Notably, the preview response has a URL scheme of "x-apple-ql-id", does not include any underlying HTTP headers, and usually has a MIME type of "text/html" or "application/pdf" rather than the underlying response MIME type. To allow clients to make better navigation response policy decisions, this patch changes the above behavior for WKWebView clients that have linked against a version of WebKit that includes this change. Rather than notifying the client's navigation response policy delegate of the preview response, we notify the client of the underlying response. Only if the client responds with a policy of "allow" will the QuickLook preview response be loaded (without another call to the navigation response policy delegate). Non-WKWebView clients and clients that have linked against a version of WebKit that does not include this change will retain the original behavior. Covered by existing layout tests and new and existing API tests. * WebCore.xcodeproj/project.pbxproj: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::shouldCreatePreviewLoaderForResponse const): (WebCore::SubresourceLoader::didReceiveResponse): * loader/ios/PreviewLoader.h: * loader/ios/PreviewLoader.mm: (-[WebPreviewLoader initWithResourceLoader:resourceResponse:]): (-[WebPreviewLoader _loadPreviewIfNeeded]): (-[WebPreviewLoader connection:didReceiveData:lengthReceived:]): (-[WebPreviewLoader connectionDidFinishLoading:]): (-[WebPreviewLoader connection:didFailWithError:]): (WebCore::PreviewLoader::create): (WebCore::PreviewLoader::didReceiveResponse): (-[WebPreviewLoader _sendDidReceiveResponseIfNecessary]): Deleted. (WebCore::PreviewLoader::shouldCreateForMIMEType): Deleted. * page/Settings.yaml: * platform/MIMETypeRegistry.cpp: (WebCore::MIMETypeRegistry::canShowMIMEType): * platform/network/ios/PreviewConverter.h: * platform/network/ios/PreviewConverter.mm: (WebCore::PreviewConverter::supportsMIMEType): Source/WebKit: Added WKWebViewConfiguration SPI for setting the QuickLook navigation response policy decision behavior. The configuration setting defaults to YES for clients linked on or after this WebKit change and NO otherwise. * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions): * Shared/WebPreferences.yaml: * Shared/ios/QuickLookDocumentData.cpp: (WebKit::QuickLookDocumentData::isEmpty const): * Shared/ios/QuickLookDocumentData.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _initializeWithConfiguration:]): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (defaultShouldDecidePolicyBeforeLoadingQuickLookPreview): (-[WKWebViewConfiguration init]): (-[WKWebViewConfiguration encodeWithCoder:]): (-[WKWebViewConfiguration initWithCoder:]): (-[WKWebViewConfiguration copyWithZone:]): (-[WKWebViewConfiguration _shouldDecidePolicyBeforeLoadingQuickLookPreview]): (-[WKWebViewConfiguration _setShouldDecidePolicyBeforeLoadingQuickLookPreview:]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: * UIProcess/Cocoa/VersionChecks.h: * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp: (WebKit::WebPreviewLoaderClient::didReceiveDataArray): Source/WTF: * wtf/NeverDestroyed.h: (WTF::NeverDestroyed::operator->): (WTF::NeverDestroyed::operator-> const): Tools: Enhanced API test coverage to include all navigation response policy decisions in both linked-before and linked-on-or-after modes. Also added new expectations for all tests. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebCore/ios/PreviewConverter.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/ios/PreviewLoader.cpp. (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm: (readFile): (-[QuickLookDelegate initWithExpectedFileURL:responsePolicy:]): (-[QuickLookDelegate initWithExpectedFileURL:previewMIMEType:responsePolicy:]): (-[QuickLookDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[QuickLookDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): (-[QuickLookDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): (-[QuickLookDelegate webView:didFailProvisionalNavigation:withError:]): (-[QuickLookDelegate _webViewWebProcessDidCrash:]): (-[QuickLookDelegate _downloadDidStart:]): (-[QuickLookDelegate _download:didReceiveResponse:]): (-[QuickLookDelegate _download:didReceiveData:]): (-[QuickLookDelegate _download:decideDestinationWithSuggestedFilename:completionHandler:]): (-[QuickLookDelegate _downloadDidFinish:]): (-[QuickLookDelegate _download:didFailWithError:]): (-[QuickLookDelegate _downloadDidCancel:]): (-[QuickLookDelegate verifyDownload]): (runTest): (runTestDecideBeforeLoading): (runTestDecideAfterLoading): (TEST): (-[QuickLookAsyncDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[QuickLookPasswordDelegate _webViewDidRequestPasswordForQuickLookDocument:]): (-[QuickLookFrameLoadDelegate webView:didFinishLoadForFrame:]): (-[QuickLookNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): Deleted. (-[QuickLookNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): Deleted. (-[QuickLookNavigationDelegate webView:didFinishNavigation:]): Deleted. (-[QuickLookAsyncNavigationDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): Deleted. (-[QuickLookAsyncNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): Deleted. (-[QuickLookAsyncNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): Deleted. (-[QuickLookAsyncNavigationDelegate webView:didFinishNavigation:]): Deleted. (-[QuickLookDecidePolicyDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): Deleted. (-[QuickLookDecidePolicyDelegate webView:didFailProvisionalNavigation:withError:]): Deleted. (-[QuickLookDecidePolicyDelegate _webViewWebProcessDidCrash:]): Deleted. (-[QuickLookPasswordNavigationDelegate _webViewDidRequestPasswordForQuickLookDocument:]): Deleted. Canonical link: https://commits.webkit.org/210698@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-31 17:37:45 +00:00
T* operator->() { return storagePointer(); }
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
operator const T&() const { return *storagePointer(); }
const T& get() const { return *storagePointer(); }
[iOS] WebKit should consult the navigation response policy delegate before previewing a QuickLook document https://bugs.webkit.org/show_bug.cgi?id=196433 <rdar://problem/49293305> Reviewed by Tim Horton. Source/WebCore: When ResourceLoader would encounter a response with a MIME type that QuickLook supports, the response would be implicitly allowed and a QuickLook preview would be generated. After generating, the client's navigation response policy delegate would be notified of the preview response, but not the underlying response. Notably, the preview response has a URL scheme of "x-apple-ql-id", does not include any underlying HTTP headers, and usually has a MIME type of "text/html" or "application/pdf" rather than the underlying response MIME type. To allow clients to make better navigation response policy decisions, this patch changes the above behavior for WKWebView clients that have linked against a version of WebKit that includes this change. Rather than notifying the client's navigation response policy delegate of the preview response, we notify the client of the underlying response. Only if the client responds with a policy of "allow" will the QuickLook preview response be loaded (without another call to the navigation response policy delegate). Non-WKWebView clients and clients that have linked against a version of WebKit that does not include this change will retain the original behavior. Covered by existing layout tests and new and existing API tests. * WebCore.xcodeproj/project.pbxproj: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::shouldCreatePreviewLoaderForResponse const): (WebCore::SubresourceLoader::didReceiveResponse): * loader/ios/PreviewLoader.h: * loader/ios/PreviewLoader.mm: (-[WebPreviewLoader initWithResourceLoader:resourceResponse:]): (-[WebPreviewLoader _loadPreviewIfNeeded]): (-[WebPreviewLoader connection:didReceiveData:lengthReceived:]): (-[WebPreviewLoader connectionDidFinishLoading:]): (-[WebPreviewLoader connection:didFailWithError:]): (WebCore::PreviewLoader::create): (WebCore::PreviewLoader::didReceiveResponse): (-[WebPreviewLoader _sendDidReceiveResponseIfNecessary]): Deleted. (WebCore::PreviewLoader::shouldCreateForMIMEType): Deleted. * page/Settings.yaml: * platform/MIMETypeRegistry.cpp: (WebCore::MIMETypeRegistry::canShowMIMEType): * platform/network/ios/PreviewConverter.h: * platform/network/ios/PreviewConverter.mm: (WebCore::PreviewConverter::supportsMIMEType): Source/WebKit: Added WKWebViewConfiguration SPI for setting the QuickLook navigation response policy decision behavior. The configuration setting defaults to YES for clients linked on or after this WebKit change and NO otherwise. * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions): * Shared/WebPreferences.yaml: * Shared/ios/QuickLookDocumentData.cpp: (WebKit::QuickLookDocumentData::isEmpty const): * Shared/ios/QuickLookDocumentData.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _initializeWithConfiguration:]): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (defaultShouldDecidePolicyBeforeLoadingQuickLookPreview): (-[WKWebViewConfiguration init]): (-[WKWebViewConfiguration encodeWithCoder:]): (-[WKWebViewConfiguration initWithCoder:]): (-[WKWebViewConfiguration copyWithZone:]): (-[WKWebViewConfiguration _shouldDecidePolicyBeforeLoadingQuickLookPreview]): (-[WKWebViewConfiguration _setShouldDecidePolicyBeforeLoadingQuickLookPreview:]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: * UIProcess/Cocoa/VersionChecks.h: * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp: (WebKit::WebPreviewLoaderClient::didReceiveDataArray): Source/WTF: * wtf/NeverDestroyed.h: (WTF::NeverDestroyed::operator->): (WTF::NeverDestroyed::operator-> const): Tools: Enhanced API test coverage to include all navigation response policy decisions in both linked-before and linked-on-or-after modes. Also added new expectations for all tests. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebCore/ios/PreviewConverter.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/ios/PreviewLoader.cpp. (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm: (readFile): (-[QuickLookDelegate initWithExpectedFileURL:responsePolicy:]): (-[QuickLookDelegate initWithExpectedFileURL:previewMIMEType:responsePolicy:]): (-[QuickLookDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[QuickLookDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): (-[QuickLookDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): (-[QuickLookDelegate webView:didFailProvisionalNavigation:withError:]): (-[QuickLookDelegate _webViewWebProcessDidCrash:]): (-[QuickLookDelegate _downloadDidStart:]): (-[QuickLookDelegate _download:didReceiveResponse:]): (-[QuickLookDelegate _download:didReceiveData:]): (-[QuickLookDelegate _download:decideDestinationWithSuggestedFilename:completionHandler:]): (-[QuickLookDelegate _downloadDidFinish:]): (-[QuickLookDelegate _download:didFailWithError:]): (-[QuickLookDelegate _downloadDidCancel:]): (-[QuickLookDelegate verifyDownload]): (runTest): (runTestDecideBeforeLoading): (runTestDecideAfterLoading): (TEST): (-[QuickLookAsyncDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[QuickLookPasswordDelegate _webViewDidRequestPasswordForQuickLookDocument:]): (-[QuickLookFrameLoadDelegate webView:didFinishLoadForFrame:]): (-[QuickLookNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): Deleted. (-[QuickLookNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): Deleted. (-[QuickLookNavigationDelegate webView:didFinishNavigation:]): Deleted. (-[QuickLookAsyncNavigationDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): Deleted. (-[QuickLookAsyncNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]): Deleted. (-[QuickLookAsyncNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]): Deleted. (-[QuickLookAsyncNavigationDelegate webView:didFinishNavigation:]): Deleted. (-[QuickLookDecidePolicyDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): Deleted. (-[QuickLookDecidePolicyDelegate webView:didFailProvisionalNavigation:withError:]): Deleted. (-[QuickLookDecidePolicyDelegate _webViewWebProcessDidCrash:]): Deleted. (-[QuickLookPasswordNavigationDelegate _webViewDidRequestPasswordForQuickLookDocument:]): Deleted. Canonical link: https://commits.webkit.org/210698@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-31 17:37:45 +00:00
const T* operator->() const { return storagePointer(); }
private:
using PointerType = typename std::remove_const<T>::type*;
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
PointerType storagePointer() const
{
AccessTraits::assertAccess();
return const_cast<PointerType>(reinterpret_cast<const T*>(&m_storage));
}
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
template<typename PtrType, bool ShouldRelax = std::is_base_of<RefCountedBase, PtrType>::value> struct MaybeRelax {
explicit MaybeRelax(PtrType*) { }
};
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
template<typename PtrType> struct MaybeRelax<PtrType, true> {
explicit MaybeRelax(PtrType* ptr) { ptr->relaxAdoptionRequirement(); }
};
// FIXME: Investigate whether we should allocate a hunk of virtual memory
// and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_storage;
};
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
template<typename T, typename AccessTraits = AnyThreadsAccessTraits> NeverDestroyed<T, AccessTraits> makeNeverDestroyed(T&&);
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
// FIXME: It's messy to have to repeat the whole class just to make this "lazy" version.
// Should revisit clients to see if we really need this, and perhaps use templates to
// share more of the code with the main NeverDestroyed above.
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
template<typename T, typename AccessTraits> class LazyNeverDestroyed {
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
WTF_MAKE_NONCOPYABLE(LazyNeverDestroyed);
WTF_FORBID_HEAP_ALLOCATION;
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
public:
LazyNeverDestroyed() = default;
template<typename... Args>
void construct(Args&&... args)
{
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
AccessTraits::assertAccess();
AtomString::init should temporarily disable checks via `isMainThread` due to WebThread's inconsistent state https://bugs.webkit.org/show_bug.cgi?id=211754 Reviewed by Dean Jackson. When starting WebThread via StartWebThread function, we have special period between the prologue of StartWebThread and spawning WebThread actually. In this period, `isMainThread()` returns false even if this is called on the main thread since WebThread is now enabled and we are not taking a WebThread lock. This causes assertion hits in MainThreadLazyNeverDestroyed initialization only in WebThread platforms. This patch takes conservative approach to fix this assertion hits: just bypass these assertions since this should not be fired. We bypass assertions by using constructWithoutAccessCheck, which intentionally skips `isMainThread()` check for construction. In non WebThread environment, we do not lose the assertion coverage since we already have ASSERT(isUIThread()). And ASSERT(isUIThread()) ensures that this is called in system main thread in WebThread platforms. Unfortunately, we have no mechanism to test this effectively. WK1 LayoutTests runner cannot show assertions since WK1 runners already initialize necessary things somewhere before calling AtomString::init() in StartWebThread. This is the same in TestWebKitAPI. For now, I manually tested that assertion does not fire. * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::constructWithoutAccessCheck): (WTF::LazyNeverDestroyed::storagePointerWithoutAccessCheck const): (WTF::LazyNeverDestroyed::storagePointer const): * wtf/text/AtomString.cpp: (WTF::AtomString::init): Canonical link: https://commits.webkit.org/224663@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 05:21:28 +00:00
constructWithoutAccessCheck(std::forward<Args>(args)...);
}
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
AtomString::init should temporarily disable checks via `isMainThread` due to WebThread's inconsistent state https://bugs.webkit.org/show_bug.cgi?id=211754 Reviewed by Dean Jackson. When starting WebThread via StartWebThread function, we have special period between the prologue of StartWebThread and spawning WebThread actually. In this period, `isMainThread()` returns false even if this is called on the main thread since WebThread is now enabled and we are not taking a WebThread lock. This causes assertion hits in MainThreadLazyNeverDestroyed initialization only in WebThread platforms. This patch takes conservative approach to fix this assertion hits: just bypass these assertions since this should not be fired. We bypass assertions by using constructWithoutAccessCheck, which intentionally skips `isMainThread()` check for construction. In non WebThread environment, we do not lose the assertion coverage since we already have ASSERT(isUIThread()). And ASSERT(isUIThread()) ensures that this is called in system main thread in WebThread platforms. Unfortunately, we have no mechanism to test this effectively. WK1 LayoutTests runner cannot show assertions since WK1 runners already initialize necessary things somewhere before calling AtomString::init() in StartWebThread. This is the same in TestWebKitAPI. For now, I manually tested that assertion does not fire. * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::constructWithoutAccessCheck): (WTF::LazyNeverDestroyed::storagePointerWithoutAccessCheck const): (WTF::LazyNeverDestroyed::storagePointer const): * wtf/text/AtomString.cpp: (WTF::AtomString::init): Canonical link: https://commits.webkit.org/224663@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 05:21:28 +00:00
template<typename... Args>
void constructWithoutAccessCheck(Args&&... args)
{
ASSERT(!m_isConstructed);
PerformanceTests: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * JetStream2/wasm/HashSet.cpp: * StitchMarker/wtf/Assertions.h: * StitchMarker/wtf/DateMath.cpp: (WTF::initializeDates): * StitchMarker/wtf/HashTable.h: * StitchMarker/wtf/Hasher.h: (WTF::StringHasher::addCharacters): * StitchMarker/wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): * StitchMarker/wtf/StackBounds.h: (WTF::StackBounds::checkConsistency const): * StitchMarker/wtf/ValueCheck.h: * StitchMarker/wtf/Vector.h: (WTF::minCapacity>::checkConsistency): * StitchMarker/wtf/text/AtomicStringImpl.cpp: * StitchMarker/wtf/text/AtomicStringImpl.h: * StitchMarker/wtf/text/StringCommon.h: (WTF::hasPrefixWithLettersIgnoringASCIICaseCommon): * StitchMarker/wtf/text/StringImpl.h: * StitchMarker/wtf/text/SymbolImpl.h: * StitchMarker/wtf/text/UniquedStringImpl.h: Source/JavaScriptCore: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * API/tests/testapi.c: * assembler/ARM64Assembler.h: (JSC::ARM64Assembler::replaceWithLoad): (JSC::ARM64Assembler::replaceWithAddressComputation): * assembler/AssemblerBuffer.h: (JSC::AssemblerBuffer::LocalWriter::LocalWriter): * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::copyCompactAndLinkCode): * assembler/ProbeStack.cpp: (JSC::Probe::Stack::Stack): * assembler/ProbeStack.h: * b3/B3FoldPathConstants.cpp: * b3/B3LowerToAir.cpp: * b3/B3MemoryValue.cpp: (JSC::B3::MemoryValue::MemoryValue): * b3/B3Opcode.cpp: * b3/B3Type.h: * b3/B3TypeMap.h: * b3/B3Width.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp: (JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration): (JSC::B3::Air::GenerateAndAllocateRegisters::generate): * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirArg.cpp: * b3/air/AirArg.h: * b3/air/AirCode.h: * b3/air/AirEmitShuffle.cpp: (JSC::B3::Air::emitShuffle): * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createExecutable): * bytecode/AccessCase.cpp: * bytecode/AccessCase.h: * bytecode/CallVariant.cpp: (JSC::variantListWithVariant): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex): * bytecode/CodeBlockHash.cpp: (JSC::CodeBlockHash::dump const): * bytecode/StructureStubInfo.cpp: * bytecode/StructureStubInfo.h: * bytecompiler/NodesCodegen.cpp: (JSC::FunctionCallResolveNode::emitBytecode): * bytecompiler/RegisterID.h: (JSC::RegisterID::RegisterID): (JSC::RegisterID::setIndex): * debugger/Debugger.cpp: (JSC::Debugger::removeBreakpoint): * debugger/DebuggerEvalEnabler.h: (JSC::DebuggerEvalEnabler::DebuggerEvalEnabler): (JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions): * dfg/DFGAbstractValue.cpp: * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::merge): (JSC::DFG::AbstractValue::checkConsistency const): (JSC::DFG::AbstractValue::assertIsRegistered const): * dfg/DFGArithMode.h: (JSC::DFG::doesOverflow): * dfg/DFGBasicBlock.cpp: (JSC::DFG::BasicBlock::BasicBlock): * dfg/DFGBasicBlock.h: (JSC::DFG::BasicBlock::didLink): * dfg/DFGCFAPhase.cpp: (JSC::DFG::CFAPhase::performBlockCFA): * dfg/DFGCommon.h: (JSC::DFG::validationEnabled): * dfg/DFGCommonData.cpp: (JSC::DFG::CommonData::finalizeCatchEntrypoints): * dfg/DFGDesiredWatchpoints.h: * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGEdge.h: (JSC::DFG::Edge::makeWord): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::finalizeOSREntrypoints): * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGSSAConversionPhase.cpp: (JSC::DFG::SSAConversionPhase::run): * dfg/DFGScoreBoard.h: (JSC::DFG::ScoreBoard::assertClear): * dfg/DFGSlowPathGenerator.h: (JSC::DFG::SlowPathGenerator::generate): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCurrentBlock): (JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse): (JSC::DFG::SpeculativeJIT::emitAllocateButterfly): (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): (JSC::DFG::SpeculativeJIT::compileMakeRope): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::fillSpeculateCell): * dfg/DFGStructureAbstractValue.cpp: * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::assertIsRegistered const): * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVirtualRegisterAllocationPhase.cpp: (JSC::DFG::VirtualRegisterAllocationPhase::run): * ftl/FTLLink.cpp: (JSC::FTL::link): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::callPreflight): (JSC::FTL::DFG::LowerDFGToB3::callCheck): (JSC::FTL::DFG::LowerDFGToB3::crash): * ftl/FTLOperations.cpp: (JSC::FTL::operationMaterializeObjectInOSR): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::assertNoUnswept): * heap/GCSegmentedArray.h: (JSC::GCArraySegment::GCArraySegment): * heap/GCSegmentedArrayInlines.h: (JSC::GCSegmentedArray<T>::clear): (JSC::GCSegmentedArray<T>::expand): (JSC::GCSegmentedArray<T>::validatePrevious): * heap/HandleSet.cpp: * heap/HandleSet.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/MarkedBlock.cpp: * heap/MarkedBlock.h: (JSC::MarkedBlock::assertValidCell const): (JSC::MarkedBlock::assertMarksNotStale): * heap/MarkedSpace.cpp: (JSC::MarkedSpace::beginMarking): (JSC::MarkedSpace::endMarking): (JSC::MarkedSpace::assertNoUnswept): * heap/PreciseAllocation.cpp: * heap/PreciseAllocation.h: (JSC::PreciseAllocation::assertValidCell const): * heap/SlotVisitor.cpp: (JSC::SlotVisitor::SlotVisitor): (JSC::SlotVisitor::appendJSCellOrAuxiliary): * heap/SlotVisitor.h: * inspector/InspectorProtocolTypes.h: (Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType): * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration): (CppProtocolTypesImplementationGenerator): (CppProtocolTypesImplementationGenerator._generate_assertion_for_enum): * inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result: * interpreter/FrameTracers.h: (JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer): * interpreter/Interpreter.cpp: (JSC::Interpreter::Interpreter): * interpreter/Interpreter.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::prepareCallOperation): * jit/BinarySwitch.cpp: (JSC::BinarySwitch::BinarySwitch): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupStubArgs): * jit/CallFrameShuffler.cpp: (JSC::CallFrameShuffler::emitDeltaCheck): (JSC::CallFrameShuffler::prepareAny): * jit/JIT.cpp: (JSC::JIT::assertStackPointerOffset): (JSC::JIT::compileWithoutLinking): * jit/JITOpcodes.cpp: (JSC::JIT::emitSlow_op_loop_hint): * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_from_scope): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_get_from_scope): * jit/Repatch.cpp: (JSC::linkPolymorphicCall): * jit/ThunkGenerators.cpp: (JSC::emitPointerValidation): * llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): * llint/LLIntOfflineAsmConfig.h: * parser/Lexer.cpp: * parser/Lexer.h: (JSC::isSafeBuiltinIdentifier): (JSC::Lexer<T>::lexExpectIdentifier): * runtime/ArgList.h: (JSC::MarkedArgumentBuffer::setNeedsOverflowCheck): (JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck): * runtime/Butterfly.h: (JSC::ContiguousData::ContiguousData): (JSC::ContiguousData::Data::Data): * runtime/HashMapImpl.h: (JSC::HashMapImpl::checkConsistency const): (JSC::HashMapImpl::assertBufferIsEmpty const): * runtime/JSCellInlines.h: (JSC::JSCell::methodTable const): * runtime/JSFunction.cpp: * runtime/JSFunction.h: (JSC::JSFunction::assertTypeInfoFlagInvariants): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSObject.cpp: (JSC::JSObject::visitChildren): (JSC::JSFinalObject::visitChildren): * runtime/JSObjectInlines.h: (JSC::JSObject::validatePutOwnDataProperty): * runtime/JSSegmentedVariableObject.h: (JSC::JSSegmentedVariableObject::assertVariableIsInThisObject): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::Lexer::lex): * runtime/LiteralParser.h: * runtime/Operations.h: (JSC::scribbleFreeCells): * runtime/OptionsList.h: * runtime/VM.cpp: (JSC::VM::computeCanUseJIT): * runtime/VM.h: (JSC::VM::canUseJIT): * runtime/VarOffset.h: (JSC::VarOffset::checkSanity const): * runtime/WeakMapImpl.h: (JSC::WeakMapImpl::checkConsistency const): (JSC::WeakMapImpl::assertBufferIsEmpty const): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::validateInst): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::parseAndCompile): * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser::validationFail const): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::checkConsistency): * wasm/WasmPlan.cpp: (JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast): * wasm/WasmSectionParser.h: * wasm/WasmSections.h: * wasm/WasmSignatureInlines.h: (JSC::Wasm::SignatureInformation::get): * wasm/WasmWorklist.cpp: (JSC::Wasm::Worklist::enqueue): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::previousInstanceOffset const): Source/WebCore: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * Modules/fetch/FetchBodySource.cpp: (WebCore::FetchBodySource::close): * Modules/fetch/FetchBodySource.h: * Modules/webdatabase/DatabaseDetails.h: (WebCore::DatabaseDetails::DatabaseDetails): (WebCore::DatabaseDetails::operator=): * Modules/webdatabase/DatabaseTask.cpp: (WebCore::DatabaseTask::performTask): * Modules/webdatabase/DatabaseTask.h: * Modules/webdatabase/DatabaseThread.cpp: (WebCore::DatabaseThread::terminationRequested const): * Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h: (WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation): * Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp: (WebCore::WHLSL::findHighZombies): * Modules/webgpu/WHLSL/WHLSLInferTypes.cpp: (WebCore::WHLSL::matches): * Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp: (WebCore::WHLSL::checkLiteralTypes): * Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp: (WebCore::WHLSL::FindAllTypes::appendNamedType): * bindings/js/JSCallbackData.h: * bindings/js/JSLazyEventListener.cpp: * bindings/js/JSLazyEventListener.h: * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * css/CSSCalculationValue.cpp: (WebCore::CSSCalcOperationNode::primitiveType const): * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): * css/CSSPrimitiveValue.cpp: * css/CSSSelector.cpp: (WebCore::CSSSelector::selectorText const): * css/CSSStyleSheet.cpp: * dom/ActiveDOMObject.cpp: (WebCore::ActiveDOMObject::suspendIfNeeded): (WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const): * dom/ActiveDOMObject.h: * dom/ContainerNode.cpp: * dom/ContainerNodeAlgorithms.cpp: * dom/ContainerNodeAlgorithms.h: * dom/CustomElementReactionQueue.cpp: * dom/CustomElementReactionQueue.h: (WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope): (WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope): * dom/Document.cpp: (WebCore::Document::hitTest): * dom/Document.h: (WebCore::Document::decrementReferencingNodeCount): * dom/Element.cpp: (WebCore::Element::addShadowRoot): (WebCore::Element::getURLAttribute const): (WebCore::Element::getNonEmptyURLAttribute const): * dom/Element.h: * dom/ElementAndTextDescendantIterator.h: (WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator): (WebCore::ElementAndTextDescendantIterator::dropAssertions): (WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack): (WebCore::ElementAndTextDescendantIterator::traverseNextSibling): (WebCore::ElementAndTextDescendantIterator::traversePreviousSibling): * dom/ElementDescendantIterator.h: (WebCore::ElementDescendantIterator::ElementDescendantIterator): (WebCore::ElementDescendantIterator::dropAssertions): (WebCore::ElementDescendantIterator::operator++): (WebCore::ElementDescendantIterator::operator--): (WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator): (WebCore::ElementDescendantConstIterator::dropAssertions): (WebCore::ElementDescendantConstIterator::operator++): * dom/ElementIterator.h: (WebCore::ElementIterator<ElementType>::ElementIterator): (WebCore::ElementIterator<ElementType>::traverseNext): (WebCore::ElementIterator<ElementType>::traversePrevious): (WebCore::ElementIterator<ElementType>::traverseNextSibling): (WebCore::ElementIterator<ElementType>::traversePreviousSibling): (WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren): (WebCore::ElementIterator<ElementType>::dropAssertions): (WebCore::ElementIterator<ElementType>::traverseAncestor): (WebCore::ElementConstIterator<ElementType>::ElementConstIterator): (WebCore::ElementConstIterator<ElementType>::traverseNext): (WebCore::ElementConstIterator<ElementType>::traversePrevious): (WebCore::ElementConstIterator<ElementType>::traverseNextSibling): (WebCore::ElementConstIterator<ElementType>::traversePreviousSibling): (WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren): (WebCore::ElementConstIterator<ElementType>::traverseAncestor): (WebCore::ElementConstIterator<ElementType>::dropAssertions): * dom/EventContext.cpp: * dom/EventContext.h: * dom/EventListener.h: * dom/EventPath.cpp: * dom/EventSender.h: * dom/EventTarget.cpp: (WebCore::EventTarget::addEventListener): (WebCore::EventTarget::setAttributeEventListener): (WebCore::EventTarget::innerInvokeEventListeners): * dom/Node.cpp: (WebCore::Node::~Node): (WebCore::Node::moveNodeToNewDocument): (WebCore::Node::removedLastRef): * dom/Node.h: (WebCore::Node::deref const): * dom/ScriptDisallowedScope.h: (WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::~ScriptExecutionContext): * dom/ScriptExecutionContext.h: * dom/SelectorQuery.cpp: (WebCore::SelectorDataList::execute const): * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::addSlotElementByName): (WebCore::SlotAssignment::removeSlotElementByName): (WebCore::SlotAssignment::resolveSlotsAfterSlotMutation): (WebCore::SlotAssignment::findFirstSlotElement): * dom/SlotAssignment.h: * dom/TreeScopeOrderedMap.cpp: (WebCore::TreeScopeOrderedMap::add): (WebCore::TreeScopeOrderedMap::get const): * dom/TreeScopeOrderedMap.h: * fileapi/Blob.cpp: * fileapi/Blob.h: * history/BackForwardCache.cpp: (WebCore::BackForwardCache::removeAllItemsForPage): * history/BackForwardCache.h: * html/CanvasBase.cpp: (WebCore::CanvasBase::notifyObserversCanvasDestroyed): * html/CanvasBase.h: * html/HTMLCollection.h: (WebCore::CollectionNamedElementCache::didPopulate): * html/HTMLSelectElement.cpp: (WebCore:: const): * html/HTMLTableRowsCollection.cpp: (WebCore::assertRowIsInTable): * html/HTMLTextFormControlElement.cpp: (WebCore::HTMLTextFormControlElement::indexForPosition const): * html/canvas/CanvasRenderingContext2DBase.cpp: (WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase): * html/parser/HTMLParserScheduler.cpp: (WebCore::HTMLParserScheduler::HTMLParserScheduler): (WebCore::HTMLParserScheduler::suspend): (WebCore::HTMLParserScheduler::resume): * html/parser/HTMLParserScheduler.h: * html/parser/HTMLToken.h: (WebCore::HTMLToken::beginStartTag): (WebCore::HTMLToken::beginEndTag): (WebCore::HTMLToken::endAttribute): * html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): (WebCore::HTMLTreeBuilder::constructTree): * html/parser/HTMLTreeBuilder.h: (WebCore::HTMLTreeBuilder::~HTMLTreeBuilder): * layout/FormattingContext.cpp: (WebCore::Layout::FormattingContext::geometryForBox const): * layout/blockformatting/BlockFormattingContext.cpp: (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition): * layout/blockformatting/BlockFormattingContext.h: * layout/displaytree/DisplayBox.cpp: (WebCore::Display::Box::Box): * layout/displaytree/DisplayBox.h: (WebCore::Display::Box::setTopLeft): (WebCore::Display::Box::setTop): (WebCore::Display::Box::setLeft): (WebCore::Display::Box::setContentBoxHeight): (WebCore::Display::Box::setContentBoxWidth): (WebCore::Display::Box::setHorizontalMargin): (WebCore::Display::Box::setVerticalMargin): (WebCore::Display::Box::setHorizontalComputedMargin): (WebCore::Display::Box::setBorder): (WebCore::Display::Box::setPadding): * layout/displaytree/DisplayInlineRect.h: (WebCore::Display::InlineRect::InlineRect): (WebCore::Display::InlineRect::setTopLeft): (WebCore::Display::InlineRect::setTop): (WebCore::Display::InlineRect::setBottom): (WebCore::Display::InlineRect::setLeft): (WebCore::Display::InlineRect::setWidth): (WebCore::Display::InlineRect::setHeight): * layout/displaytree/DisplayLineBox.h: (WebCore::Display::LineBox::LineBox): (WebCore::Display::LineBox::setBaselineOffsetIfGreater): (WebCore::Display::LineBox::resetBaseline): (WebCore::Display::LineBox::Baseline::Baseline): (WebCore::Display::LineBox::Baseline::setAscent): (WebCore::Display::LineBox::Baseline::setDescent): (WebCore::Display::LineBox::Baseline::reset): * layout/displaytree/DisplayRect.h: (WebCore::Display::Rect::Rect): (WebCore::Display::Rect::setTopLeft): (WebCore::Display::Rect::setTop): (WebCore::Display::Rect::setLeft): (WebCore::Display::Rect::setWidth): (WebCore::Display::Rect::setHeight): (WebCore::Display::Rect::setSize): (WebCore::Display::Rect::clone const): * layout/floats/FloatingContext.cpp: * layout/inlineformatting/InlineLineBuilder.cpp: (WebCore::Layout::LineBuilder::CollapsibleContent::collapse): * layout/tableformatting/TableGrid.cpp: (WebCore::Layout::TableGrid::Column::setWidthConstraints): (WebCore::Layout::TableGrid::Column::setLogicalWidth): (WebCore::Layout::TableGrid::Column::setLogicalLeft): * layout/tableformatting/TableGrid.h: * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::continueAfterContentPolicy): (WebCore::DocumentLoader::attachToFrame): (WebCore::DocumentLoader::detachFromFrame): (WebCore::DocumentLoader::addSubresourceLoader): * loader/DocumentLoader.h: * loader/ImageLoader.cpp: * loader/cache/CachedResource.h: * loader/cache/MemoryCache.cpp: (WebCore::MemoryCache::lruListFor): (WebCore::MemoryCache::removeFromLRUList): * page/FrameView.cpp: (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive): * page/FrameViewLayoutContext.cpp: * page/FrameViewLayoutContext.h: * page/Page.cpp: * page/Page.h: * page/ViewportConfiguration.cpp: * page/ViewportConfiguration.h: * page/mac/EventHandlerMac.mm: (WebCore::CurrentEventScope::CurrentEventScope): * platform/DateComponents.cpp: (WebCore::DateComponents::toStringForTime const): * platform/ScrollableArea.cpp: * platform/SharedBuffer.cpp: (WebCore::SharedBuffer::combineIntoOneSegment const): * platform/SharedBuffer.h: * platform/Supplementable.h: * platform/Timer.cpp: (WebCore::TimerBase::checkHeapIndex const): (WebCore::TimerBase::updateHeapIfNeeded): * platform/graphics/BitmapImage.cpp: * platform/graphics/BitmapImage.h: * platform/graphics/Image.h: * platform/graphics/ShadowBlur.cpp: (WebCore::ScratchBuffer::ScratchBuffer): (WebCore::ScratchBuffer::getScratchBuffer): (WebCore::ScratchBuffer::scheduleScratchBufferPurge): * platform/graphics/ca/win/CACFLayerTreeHost.cpp: (WebCore::CACFLayerTreeHost::setWindow): * platform/graphics/ca/win/CACFLayerTreeHost.h: * platform/graphics/cg/ImageBufferDataCG.cpp: (WebCore::ImageBufferData::putData): * platform/graphics/cocoa/FontCacheCoreText.cpp: * platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp: (gstAllocatorFastMallocFree): * platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp: (Nicosia::PaintingContextCairo::ForPainting::ForPainting): * platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp: (Nicosia::BackingStoreTextureMapperImpl::createTile): * platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp: (Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl): * platform/graphics/win/GradientDirect2D.cpp: (WebCore::Gradient::fill): * platform/graphics/win/ImageBufferDataDirect2D.cpp: (WebCore::ImageBufferData::putData): * platform/graphics/win/PathDirect2D.cpp: (WebCore::Path::appendGeometry): (WebCore::Path::Path): (WebCore::Path::operator=): (WebCore::Path::strokeContains const): (WebCore::Path::transform): * platform/graphics/win/PlatformContextDirect2D.cpp: (WebCore::PlatformContextDirect2D::setTags): * platform/mediastream/MediaStreamTrackPrivate.h: * platform/mediastream/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource): * platform/mediastream/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource): * platform/network/HTTPParsers.cpp: (WebCore::isCrossOriginSafeHeader): * platform/sql/SQLiteDatabase.cpp: * platform/sql/SQLiteDatabase.h: * platform/sql/SQLiteStatement.cpp: (WebCore::SQLiteStatement::SQLiteStatement): (WebCore::SQLiteStatement::prepare): (WebCore::SQLiteStatement::finalize): * platform/sql/SQLiteStatement.h: * platform/win/COMPtr.h: * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::removeInlineBox const): * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::FloatingObject): (WebCore::FloatingObjects::addPlacedObject): (WebCore::FloatingObjects::removePlacedObject): * rendering/FloatingObjects.h: * rendering/GridTrackSizingAlgorithm.cpp: * rendering/GridTrackSizingAlgorithm.h: * rendering/LayoutDisallowedScope.cpp: * rendering/LayoutDisallowedScope.h: * rendering/RenderBlock.cpp: * rendering/RenderBlock.h: * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::layoutBlockChild): (WebCore::RenderBlockFlow::removeFloatingObject): (WebCore::RenderBlockFlow::ensureLineBoxes): * rendering/RenderBoxModelObject.cpp: * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::layoutBlock): * rendering/RenderElement.cpp: * rendering/RenderGeometryMap.cpp: (WebCore::RenderGeometryMap::mapToContainer const): * rendering/RenderGrid.cpp: (WebCore::RenderGrid::placeItemsOnGrid const): (WebCore::RenderGrid::baselinePosition const): * rendering/RenderInline.cpp: (WebCore::RenderInline::willBeDestroyed): * rendering/RenderLayer.cpp: (WebCore::ClipRectsCache::ClipRectsCache): (WebCore::RenderLayer::RenderLayer): (WebCore::RenderLayer::paintList): (WebCore::RenderLayer::hitTestLayer): (WebCore::RenderLayer::updateClipRects): (WebCore::RenderLayer::calculateClipRects const): * rendering/RenderLayer.h: * rendering/RenderLayerBacking.cpp: (WebCore::traverseVisibleNonCompositedDescendantLayers): * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::computeCompositingRequirements): (WebCore::RenderLayerCompositor::traverseUnchangedSubtree): (WebCore::RenderLayerCompositor::updateBackingAndHierarchy): (WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const): (WebCore::RenderLayerCompositor::recursiveRepaintLayer): (WebCore::RenderLayerCompositor::layerHas3DContent const): * rendering/RenderLayoutState.cpp: (WebCore::RenderLayoutState::RenderLayoutState): (WebCore::RenderLayoutState::computeOffsets): (WebCore::RenderLayoutState::addLayoutDelta): * rendering/RenderLayoutState.h: (WebCore::RenderLayoutState::RenderLayoutState): * rendering/RenderObject.cpp: (WebCore::RenderObject::RenderObject): (WebCore::RenderObject::~RenderObject): (WebCore::RenderObject::clearNeedsLayout): * rendering/RenderObject.h: * rendering/RenderQuote.cpp: (WebCore::quotesForLanguage): * rendering/RenderTableCell.h: * rendering/RenderTableSection.cpp: (WebCore::RenderTableSection::computeOverflowFromCells): * rendering/RenderTextLineBoxes.cpp: (WebCore::RenderTextLineBoxes::checkConsistency const): * rendering/RenderTextLineBoxes.h: * rendering/line/BreakingContext.h: (WebCore::tryHyphenating): * rendering/style/GridArea.h: (WebCore::GridSpan::GridSpan): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::~RenderStyle): * rendering/style/RenderStyle.h: * rendering/updating/RenderTreeBuilderRuby.cpp: (WebCore::RenderTreeBuilder::Ruby::detach): * rendering/updating/RenderTreePosition.cpp: (WebCore::RenderTreePosition::computeNextSibling): * rendering/updating/RenderTreePosition.h: * svg/SVGToOTFFontConversion.cpp: (WebCore::SVGToOTFFontConverter::Placeholder::Placeholder): (WebCore::SVGToOTFFontConverter::Placeholder::populate): (WebCore::SVGToOTFFontConverter::appendCFFTable): (WebCore::SVGToOTFFontConverter::firstGlyph const): (WebCore::SVGToOTFFontConverter::appendKERNTable): * svg/SVGTransformDistance.cpp: (WebCore::SVGTransformDistance::SVGTransformDistance): (WebCore::SVGTransformDistance::scaledDistance const): (WebCore::SVGTransformDistance::addSVGTransforms): (WebCore::SVGTransformDistance::addToSVGTransform const): (WebCore::SVGTransformDistance::distance const): * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::nativeImage): * testing/InternalSettings.cpp: * workers/service/ServiceWorkerJob.h: * worklets/PaintWorkletGlobalScope.h: (WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope): * xml/XPathStep.cpp: Source/WebKit: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::invalidateAndCancel): * NetworkProcess/NetworkSession.h: * NetworkProcess/cache/NetworkCacheStorage.cpp: (WebKit::NetworkCache::Storage::setCapacity): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (toNSURLSessionResponseDisposition): (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): * Platform/IPC/Connection.cpp: (IPC::Connection::waitForMessage): * Platform/IPC/MessageReceiver.h: (IPC::MessageReceiver::willBeAddedToMessageReceiverMap): (IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap): * Platform/IPC/cocoa/ConnectionCocoa.mm: (IPC::readFromMachPort): * Platform/mac/MachUtilities.cpp: (setMachExceptionPort): * Shared/API/APIClient.h: (API::Client::Client): * Shared/API/Cocoa/WKRemoteObjectCoder.mm: * Shared/Cocoa/ArgumentCodersCocoa.h: * Shared/SharedStringHashTableReadOnly.cpp: * UIProcess/BackingStore.cpp: (WebKit::BackingStore::incorporateUpdate): * UIProcess/GenericCallback.h: * UIProcess/Launcher/mac/ProcessLauncherMac.mm: (WebKit::ProcessLauncher::launchProcess): * UIProcess/PageLoadState.h: (WebKit::PageLoadState::Transaction::Token::Token): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::~WebPageProxy): * WebProcess/Network/WebResourceLoader.cpp: (WebKit::WebResourceLoader::didReceiveResponse): * WebProcess/Network/WebResourceLoader.h: * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp: (WebKit::NetscapePluginStream::NetscapePluginStream): (WebKit::NetscapePluginStream::notifyAndDestroyStream): * WebProcess/Plugins/Netscape/NetscapePluginStream.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runModal): * WebProcess/WebProcess.cpp: (WebKit::checkDocumentsCaptureStateConsistency): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::updateProcessName): Source/WebKitLegacy: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * Storage/StorageAreaImpl.cpp: (WebKit::StorageAreaImpl::StorageAreaImpl): (WebKit::StorageAreaImpl::close): * Storage/StorageAreaImpl.h: Source/WebKitLegacy/mac: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * History/WebHistory.mm: (-[WebHistoryPrivate removeItemForURLString:]): * WebView/WebFrame.mm: Source/WebKitLegacy/win: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * WebKitQuartzCoreAdditions/CAD3DRenderer.cpp: (WKQCA::CAD3DRenderer::swapChain): (WKQCA::CAD3DRenderer::initialize): * WebKitQuartzCoreAdditions/CAD3DRenderer.h: * WebView.cpp: (WebView::Release): * WebView.h: Source/WTF: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. This patch did the following changes: 1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away with the need for the double negative !ASSERT_DISABLED test that is commonly used all over the code, thereby improving code readability. In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED, ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents as well. We'll do that in another patch. For now, they are left as is to minimize the size of this patch. See https://bugs.webkit.org/show_bug.cgi?id=205780. 2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be guarded by "#if ASSERT_ENABLED" instead. 3. In cases where the change is minimal, we move some code around so that we can test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED". * wtf/Assertions.h: * wtf/AutomaticThread.cpp: (WTF::AutomaticThread::start): * wtf/BitVector.h: * wtf/BlockObjCExceptions.mm: (ReportBlockedObjCException): * wtf/BloomFilter.h: * wtf/CallbackAggregator.h: (WTF::CallbackAggregator::CallbackAggregator): * wtf/CheckedArithmetic.h: (WTF::observesOverflow<AssertNoOverflow>): * wtf/CheckedBoolean.h: (CheckedBoolean::CheckedBoolean): (CheckedBoolean::operator bool): * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): * wtf/DateMath.cpp: (WTF::initializeDates): * wtf/Gigacage.cpp: (Gigacage::tryAllocateZeroedVirtualPages): * wtf/HashTable.h: (WTF::KeyTraits>::checkKey): (WTF::KeyTraits>::checkTableConsistencyExceptSize const): * wtf/LoggerHelper.h: * wtf/NaturalLoops.h: (WTF::NaturalLoops::headerOf const): * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): * wtf/OptionSet.h: (WTF::OptionSet::OptionSet): * wtf/Platform.h: * wtf/PtrTag.h: * wtf/RefCounted.h: (WTF::RefCountedBase::disableThreadingChecks): (WTF::RefCountedBase::enableThreadingChecksGlobally): (WTF::RefCountedBase::RefCountedBase): (WTF::RefCountedBase::applyRefDerefThreadingCheck const): * wtf/SingleRootGraph.h: (WTF::SingleRootGraph::assertIsConsistent const): * wtf/SizeLimits.cpp: * wtf/StackBounds.h: (WTF::StackBounds::checkConsistency const): * wtf/URLParser.cpp: (WTF::URLParser::URLParser): (WTF::URLParser::domainToASCII): * wtf/ValueCheck.h: * wtf/Vector.h: (WTF::Malloc>::checkConsistency): * wtf/WeakHashSet.h: * wtf/WeakPtr.h: (WTF::WeakPtrImpl::WeakPtrImpl): (WTF::WeakPtrFactory::WeakPtrFactory): * wtf/text/AtomStringImpl.cpp: * wtf/text/AtomStringImpl.h: * wtf/text/StringBuilder.cpp: (WTF::StringBuilder::reifyString const): * wtf/text/StringBuilder.h: * wtf/text/StringCommon.h: (WTF::hasPrefixWithLettersIgnoringASCIICaseCommon): * wtf/text/StringHasher.h: (WTF::StringHasher::addCharacters): * wtf/text/StringImpl.h: * wtf/text/SymbolImpl.h: * wtf/text/UniquedStringImpl.h: Tools: Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory https://bugs.webkit.org/show_bug.cgi?id=205754 Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06 Reviewed by Youenn Fablet. * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: * WebKitTestRunner/TestController.cpp: (WTR::TestController::websiteDataStore): (WTR::TestController::platformAdjustContext): * WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::initializeWebViewConfiguration): Canonical link: https://commits.webkit.org/218957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
#if ASSERT_ENABLED
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
m_isConstructed = true;
#endif
AtomString::init should temporarily disable checks via `isMainThread` due to WebThread's inconsistent state https://bugs.webkit.org/show_bug.cgi?id=211754 Reviewed by Dean Jackson. When starting WebThread via StartWebThread function, we have special period between the prologue of StartWebThread and spawning WebThread actually. In this period, `isMainThread()` returns false even if this is called on the main thread since WebThread is now enabled and we are not taking a WebThread lock. This causes assertion hits in MainThreadLazyNeverDestroyed initialization only in WebThread platforms. This patch takes conservative approach to fix this assertion hits: just bypass these assertions since this should not be fired. We bypass assertions by using constructWithoutAccessCheck, which intentionally skips `isMainThread()` check for construction. In non WebThread environment, we do not lose the assertion coverage since we already have ASSERT(isUIThread()). And ASSERT(isUIThread()) ensures that this is called in system main thread in WebThread platforms. Unfortunately, we have no mechanism to test this effectively. WK1 LayoutTests runner cannot show assertions since WK1 runners already initialize necessary things somewhere before calling AtomString::init() in StartWebThread. This is the same in TestWebKitAPI. For now, I manually tested that assertion does not fire. * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::constructWithoutAccessCheck): (WTF::LazyNeverDestroyed::storagePointerWithoutAccessCheck const): (WTF::LazyNeverDestroyed::storagePointer const): * wtf/text/AtomString.cpp: (WTF::AtomString::init): Canonical link: https://commits.webkit.org/224663@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 05:21:28 +00:00
MaybeRelax<T>(new (storagePointerWithoutAccessCheck()) T(std::forward<Args>(args)...));
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
}
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
operator T&() { return *storagePointer(); }
T& get() { return *storagePointer(); }
T* operator->() { return storagePointer(); }
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
operator const T&() const { return *storagePointer(); }
const T& get() const { return *storagePointer(); }
const T* operator->() const { return storagePointer(); }
PerformanceTests: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * JetStream2/wasm/HashSet.cpp: * StitchMarker/wtf/Assertions.h: * StitchMarker/wtf/DateMath.cpp: (WTF::initializeDates): * StitchMarker/wtf/HashTable.h: * StitchMarker/wtf/Hasher.h: (WTF::StringHasher::addCharacters): * StitchMarker/wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): * StitchMarker/wtf/StackBounds.h: (WTF::StackBounds::checkConsistency const): * StitchMarker/wtf/ValueCheck.h: * StitchMarker/wtf/Vector.h: (WTF::minCapacity>::checkConsistency): * StitchMarker/wtf/text/AtomicStringImpl.cpp: * StitchMarker/wtf/text/AtomicStringImpl.h: * StitchMarker/wtf/text/StringCommon.h: (WTF::hasPrefixWithLettersIgnoringASCIICaseCommon): * StitchMarker/wtf/text/StringImpl.h: * StitchMarker/wtf/text/SymbolImpl.h: * StitchMarker/wtf/text/UniquedStringImpl.h: Source/JavaScriptCore: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * API/tests/testapi.c: * assembler/ARM64Assembler.h: (JSC::ARM64Assembler::replaceWithLoad): (JSC::ARM64Assembler::replaceWithAddressComputation): * assembler/AssemblerBuffer.h: (JSC::AssemblerBuffer::LocalWriter::LocalWriter): * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::copyCompactAndLinkCode): * assembler/ProbeStack.cpp: (JSC::Probe::Stack::Stack): * assembler/ProbeStack.h: * b3/B3FoldPathConstants.cpp: * b3/B3LowerToAir.cpp: * b3/B3MemoryValue.cpp: (JSC::B3::MemoryValue::MemoryValue): * b3/B3Opcode.cpp: * b3/B3Type.h: * b3/B3TypeMap.h: * b3/B3Width.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp: (JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration): (JSC::B3::Air::GenerateAndAllocateRegisters::generate): * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirArg.cpp: * b3/air/AirArg.h: * b3/air/AirCode.h: * b3/air/AirEmitShuffle.cpp: (JSC::B3::Air::emitShuffle): * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createExecutable): * bytecode/AccessCase.cpp: * bytecode/AccessCase.h: * bytecode/CallVariant.cpp: (JSC::variantListWithVariant): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex): * bytecode/CodeBlockHash.cpp: (JSC::CodeBlockHash::dump const): * bytecode/StructureStubInfo.cpp: * bytecode/StructureStubInfo.h: * bytecompiler/NodesCodegen.cpp: (JSC::FunctionCallResolveNode::emitBytecode): * bytecompiler/RegisterID.h: (JSC::RegisterID::RegisterID): (JSC::RegisterID::setIndex): * debugger/Debugger.cpp: (JSC::Debugger::removeBreakpoint): * debugger/DebuggerEvalEnabler.h: (JSC::DebuggerEvalEnabler::DebuggerEvalEnabler): (JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions): * dfg/DFGAbstractValue.cpp: * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::merge): (JSC::DFG::AbstractValue::checkConsistency const): (JSC::DFG::AbstractValue::assertIsRegistered const): * dfg/DFGArithMode.h: (JSC::DFG::doesOverflow): * dfg/DFGBasicBlock.cpp: (JSC::DFG::BasicBlock::BasicBlock): * dfg/DFGBasicBlock.h: (JSC::DFG::BasicBlock::didLink): * dfg/DFGCFAPhase.cpp: (JSC::DFG::CFAPhase::performBlockCFA): * dfg/DFGCommon.h: (JSC::DFG::validationEnabled): * dfg/DFGCommonData.cpp: (JSC::DFG::CommonData::finalizeCatchEntrypoints): * dfg/DFGDesiredWatchpoints.h: * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGEdge.h: (JSC::DFG::Edge::makeWord): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::finalizeOSREntrypoints): * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGSSAConversionPhase.cpp: (JSC::DFG::SSAConversionPhase::run): * dfg/DFGScoreBoard.h: (JSC::DFG::ScoreBoard::assertClear): * dfg/DFGSlowPathGenerator.h: (JSC::DFG::SlowPathGenerator::generate): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCurrentBlock): (JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse): (JSC::DFG::SpeculativeJIT::emitAllocateButterfly): (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): (JSC::DFG::SpeculativeJIT::compileMakeRope): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::fillSpeculateCell): * dfg/DFGStructureAbstractValue.cpp: * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::assertIsRegistered const): * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVirtualRegisterAllocationPhase.cpp: (JSC::DFG::VirtualRegisterAllocationPhase::run): * ftl/FTLLink.cpp: (JSC::FTL::link): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::callPreflight): (JSC::FTL::DFG::LowerDFGToB3::callCheck): (JSC::FTL::DFG::LowerDFGToB3::crash): * ftl/FTLOperations.cpp: (JSC::FTL::operationMaterializeObjectInOSR): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::assertNoUnswept): * heap/GCSegmentedArray.h: (JSC::GCArraySegment::GCArraySegment): * heap/GCSegmentedArrayInlines.h: (JSC::GCSegmentedArray<T>::clear): (JSC::GCSegmentedArray<T>::expand): (JSC::GCSegmentedArray<T>::validatePrevious): * heap/HandleSet.cpp: * heap/HandleSet.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/MarkedBlock.cpp: * heap/MarkedBlock.h: (JSC::MarkedBlock::assertValidCell const): (JSC::MarkedBlock::assertMarksNotStale): * heap/MarkedSpace.cpp: (JSC::MarkedSpace::beginMarking): (JSC::MarkedSpace::endMarking): (JSC::MarkedSpace::assertNoUnswept): * heap/PreciseAllocation.cpp: * heap/PreciseAllocation.h: (JSC::PreciseAllocation::assertValidCell const): * heap/SlotVisitor.cpp: (JSC::SlotVisitor::SlotVisitor): (JSC::SlotVisitor::appendJSCellOrAuxiliary): * heap/SlotVisitor.h: * inspector/InspectorProtocolTypes.h: (Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType): * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration): (CppProtocolTypesImplementationGenerator): (CppProtocolTypesImplementationGenerator._generate_assertion_for_enum): * inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result: * interpreter/FrameTracers.h: (JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer): * interpreter/Interpreter.cpp: (JSC::Interpreter::Interpreter): * interpreter/Interpreter.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::prepareCallOperation): * jit/BinarySwitch.cpp: (JSC::BinarySwitch::BinarySwitch): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupStubArgs): * jit/CallFrameShuffler.cpp: (JSC::CallFrameShuffler::emitDeltaCheck): (JSC::CallFrameShuffler::prepareAny): * jit/JIT.cpp: (JSC::JIT::assertStackPointerOffset): (JSC::JIT::compileWithoutLinking): * jit/JITOpcodes.cpp: (JSC::JIT::emitSlow_op_loop_hint): * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_from_scope): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_get_from_scope): * jit/Repatch.cpp: (JSC::linkPolymorphicCall): * jit/ThunkGenerators.cpp: (JSC::emitPointerValidation): * llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): * llint/LLIntOfflineAsmConfig.h: * parser/Lexer.cpp: * parser/Lexer.h: (JSC::isSafeBuiltinIdentifier): (JSC::Lexer<T>::lexExpectIdentifier): * runtime/ArgList.h: (JSC::MarkedArgumentBuffer::setNeedsOverflowCheck): (JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck): * runtime/Butterfly.h: (JSC::ContiguousData::ContiguousData): (JSC::ContiguousData::Data::Data): * runtime/HashMapImpl.h: (JSC::HashMapImpl::checkConsistency const): (JSC::HashMapImpl::assertBufferIsEmpty const): * runtime/JSCellInlines.h: (JSC::JSCell::methodTable const): * runtime/JSFunction.cpp: * runtime/JSFunction.h: (JSC::JSFunction::assertTypeInfoFlagInvariants): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSObject.cpp: (JSC::JSObject::visitChildren): (JSC::JSFinalObject::visitChildren): * runtime/JSObjectInlines.h: (JSC::JSObject::validatePutOwnDataProperty): * runtime/JSSegmentedVariableObject.h: (JSC::JSSegmentedVariableObject::assertVariableIsInThisObject): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::Lexer::lex): * runtime/LiteralParser.h: * runtime/Operations.h: (JSC::scribbleFreeCells): * runtime/OptionsList.h: * runtime/VM.cpp: (JSC::VM::computeCanUseJIT): * runtime/VM.h: (JSC::VM::canUseJIT): * runtime/VarOffset.h: (JSC::VarOffset::checkSanity const): * runtime/WeakMapImpl.h: (JSC::WeakMapImpl::checkConsistency const): (JSC::WeakMapImpl::assertBufferIsEmpty const): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::validateInst): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::parseAndCompile): * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser::validationFail const): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::checkConsistency): * wasm/WasmPlan.cpp: (JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast): * wasm/WasmSectionParser.h: * wasm/WasmSections.h: * wasm/WasmSignatureInlines.h: (JSC::Wasm::SignatureInformation::get): * wasm/WasmWorklist.cpp: (JSC::Wasm::Worklist::enqueue): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::previousInstanceOffset const): Source/WebCore: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * Modules/fetch/FetchBodySource.cpp: (WebCore::FetchBodySource::close): * Modules/fetch/FetchBodySource.h: * Modules/webdatabase/DatabaseDetails.h: (WebCore::DatabaseDetails::DatabaseDetails): (WebCore::DatabaseDetails::operator=): * Modules/webdatabase/DatabaseTask.cpp: (WebCore::DatabaseTask::performTask): * Modules/webdatabase/DatabaseTask.h: * Modules/webdatabase/DatabaseThread.cpp: (WebCore::DatabaseThread::terminationRequested const): * Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h: (WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation): * Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp: (WebCore::WHLSL::findHighZombies): * Modules/webgpu/WHLSL/WHLSLInferTypes.cpp: (WebCore::WHLSL::matches): * Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp: (WebCore::WHLSL::checkLiteralTypes): * Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp: (WebCore::WHLSL::FindAllTypes::appendNamedType): * bindings/js/JSCallbackData.h: * bindings/js/JSLazyEventListener.cpp: * bindings/js/JSLazyEventListener.h: * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * css/CSSCalculationValue.cpp: (WebCore::CSSCalcOperationNode::primitiveType const): * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): * css/CSSPrimitiveValue.cpp: * css/CSSSelector.cpp: (WebCore::CSSSelector::selectorText const): * css/CSSStyleSheet.cpp: * dom/ActiveDOMObject.cpp: (WebCore::ActiveDOMObject::suspendIfNeeded): (WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const): * dom/ActiveDOMObject.h: * dom/ContainerNode.cpp: * dom/ContainerNodeAlgorithms.cpp: * dom/ContainerNodeAlgorithms.h: * dom/CustomElementReactionQueue.cpp: * dom/CustomElementReactionQueue.h: (WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope): (WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope): * dom/Document.cpp: (WebCore::Document::hitTest): * dom/Document.h: (WebCore::Document::decrementReferencingNodeCount): * dom/Element.cpp: (WebCore::Element::addShadowRoot): (WebCore::Element::getURLAttribute const): (WebCore::Element::getNonEmptyURLAttribute const): * dom/Element.h: * dom/ElementAndTextDescendantIterator.h: (WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator): (WebCore::ElementAndTextDescendantIterator::dropAssertions): (WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack): (WebCore::ElementAndTextDescendantIterator::traverseNextSibling): (WebCore::ElementAndTextDescendantIterator::traversePreviousSibling): * dom/ElementDescendantIterator.h: (WebCore::ElementDescendantIterator::ElementDescendantIterator): (WebCore::ElementDescendantIterator::dropAssertions): (WebCore::ElementDescendantIterator::operator++): (WebCore::ElementDescendantIterator::operator--): (WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator): (WebCore::ElementDescendantConstIterator::dropAssertions): (WebCore::ElementDescendantConstIterator::operator++): * dom/ElementIterator.h: (WebCore::ElementIterator<ElementType>::ElementIterator): (WebCore::ElementIterator<ElementType>::traverseNext): (WebCore::ElementIterator<ElementType>::traversePrevious): (WebCore::ElementIterator<ElementType>::traverseNextSibling): (WebCore::ElementIterator<ElementType>::traversePreviousSibling): (WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren): (WebCore::ElementIterator<ElementType>::dropAssertions): (WebCore::ElementIterator<ElementType>::traverseAncestor): (WebCore::ElementConstIterator<ElementType>::ElementConstIterator): (WebCore::ElementConstIterator<ElementType>::traverseNext): (WebCore::ElementConstIterator<ElementType>::traversePrevious): (WebCore::ElementConstIterator<ElementType>::traverseNextSibling): (WebCore::ElementConstIterator<ElementType>::traversePreviousSibling): (WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren): (WebCore::ElementConstIterator<ElementType>::traverseAncestor): (WebCore::ElementConstIterator<ElementType>::dropAssertions): * dom/EventContext.cpp: * dom/EventContext.h: * dom/EventListener.h: * dom/EventPath.cpp: * dom/EventSender.h: * dom/EventTarget.cpp: (WebCore::EventTarget::addEventListener): (WebCore::EventTarget::setAttributeEventListener): (WebCore::EventTarget::innerInvokeEventListeners): * dom/Node.cpp: (WebCore::Node::~Node): (WebCore::Node::moveNodeToNewDocument): (WebCore::Node::removedLastRef): * dom/Node.h: (WebCore::Node::deref const): * dom/ScriptDisallowedScope.h: (WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::~ScriptExecutionContext): * dom/ScriptExecutionContext.h: * dom/SelectorQuery.cpp: (WebCore::SelectorDataList::execute const): * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::addSlotElementByName): (WebCore::SlotAssignment::removeSlotElementByName): (WebCore::SlotAssignment::resolveSlotsAfterSlotMutation): (WebCore::SlotAssignment::findFirstSlotElement): * dom/SlotAssignment.h: * dom/TreeScopeOrderedMap.cpp: (WebCore::TreeScopeOrderedMap::add): (WebCore::TreeScopeOrderedMap::get const): * dom/TreeScopeOrderedMap.h: * fileapi/Blob.cpp: * fileapi/Blob.h: * history/BackForwardCache.cpp: (WebCore::BackForwardCache::removeAllItemsForPage): * history/BackForwardCache.h: * html/CanvasBase.cpp: (WebCore::CanvasBase::notifyObserversCanvasDestroyed): * html/CanvasBase.h: * html/HTMLCollection.h: (WebCore::CollectionNamedElementCache::didPopulate): * html/HTMLSelectElement.cpp: (WebCore:: const): * html/HTMLTableRowsCollection.cpp: (WebCore::assertRowIsInTable): * html/HTMLTextFormControlElement.cpp: (WebCore::HTMLTextFormControlElement::indexForPosition const): * html/canvas/CanvasRenderingContext2DBase.cpp: (WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase): * html/parser/HTMLParserScheduler.cpp: (WebCore::HTMLParserScheduler::HTMLParserScheduler): (WebCore::HTMLParserScheduler::suspend): (WebCore::HTMLParserScheduler::resume): * html/parser/HTMLParserScheduler.h: * html/parser/HTMLToken.h: (WebCore::HTMLToken::beginStartTag): (WebCore::HTMLToken::beginEndTag): (WebCore::HTMLToken::endAttribute): * html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): (WebCore::HTMLTreeBuilder::constructTree): * html/parser/HTMLTreeBuilder.h: (WebCore::HTMLTreeBuilder::~HTMLTreeBuilder): * layout/FormattingContext.cpp: (WebCore::Layout::FormattingContext::geometryForBox const): * layout/blockformatting/BlockFormattingContext.cpp: (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition): * layout/blockformatting/BlockFormattingContext.h: * layout/displaytree/DisplayBox.cpp: (WebCore::Display::Box::Box): * layout/displaytree/DisplayBox.h: (WebCore::Display::Box::setTopLeft): (WebCore::Display::Box::setTop): (WebCore::Display::Box::setLeft): (WebCore::Display::Box::setContentBoxHeight): (WebCore::Display::Box::setContentBoxWidth): (WebCore::Display::Box::setHorizontalMargin): (WebCore::Display::Box::setVerticalMargin): (WebCore::Display::Box::setHorizontalComputedMargin): (WebCore::Display::Box::setBorder): (WebCore::Display::Box::setPadding): * layout/displaytree/DisplayInlineRect.h: (WebCore::Display::InlineRect::InlineRect): (WebCore::Display::InlineRect::setTopLeft): (WebCore::Display::InlineRect::setTop): (WebCore::Display::InlineRect::setBottom): (WebCore::Display::InlineRect::setLeft): (WebCore::Display::InlineRect::setWidth): (WebCore::Display::InlineRect::setHeight): * layout/displaytree/DisplayLineBox.h: (WebCore::Display::LineBox::LineBox): (WebCore::Display::LineBox::setBaselineOffsetIfGreater): (WebCore::Display::LineBox::resetBaseline): (WebCore::Display::LineBox::Baseline::Baseline): (WebCore::Display::LineBox::Baseline::setAscent): (WebCore::Display::LineBox::Baseline::setDescent): (WebCore::Display::LineBox::Baseline::reset): * layout/displaytree/DisplayRect.h: (WebCore::Display::Rect::Rect): (WebCore::Display::Rect::setTopLeft): (WebCore::Display::Rect::setTop): (WebCore::Display::Rect::setLeft): (WebCore::Display::Rect::setWidth): (WebCore::Display::Rect::setHeight): (WebCore::Display::Rect::setSize): (WebCore::Display::Rect::clone const): * layout/floats/FloatingContext.cpp: * layout/inlineformatting/InlineLineBuilder.cpp: (WebCore::Layout::LineBuilder::CollapsibleContent::collapse): * layout/tableformatting/TableGrid.cpp: (WebCore::Layout::TableGrid::Column::setWidthConstraints): (WebCore::Layout::TableGrid::Column::setLogicalWidth): (WebCore::Layout::TableGrid::Column::setLogicalLeft): * layout/tableformatting/TableGrid.h: * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::continueAfterContentPolicy): (WebCore::DocumentLoader::attachToFrame): (WebCore::DocumentLoader::detachFromFrame): (WebCore::DocumentLoader::addSubresourceLoader): * loader/DocumentLoader.h: * loader/ImageLoader.cpp: * loader/cache/CachedResource.h: * loader/cache/MemoryCache.cpp: (WebCore::MemoryCache::lruListFor): (WebCore::MemoryCache::removeFromLRUList): * page/FrameView.cpp: (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive): * page/FrameViewLayoutContext.cpp: * page/FrameViewLayoutContext.h: * page/Page.cpp: * page/Page.h: * page/ViewportConfiguration.cpp: * page/ViewportConfiguration.h: * page/mac/EventHandlerMac.mm: (WebCore::CurrentEventScope::CurrentEventScope): * platform/DateComponents.cpp: (WebCore::DateComponents::toStringForTime const): * platform/ScrollableArea.cpp: * platform/SharedBuffer.cpp: (WebCore::SharedBuffer::combineIntoOneSegment const): * platform/SharedBuffer.h: * platform/Supplementable.h: * platform/Timer.cpp: (WebCore::TimerBase::checkHeapIndex const): (WebCore::TimerBase::updateHeapIfNeeded): * platform/graphics/BitmapImage.cpp: * platform/graphics/BitmapImage.h: * platform/graphics/Image.h: * platform/graphics/ShadowBlur.cpp: (WebCore::ScratchBuffer::ScratchBuffer): (WebCore::ScratchBuffer::getScratchBuffer): (WebCore::ScratchBuffer::scheduleScratchBufferPurge): * platform/graphics/ca/win/CACFLayerTreeHost.cpp: (WebCore::CACFLayerTreeHost::setWindow): * platform/graphics/ca/win/CACFLayerTreeHost.h: * platform/graphics/cg/ImageBufferDataCG.cpp: (WebCore::ImageBufferData::putData): * platform/graphics/cocoa/FontCacheCoreText.cpp: * platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp: (gstAllocatorFastMallocFree): * platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp: (Nicosia::PaintingContextCairo::ForPainting::ForPainting): * platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp: (Nicosia::BackingStoreTextureMapperImpl::createTile): * platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp: (Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl): * platform/graphics/win/GradientDirect2D.cpp: (WebCore::Gradient::fill): * platform/graphics/win/ImageBufferDataDirect2D.cpp: (WebCore::ImageBufferData::putData): * platform/graphics/win/PathDirect2D.cpp: (WebCore::Path::appendGeometry): (WebCore::Path::Path): (WebCore::Path::operator=): (WebCore::Path::strokeContains const): (WebCore::Path::transform): * platform/graphics/win/PlatformContextDirect2D.cpp: (WebCore::PlatformContextDirect2D::setTags): * platform/mediastream/MediaStreamTrackPrivate.h: * platform/mediastream/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource): * platform/mediastream/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource): * platform/network/HTTPParsers.cpp: (WebCore::isCrossOriginSafeHeader): * platform/sql/SQLiteDatabase.cpp: * platform/sql/SQLiteDatabase.h: * platform/sql/SQLiteStatement.cpp: (WebCore::SQLiteStatement::SQLiteStatement): (WebCore::SQLiteStatement::prepare): (WebCore::SQLiteStatement::finalize): * platform/sql/SQLiteStatement.h: * platform/win/COMPtr.h: * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::removeInlineBox const): * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::FloatingObject): (WebCore::FloatingObjects::addPlacedObject): (WebCore::FloatingObjects::removePlacedObject): * rendering/FloatingObjects.h: * rendering/GridTrackSizingAlgorithm.cpp: * rendering/GridTrackSizingAlgorithm.h: * rendering/LayoutDisallowedScope.cpp: * rendering/LayoutDisallowedScope.h: * rendering/RenderBlock.cpp: * rendering/RenderBlock.h: * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::layoutBlockChild): (WebCore::RenderBlockFlow::removeFloatingObject): (WebCore::RenderBlockFlow::ensureLineBoxes): * rendering/RenderBoxModelObject.cpp: * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::layoutBlock): * rendering/RenderElement.cpp: * rendering/RenderGeometryMap.cpp: (WebCore::RenderGeometryMap::mapToContainer const): * rendering/RenderGrid.cpp: (WebCore::RenderGrid::placeItemsOnGrid const): (WebCore::RenderGrid::baselinePosition const): * rendering/RenderInline.cpp: (WebCore::RenderInline::willBeDestroyed): * rendering/RenderLayer.cpp: (WebCore::ClipRectsCache::ClipRectsCache): (WebCore::RenderLayer::RenderLayer): (WebCore::RenderLayer::paintList): (WebCore::RenderLayer::hitTestLayer): (WebCore::RenderLayer::updateClipRects): (WebCore::RenderLayer::calculateClipRects const): * rendering/RenderLayer.h: * rendering/RenderLayerBacking.cpp: (WebCore::traverseVisibleNonCompositedDescendantLayers): * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::computeCompositingRequirements): (WebCore::RenderLayerCompositor::traverseUnchangedSubtree): (WebCore::RenderLayerCompositor::updateBackingAndHierarchy): (WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const): (WebCore::RenderLayerCompositor::recursiveRepaintLayer): (WebCore::RenderLayerCompositor::layerHas3DContent const): * rendering/RenderLayoutState.cpp: (WebCore::RenderLayoutState::RenderLayoutState): (WebCore::RenderLayoutState::computeOffsets): (WebCore::RenderLayoutState::addLayoutDelta): * rendering/RenderLayoutState.h: (WebCore::RenderLayoutState::RenderLayoutState): * rendering/RenderObject.cpp: (WebCore::RenderObject::RenderObject): (WebCore::RenderObject::~RenderObject): (WebCore::RenderObject::clearNeedsLayout): * rendering/RenderObject.h: * rendering/RenderQuote.cpp: (WebCore::quotesForLanguage): * rendering/RenderTableCell.h: * rendering/RenderTableSection.cpp: (WebCore::RenderTableSection::computeOverflowFromCells): * rendering/RenderTextLineBoxes.cpp: (WebCore::RenderTextLineBoxes::checkConsistency const): * rendering/RenderTextLineBoxes.h: * rendering/line/BreakingContext.h: (WebCore::tryHyphenating): * rendering/style/GridArea.h: (WebCore::GridSpan::GridSpan): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::~RenderStyle): * rendering/style/RenderStyle.h: * rendering/updating/RenderTreeBuilderRuby.cpp: (WebCore::RenderTreeBuilder::Ruby::detach): * rendering/updating/RenderTreePosition.cpp: (WebCore::RenderTreePosition::computeNextSibling): * rendering/updating/RenderTreePosition.h: * svg/SVGToOTFFontConversion.cpp: (WebCore::SVGToOTFFontConverter::Placeholder::Placeholder): (WebCore::SVGToOTFFontConverter::Placeholder::populate): (WebCore::SVGToOTFFontConverter::appendCFFTable): (WebCore::SVGToOTFFontConverter::firstGlyph const): (WebCore::SVGToOTFFontConverter::appendKERNTable): * svg/SVGTransformDistance.cpp: (WebCore::SVGTransformDistance::SVGTransformDistance): (WebCore::SVGTransformDistance::scaledDistance const): (WebCore::SVGTransformDistance::addSVGTransforms): (WebCore::SVGTransformDistance::addToSVGTransform const): (WebCore::SVGTransformDistance::distance const): * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::nativeImage): * testing/InternalSettings.cpp: * workers/service/ServiceWorkerJob.h: * worklets/PaintWorkletGlobalScope.h: (WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope): * xml/XPathStep.cpp: Source/WebKit: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::invalidateAndCancel): * NetworkProcess/NetworkSession.h: * NetworkProcess/cache/NetworkCacheStorage.cpp: (WebKit::NetworkCache::Storage::setCapacity): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (toNSURLSessionResponseDisposition): (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): * Platform/IPC/Connection.cpp: (IPC::Connection::waitForMessage): * Platform/IPC/MessageReceiver.h: (IPC::MessageReceiver::willBeAddedToMessageReceiverMap): (IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap): * Platform/IPC/cocoa/ConnectionCocoa.mm: (IPC::readFromMachPort): * Platform/mac/MachUtilities.cpp: (setMachExceptionPort): * Shared/API/APIClient.h: (API::Client::Client): * Shared/API/Cocoa/WKRemoteObjectCoder.mm: * Shared/Cocoa/ArgumentCodersCocoa.h: * Shared/SharedStringHashTableReadOnly.cpp: * UIProcess/BackingStore.cpp: (WebKit::BackingStore::incorporateUpdate): * UIProcess/GenericCallback.h: * UIProcess/Launcher/mac/ProcessLauncherMac.mm: (WebKit::ProcessLauncher::launchProcess): * UIProcess/PageLoadState.h: (WebKit::PageLoadState::Transaction::Token::Token): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::~WebPageProxy): * WebProcess/Network/WebResourceLoader.cpp: (WebKit::WebResourceLoader::didReceiveResponse): * WebProcess/Network/WebResourceLoader.h: * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp: (WebKit::NetscapePluginStream::NetscapePluginStream): (WebKit::NetscapePluginStream::notifyAndDestroyStream): * WebProcess/Plugins/Netscape/NetscapePluginStream.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runModal): * WebProcess/WebProcess.cpp: (WebKit::checkDocumentsCaptureStateConsistency): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::updateProcessName): Source/WebKitLegacy: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * Storage/StorageAreaImpl.cpp: (WebKit::StorageAreaImpl::StorageAreaImpl): (WebKit::StorageAreaImpl::close): * Storage/StorageAreaImpl.h: Source/WebKitLegacy/mac: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * History/WebHistory.mm: (-[WebHistoryPrivate removeItemForURLString:]): * WebView/WebFrame.mm: Source/WebKitLegacy/win: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * WebKitQuartzCoreAdditions/CAD3DRenderer.cpp: (WKQCA::CAD3DRenderer::swapChain): (WKQCA::CAD3DRenderer::initialize): * WebKitQuartzCoreAdditions/CAD3DRenderer.h: * WebView.cpp: (WebView::Release): * WebView.h: Source/WTF: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. This patch did the following changes: 1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away with the need for the double negative !ASSERT_DISABLED test that is commonly used all over the code, thereby improving code readability. In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED, ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents as well. We'll do that in another patch. For now, they are left as is to minimize the size of this patch. See https://bugs.webkit.org/show_bug.cgi?id=205780. 2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be guarded by "#if ASSERT_ENABLED" instead. 3. In cases where the change is minimal, we move some code around so that we can test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED". * wtf/Assertions.h: * wtf/AutomaticThread.cpp: (WTF::AutomaticThread::start): * wtf/BitVector.h: * wtf/BlockObjCExceptions.mm: (ReportBlockedObjCException): * wtf/BloomFilter.h: * wtf/CallbackAggregator.h: (WTF::CallbackAggregator::CallbackAggregator): * wtf/CheckedArithmetic.h: (WTF::observesOverflow<AssertNoOverflow>): * wtf/CheckedBoolean.h: (CheckedBoolean::CheckedBoolean): (CheckedBoolean::operator bool): * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): * wtf/DateMath.cpp: (WTF::initializeDates): * wtf/Gigacage.cpp: (Gigacage::tryAllocateZeroedVirtualPages): * wtf/HashTable.h: (WTF::KeyTraits>::checkKey): (WTF::KeyTraits>::checkTableConsistencyExceptSize const): * wtf/LoggerHelper.h: * wtf/NaturalLoops.h: (WTF::NaturalLoops::headerOf const): * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): * wtf/OptionSet.h: (WTF::OptionSet::OptionSet): * wtf/Platform.h: * wtf/PtrTag.h: * wtf/RefCounted.h: (WTF::RefCountedBase::disableThreadingChecks): (WTF::RefCountedBase::enableThreadingChecksGlobally): (WTF::RefCountedBase::RefCountedBase): (WTF::RefCountedBase::applyRefDerefThreadingCheck const): * wtf/SingleRootGraph.h: (WTF::SingleRootGraph::assertIsConsistent const): * wtf/SizeLimits.cpp: * wtf/StackBounds.h: (WTF::StackBounds::checkConsistency const): * wtf/URLParser.cpp: (WTF::URLParser::URLParser): (WTF::URLParser::domainToASCII): * wtf/ValueCheck.h: * wtf/Vector.h: (WTF::Malloc>::checkConsistency): * wtf/WeakHashSet.h: * wtf/WeakPtr.h: (WTF::WeakPtrImpl::WeakPtrImpl): (WTF::WeakPtrFactory::WeakPtrFactory): * wtf/text/AtomStringImpl.cpp: * wtf/text/AtomStringImpl.h: * wtf/text/StringBuilder.cpp: (WTF::StringBuilder::reifyString const): * wtf/text/StringBuilder.h: * wtf/text/StringCommon.h: (WTF::hasPrefixWithLettersIgnoringASCIICaseCommon): * wtf/text/StringHasher.h: (WTF::StringHasher::addCharacters): * wtf/text/StringImpl.h: * wtf/text/SymbolImpl.h: * wtf/text/UniquedStringImpl.h: Tools: Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory https://bugs.webkit.org/show_bug.cgi?id=205754 Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06 Reviewed by Youenn Fablet. * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: * WebKitTestRunner/TestController.cpp: (WTR::TestController::websiteDataStore): (WTR::TestController::platformAdjustContext): * WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::initializeWebViewConfiguration): Canonical link: https://commits.webkit.org/218957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
#if ASSERT_ENABLED
bool isConstructed() const { return m_isConstructed; }
#endif
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
private:
using PointerType = typename std::remove_const<T>::type*;
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
AtomString::init should temporarily disable checks via `isMainThread` due to WebThread's inconsistent state https://bugs.webkit.org/show_bug.cgi?id=211754 Reviewed by Dean Jackson. When starting WebThread via StartWebThread function, we have special period between the prologue of StartWebThread and spawning WebThread actually. In this period, `isMainThread()` returns false even if this is called on the main thread since WebThread is now enabled and we are not taking a WebThread lock. This causes assertion hits in MainThreadLazyNeverDestroyed initialization only in WebThread platforms. This patch takes conservative approach to fix this assertion hits: just bypass these assertions since this should not be fired. We bypass assertions by using constructWithoutAccessCheck, which intentionally skips `isMainThread()` check for construction. In non WebThread environment, we do not lose the assertion coverage since we already have ASSERT(isUIThread()). And ASSERT(isUIThread()) ensures that this is called in system main thread in WebThread platforms. Unfortunately, we have no mechanism to test this effectively. WK1 LayoutTests runner cannot show assertions since WK1 runners already initialize necessary things somewhere before calling AtomString::init() in StartWebThread. This is the same in TestWebKitAPI. For now, I manually tested that assertion does not fire. * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::constructWithoutAccessCheck): (WTF::LazyNeverDestroyed::storagePointerWithoutAccessCheck const): (WTF::LazyNeverDestroyed::storagePointer const): * wtf/text/AtomString.cpp: (WTF::AtomString::init): Canonical link: https://commits.webkit.org/224663@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 05:21:28 +00:00
PointerType storagePointerWithoutAccessCheck() const
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
{
ASSERT(m_isConstructed);
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
return const_cast<PointerType>(reinterpret_cast<const T*>(&m_storage));
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
}
AtomString::init should temporarily disable checks via `isMainThread` due to WebThread's inconsistent state https://bugs.webkit.org/show_bug.cgi?id=211754 Reviewed by Dean Jackson. When starting WebThread via StartWebThread function, we have special period between the prologue of StartWebThread and spawning WebThread actually. In this period, `isMainThread()` returns false even if this is called on the main thread since WebThread is now enabled and we are not taking a WebThread lock. This causes assertion hits in MainThreadLazyNeverDestroyed initialization only in WebThread platforms. This patch takes conservative approach to fix this assertion hits: just bypass these assertions since this should not be fired. We bypass assertions by using constructWithoutAccessCheck, which intentionally skips `isMainThread()` check for construction. In non WebThread environment, we do not lose the assertion coverage since we already have ASSERT(isUIThread()). And ASSERT(isUIThread()) ensures that this is called in system main thread in WebThread platforms. Unfortunately, we have no mechanism to test this effectively. WK1 LayoutTests runner cannot show assertions since WK1 runners already initialize necessary things somewhere before calling AtomString::init() in StartWebThread. This is the same in TestWebKitAPI. For now, I manually tested that assertion does not fire. * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::constructWithoutAccessCheck): (WTF::LazyNeverDestroyed::storagePointerWithoutAccessCheck const): (WTF::LazyNeverDestroyed::storagePointer const): * wtf/text/AtomString.cpp: (WTF::AtomString::init): Canonical link: https://commits.webkit.org/224663@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 05:21:28 +00:00
PointerType storagePointer() const
{
AccessTraits::assertAccess();
return storagePointerWithoutAccessCheck();
}
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
template<typename PtrType, bool ShouldRelax = std::is_base_of<RefCountedBase, PtrType>::value> struct MaybeRelax {
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
explicit MaybeRelax(PtrType*) { }
};
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
template<typename PtrType> struct MaybeRelax<PtrType, true> {
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
explicit MaybeRelax(PtrType* ptr) { ptr->relaxAdoptionRequirement(); }
};
PerformanceTests: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * JetStream2/wasm/HashSet.cpp: * StitchMarker/wtf/Assertions.h: * StitchMarker/wtf/DateMath.cpp: (WTF::initializeDates): * StitchMarker/wtf/HashTable.h: * StitchMarker/wtf/Hasher.h: (WTF::StringHasher::addCharacters): * StitchMarker/wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): * StitchMarker/wtf/StackBounds.h: (WTF::StackBounds::checkConsistency const): * StitchMarker/wtf/ValueCheck.h: * StitchMarker/wtf/Vector.h: (WTF::minCapacity>::checkConsistency): * StitchMarker/wtf/text/AtomicStringImpl.cpp: * StitchMarker/wtf/text/AtomicStringImpl.h: * StitchMarker/wtf/text/StringCommon.h: (WTF::hasPrefixWithLettersIgnoringASCIICaseCommon): * StitchMarker/wtf/text/StringImpl.h: * StitchMarker/wtf/text/SymbolImpl.h: * StitchMarker/wtf/text/UniquedStringImpl.h: Source/JavaScriptCore: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * API/tests/testapi.c: * assembler/ARM64Assembler.h: (JSC::ARM64Assembler::replaceWithLoad): (JSC::ARM64Assembler::replaceWithAddressComputation): * assembler/AssemblerBuffer.h: (JSC::AssemblerBuffer::LocalWriter::LocalWriter): * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::copyCompactAndLinkCode): * assembler/ProbeStack.cpp: (JSC::Probe::Stack::Stack): * assembler/ProbeStack.h: * b3/B3FoldPathConstants.cpp: * b3/B3LowerToAir.cpp: * b3/B3MemoryValue.cpp: (JSC::B3::MemoryValue::MemoryValue): * b3/B3Opcode.cpp: * b3/B3Type.h: * b3/B3TypeMap.h: * b3/B3Width.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp: (JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration): (JSC::B3::Air::GenerateAndAllocateRegisters::generate): * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirArg.cpp: * b3/air/AirArg.h: * b3/air/AirCode.h: * b3/air/AirEmitShuffle.cpp: (JSC::B3::Air::emitShuffle): * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createExecutable): * bytecode/AccessCase.cpp: * bytecode/AccessCase.h: * bytecode/CallVariant.cpp: (JSC::variantListWithVariant): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex): * bytecode/CodeBlockHash.cpp: (JSC::CodeBlockHash::dump const): * bytecode/StructureStubInfo.cpp: * bytecode/StructureStubInfo.h: * bytecompiler/NodesCodegen.cpp: (JSC::FunctionCallResolveNode::emitBytecode): * bytecompiler/RegisterID.h: (JSC::RegisterID::RegisterID): (JSC::RegisterID::setIndex): * debugger/Debugger.cpp: (JSC::Debugger::removeBreakpoint): * debugger/DebuggerEvalEnabler.h: (JSC::DebuggerEvalEnabler::DebuggerEvalEnabler): (JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions): * dfg/DFGAbstractValue.cpp: * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::merge): (JSC::DFG::AbstractValue::checkConsistency const): (JSC::DFG::AbstractValue::assertIsRegistered const): * dfg/DFGArithMode.h: (JSC::DFG::doesOverflow): * dfg/DFGBasicBlock.cpp: (JSC::DFG::BasicBlock::BasicBlock): * dfg/DFGBasicBlock.h: (JSC::DFG::BasicBlock::didLink): * dfg/DFGCFAPhase.cpp: (JSC::DFG::CFAPhase::performBlockCFA): * dfg/DFGCommon.h: (JSC::DFG::validationEnabled): * dfg/DFGCommonData.cpp: (JSC::DFG::CommonData::finalizeCatchEntrypoints): * dfg/DFGDesiredWatchpoints.h: * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGEdge.h: (JSC::DFG::Edge::makeWord): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::finalizeOSREntrypoints): * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGSSAConversionPhase.cpp: (JSC::DFG::SSAConversionPhase::run): * dfg/DFGScoreBoard.h: (JSC::DFG::ScoreBoard::assertClear): * dfg/DFGSlowPathGenerator.h: (JSC::DFG::SlowPathGenerator::generate): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCurrentBlock): (JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse): (JSC::DFG::SpeculativeJIT::emitAllocateButterfly): (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): (JSC::DFG::SpeculativeJIT::compileMakeRope): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::fillSpeculateCell): * dfg/DFGStructureAbstractValue.cpp: * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::assertIsRegistered const): * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVirtualRegisterAllocationPhase.cpp: (JSC::DFG::VirtualRegisterAllocationPhase::run): * ftl/FTLLink.cpp: (JSC::FTL::link): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::callPreflight): (JSC::FTL::DFG::LowerDFGToB3::callCheck): (JSC::FTL::DFG::LowerDFGToB3::crash): * ftl/FTLOperations.cpp: (JSC::FTL::operationMaterializeObjectInOSR): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::assertNoUnswept): * heap/GCSegmentedArray.h: (JSC::GCArraySegment::GCArraySegment): * heap/GCSegmentedArrayInlines.h: (JSC::GCSegmentedArray<T>::clear): (JSC::GCSegmentedArray<T>::expand): (JSC::GCSegmentedArray<T>::validatePrevious): * heap/HandleSet.cpp: * heap/HandleSet.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/MarkedBlock.cpp: * heap/MarkedBlock.h: (JSC::MarkedBlock::assertValidCell const): (JSC::MarkedBlock::assertMarksNotStale): * heap/MarkedSpace.cpp: (JSC::MarkedSpace::beginMarking): (JSC::MarkedSpace::endMarking): (JSC::MarkedSpace::assertNoUnswept): * heap/PreciseAllocation.cpp: * heap/PreciseAllocation.h: (JSC::PreciseAllocation::assertValidCell const): * heap/SlotVisitor.cpp: (JSC::SlotVisitor::SlotVisitor): (JSC::SlotVisitor::appendJSCellOrAuxiliary): * heap/SlotVisitor.h: * inspector/InspectorProtocolTypes.h: (Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType): * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration): (CppProtocolTypesImplementationGenerator): (CppProtocolTypesImplementationGenerator._generate_assertion_for_enum): * inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result: * interpreter/FrameTracers.h: (JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer): * interpreter/Interpreter.cpp: (JSC::Interpreter::Interpreter): * interpreter/Interpreter.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::prepareCallOperation): * jit/BinarySwitch.cpp: (JSC::BinarySwitch::BinarySwitch): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupStubArgs): * jit/CallFrameShuffler.cpp: (JSC::CallFrameShuffler::emitDeltaCheck): (JSC::CallFrameShuffler::prepareAny): * jit/JIT.cpp: (JSC::JIT::assertStackPointerOffset): (JSC::JIT::compileWithoutLinking): * jit/JITOpcodes.cpp: (JSC::JIT::emitSlow_op_loop_hint): * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_from_scope): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_get_from_scope): * jit/Repatch.cpp: (JSC::linkPolymorphicCall): * jit/ThunkGenerators.cpp: (JSC::emitPointerValidation): * llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): * llint/LLIntOfflineAsmConfig.h: * parser/Lexer.cpp: * parser/Lexer.h: (JSC::isSafeBuiltinIdentifier): (JSC::Lexer<T>::lexExpectIdentifier): * runtime/ArgList.h: (JSC::MarkedArgumentBuffer::setNeedsOverflowCheck): (JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck): * runtime/Butterfly.h: (JSC::ContiguousData::ContiguousData): (JSC::ContiguousData::Data::Data): * runtime/HashMapImpl.h: (JSC::HashMapImpl::checkConsistency const): (JSC::HashMapImpl::assertBufferIsEmpty const): * runtime/JSCellInlines.h: (JSC::JSCell::methodTable const): * runtime/JSFunction.cpp: * runtime/JSFunction.h: (JSC::JSFunction::assertTypeInfoFlagInvariants): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSObject.cpp: (JSC::JSObject::visitChildren): (JSC::JSFinalObject::visitChildren): * runtime/JSObjectInlines.h: (JSC::JSObject::validatePutOwnDataProperty): * runtime/JSSegmentedVariableObject.h: (JSC::JSSegmentedVariableObject::assertVariableIsInThisObject): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::Lexer::lex): * runtime/LiteralParser.h: * runtime/Operations.h: (JSC::scribbleFreeCells): * runtime/OptionsList.h: * runtime/VM.cpp: (JSC::VM::computeCanUseJIT): * runtime/VM.h: (JSC::VM::canUseJIT): * runtime/VarOffset.h: (JSC::VarOffset::checkSanity const): * runtime/WeakMapImpl.h: (JSC::WeakMapImpl::checkConsistency const): (JSC::WeakMapImpl::assertBufferIsEmpty const): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::validateInst): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::parseAndCompile): * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser::validationFail const): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::checkConsistency): * wasm/WasmPlan.cpp: (JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast): * wasm/WasmSectionParser.h: * wasm/WasmSections.h: * wasm/WasmSignatureInlines.h: (JSC::Wasm::SignatureInformation::get): * wasm/WasmWorklist.cpp: (JSC::Wasm::Worklist::enqueue): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::previousInstanceOffset const): Source/WebCore: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * Modules/fetch/FetchBodySource.cpp: (WebCore::FetchBodySource::close): * Modules/fetch/FetchBodySource.h: * Modules/webdatabase/DatabaseDetails.h: (WebCore::DatabaseDetails::DatabaseDetails): (WebCore::DatabaseDetails::operator=): * Modules/webdatabase/DatabaseTask.cpp: (WebCore::DatabaseTask::performTask): * Modules/webdatabase/DatabaseTask.h: * Modules/webdatabase/DatabaseThread.cpp: (WebCore::DatabaseThread::terminationRequested const): * Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h: (WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation): * Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp: (WebCore::WHLSL::findHighZombies): * Modules/webgpu/WHLSL/WHLSLInferTypes.cpp: (WebCore::WHLSL::matches): * Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp: (WebCore::WHLSL::checkLiteralTypes): * Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp: (WebCore::WHLSL::FindAllTypes::appendNamedType): * bindings/js/JSCallbackData.h: * bindings/js/JSLazyEventListener.cpp: * bindings/js/JSLazyEventListener.h: * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * css/CSSCalculationValue.cpp: (WebCore::CSSCalcOperationNode::primitiveType const): * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): * css/CSSPrimitiveValue.cpp: * css/CSSSelector.cpp: (WebCore::CSSSelector::selectorText const): * css/CSSStyleSheet.cpp: * dom/ActiveDOMObject.cpp: (WebCore::ActiveDOMObject::suspendIfNeeded): (WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const): * dom/ActiveDOMObject.h: * dom/ContainerNode.cpp: * dom/ContainerNodeAlgorithms.cpp: * dom/ContainerNodeAlgorithms.h: * dom/CustomElementReactionQueue.cpp: * dom/CustomElementReactionQueue.h: (WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope): (WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope): * dom/Document.cpp: (WebCore::Document::hitTest): * dom/Document.h: (WebCore::Document::decrementReferencingNodeCount): * dom/Element.cpp: (WebCore::Element::addShadowRoot): (WebCore::Element::getURLAttribute const): (WebCore::Element::getNonEmptyURLAttribute const): * dom/Element.h: * dom/ElementAndTextDescendantIterator.h: (WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator): (WebCore::ElementAndTextDescendantIterator::dropAssertions): (WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack): (WebCore::ElementAndTextDescendantIterator::traverseNextSibling): (WebCore::ElementAndTextDescendantIterator::traversePreviousSibling): * dom/ElementDescendantIterator.h: (WebCore::ElementDescendantIterator::ElementDescendantIterator): (WebCore::ElementDescendantIterator::dropAssertions): (WebCore::ElementDescendantIterator::operator++): (WebCore::ElementDescendantIterator::operator--): (WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator): (WebCore::ElementDescendantConstIterator::dropAssertions): (WebCore::ElementDescendantConstIterator::operator++): * dom/ElementIterator.h: (WebCore::ElementIterator<ElementType>::ElementIterator): (WebCore::ElementIterator<ElementType>::traverseNext): (WebCore::ElementIterator<ElementType>::traversePrevious): (WebCore::ElementIterator<ElementType>::traverseNextSibling): (WebCore::ElementIterator<ElementType>::traversePreviousSibling): (WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren): (WebCore::ElementIterator<ElementType>::dropAssertions): (WebCore::ElementIterator<ElementType>::traverseAncestor): (WebCore::ElementConstIterator<ElementType>::ElementConstIterator): (WebCore::ElementConstIterator<ElementType>::traverseNext): (WebCore::ElementConstIterator<ElementType>::traversePrevious): (WebCore::ElementConstIterator<ElementType>::traverseNextSibling): (WebCore::ElementConstIterator<ElementType>::traversePreviousSibling): (WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren): (WebCore::ElementConstIterator<ElementType>::traverseAncestor): (WebCore::ElementConstIterator<ElementType>::dropAssertions): * dom/EventContext.cpp: * dom/EventContext.h: * dom/EventListener.h: * dom/EventPath.cpp: * dom/EventSender.h: * dom/EventTarget.cpp: (WebCore::EventTarget::addEventListener): (WebCore::EventTarget::setAttributeEventListener): (WebCore::EventTarget::innerInvokeEventListeners): * dom/Node.cpp: (WebCore::Node::~Node): (WebCore::Node::moveNodeToNewDocument): (WebCore::Node::removedLastRef): * dom/Node.h: (WebCore::Node::deref const): * dom/ScriptDisallowedScope.h: (WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::~ScriptExecutionContext): * dom/ScriptExecutionContext.h: * dom/SelectorQuery.cpp: (WebCore::SelectorDataList::execute const): * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::addSlotElementByName): (WebCore::SlotAssignment::removeSlotElementByName): (WebCore::SlotAssignment::resolveSlotsAfterSlotMutation): (WebCore::SlotAssignment::findFirstSlotElement): * dom/SlotAssignment.h: * dom/TreeScopeOrderedMap.cpp: (WebCore::TreeScopeOrderedMap::add): (WebCore::TreeScopeOrderedMap::get const): * dom/TreeScopeOrderedMap.h: * fileapi/Blob.cpp: * fileapi/Blob.h: * history/BackForwardCache.cpp: (WebCore::BackForwardCache::removeAllItemsForPage): * history/BackForwardCache.h: * html/CanvasBase.cpp: (WebCore::CanvasBase::notifyObserversCanvasDestroyed): * html/CanvasBase.h: * html/HTMLCollection.h: (WebCore::CollectionNamedElementCache::didPopulate): * html/HTMLSelectElement.cpp: (WebCore:: const): * html/HTMLTableRowsCollection.cpp: (WebCore::assertRowIsInTable): * html/HTMLTextFormControlElement.cpp: (WebCore::HTMLTextFormControlElement::indexForPosition const): * html/canvas/CanvasRenderingContext2DBase.cpp: (WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase): * html/parser/HTMLParserScheduler.cpp: (WebCore::HTMLParserScheduler::HTMLParserScheduler): (WebCore::HTMLParserScheduler::suspend): (WebCore::HTMLParserScheduler::resume): * html/parser/HTMLParserScheduler.h: * html/parser/HTMLToken.h: (WebCore::HTMLToken::beginStartTag): (WebCore::HTMLToken::beginEndTag): (WebCore::HTMLToken::endAttribute): * html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): (WebCore::HTMLTreeBuilder::constructTree): * html/parser/HTMLTreeBuilder.h: (WebCore::HTMLTreeBuilder::~HTMLTreeBuilder): * layout/FormattingContext.cpp: (WebCore::Layout::FormattingContext::geometryForBox const): * layout/blockformatting/BlockFormattingContext.cpp: (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition): * layout/blockformatting/BlockFormattingContext.h: * layout/displaytree/DisplayBox.cpp: (WebCore::Display::Box::Box): * layout/displaytree/DisplayBox.h: (WebCore::Display::Box::setTopLeft): (WebCore::Display::Box::setTop): (WebCore::Display::Box::setLeft): (WebCore::Display::Box::setContentBoxHeight): (WebCore::Display::Box::setContentBoxWidth): (WebCore::Display::Box::setHorizontalMargin): (WebCore::Display::Box::setVerticalMargin): (WebCore::Display::Box::setHorizontalComputedMargin): (WebCore::Display::Box::setBorder): (WebCore::Display::Box::setPadding): * layout/displaytree/DisplayInlineRect.h: (WebCore::Display::InlineRect::InlineRect): (WebCore::Display::InlineRect::setTopLeft): (WebCore::Display::InlineRect::setTop): (WebCore::Display::InlineRect::setBottom): (WebCore::Display::InlineRect::setLeft): (WebCore::Display::InlineRect::setWidth): (WebCore::Display::InlineRect::setHeight): * layout/displaytree/DisplayLineBox.h: (WebCore::Display::LineBox::LineBox): (WebCore::Display::LineBox::setBaselineOffsetIfGreater): (WebCore::Display::LineBox::resetBaseline): (WebCore::Display::LineBox::Baseline::Baseline): (WebCore::Display::LineBox::Baseline::setAscent): (WebCore::Display::LineBox::Baseline::setDescent): (WebCore::Display::LineBox::Baseline::reset): * layout/displaytree/DisplayRect.h: (WebCore::Display::Rect::Rect): (WebCore::Display::Rect::setTopLeft): (WebCore::Display::Rect::setTop): (WebCore::Display::Rect::setLeft): (WebCore::Display::Rect::setWidth): (WebCore::Display::Rect::setHeight): (WebCore::Display::Rect::setSize): (WebCore::Display::Rect::clone const): * layout/floats/FloatingContext.cpp: * layout/inlineformatting/InlineLineBuilder.cpp: (WebCore::Layout::LineBuilder::CollapsibleContent::collapse): * layout/tableformatting/TableGrid.cpp: (WebCore::Layout::TableGrid::Column::setWidthConstraints): (WebCore::Layout::TableGrid::Column::setLogicalWidth): (WebCore::Layout::TableGrid::Column::setLogicalLeft): * layout/tableformatting/TableGrid.h: * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::continueAfterContentPolicy): (WebCore::DocumentLoader::attachToFrame): (WebCore::DocumentLoader::detachFromFrame): (WebCore::DocumentLoader::addSubresourceLoader): * loader/DocumentLoader.h: * loader/ImageLoader.cpp: * loader/cache/CachedResource.h: * loader/cache/MemoryCache.cpp: (WebCore::MemoryCache::lruListFor): (WebCore::MemoryCache::removeFromLRUList): * page/FrameView.cpp: (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive): * page/FrameViewLayoutContext.cpp: * page/FrameViewLayoutContext.h: * page/Page.cpp: * page/Page.h: * page/ViewportConfiguration.cpp: * page/ViewportConfiguration.h: * page/mac/EventHandlerMac.mm: (WebCore::CurrentEventScope::CurrentEventScope): * platform/DateComponents.cpp: (WebCore::DateComponents::toStringForTime const): * platform/ScrollableArea.cpp: * platform/SharedBuffer.cpp: (WebCore::SharedBuffer::combineIntoOneSegment const): * platform/SharedBuffer.h: * platform/Supplementable.h: * platform/Timer.cpp: (WebCore::TimerBase::checkHeapIndex const): (WebCore::TimerBase::updateHeapIfNeeded): * platform/graphics/BitmapImage.cpp: * platform/graphics/BitmapImage.h: * platform/graphics/Image.h: * platform/graphics/ShadowBlur.cpp: (WebCore::ScratchBuffer::ScratchBuffer): (WebCore::ScratchBuffer::getScratchBuffer): (WebCore::ScratchBuffer::scheduleScratchBufferPurge): * platform/graphics/ca/win/CACFLayerTreeHost.cpp: (WebCore::CACFLayerTreeHost::setWindow): * platform/graphics/ca/win/CACFLayerTreeHost.h: * platform/graphics/cg/ImageBufferDataCG.cpp: (WebCore::ImageBufferData::putData): * platform/graphics/cocoa/FontCacheCoreText.cpp: * platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp: (gstAllocatorFastMallocFree): * platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp: (Nicosia::PaintingContextCairo::ForPainting::ForPainting): * platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp: (Nicosia::BackingStoreTextureMapperImpl::createTile): * platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp: (Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl): * platform/graphics/win/GradientDirect2D.cpp: (WebCore::Gradient::fill): * platform/graphics/win/ImageBufferDataDirect2D.cpp: (WebCore::ImageBufferData::putData): * platform/graphics/win/PathDirect2D.cpp: (WebCore::Path::appendGeometry): (WebCore::Path::Path): (WebCore::Path::operator=): (WebCore::Path::strokeContains const): (WebCore::Path::transform): * platform/graphics/win/PlatformContextDirect2D.cpp: (WebCore::PlatformContextDirect2D::setTags): * platform/mediastream/MediaStreamTrackPrivate.h: * platform/mediastream/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource): * platform/mediastream/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource): * platform/network/HTTPParsers.cpp: (WebCore::isCrossOriginSafeHeader): * platform/sql/SQLiteDatabase.cpp: * platform/sql/SQLiteDatabase.h: * platform/sql/SQLiteStatement.cpp: (WebCore::SQLiteStatement::SQLiteStatement): (WebCore::SQLiteStatement::prepare): (WebCore::SQLiteStatement::finalize): * platform/sql/SQLiteStatement.h: * platform/win/COMPtr.h: * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::removeInlineBox const): * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::FloatingObject): (WebCore::FloatingObjects::addPlacedObject): (WebCore::FloatingObjects::removePlacedObject): * rendering/FloatingObjects.h: * rendering/GridTrackSizingAlgorithm.cpp: * rendering/GridTrackSizingAlgorithm.h: * rendering/LayoutDisallowedScope.cpp: * rendering/LayoutDisallowedScope.h: * rendering/RenderBlock.cpp: * rendering/RenderBlock.h: * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::layoutBlockChild): (WebCore::RenderBlockFlow::removeFloatingObject): (WebCore::RenderBlockFlow::ensureLineBoxes): * rendering/RenderBoxModelObject.cpp: * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::layoutBlock): * rendering/RenderElement.cpp: * rendering/RenderGeometryMap.cpp: (WebCore::RenderGeometryMap::mapToContainer const): * rendering/RenderGrid.cpp: (WebCore::RenderGrid::placeItemsOnGrid const): (WebCore::RenderGrid::baselinePosition const): * rendering/RenderInline.cpp: (WebCore::RenderInline::willBeDestroyed): * rendering/RenderLayer.cpp: (WebCore::ClipRectsCache::ClipRectsCache): (WebCore::RenderLayer::RenderLayer): (WebCore::RenderLayer::paintList): (WebCore::RenderLayer::hitTestLayer): (WebCore::RenderLayer::updateClipRects): (WebCore::RenderLayer::calculateClipRects const): * rendering/RenderLayer.h: * rendering/RenderLayerBacking.cpp: (WebCore::traverseVisibleNonCompositedDescendantLayers): * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::computeCompositingRequirements): (WebCore::RenderLayerCompositor::traverseUnchangedSubtree): (WebCore::RenderLayerCompositor::updateBackingAndHierarchy): (WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const): (WebCore::RenderLayerCompositor::recursiveRepaintLayer): (WebCore::RenderLayerCompositor::layerHas3DContent const): * rendering/RenderLayoutState.cpp: (WebCore::RenderLayoutState::RenderLayoutState): (WebCore::RenderLayoutState::computeOffsets): (WebCore::RenderLayoutState::addLayoutDelta): * rendering/RenderLayoutState.h: (WebCore::RenderLayoutState::RenderLayoutState): * rendering/RenderObject.cpp: (WebCore::RenderObject::RenderObject): (WebCore::RenderObject::~RenderObject): (WebCore::RenderObject::clearNeedsLayout): * rendering/RenderObject.h: * rendering/RenderQuote.cpp: (WebCore::quotesForLanguage): * rendering/RenderTableCell.h: * rendering/RenderTableSection.cpp: (WebCore::RenderTableSection::computeOverflowFromCells): * rendering/RenderTextLineBoxes.cpp: (WebCore::RenderTextLineBoxes::checkConsistency const): * rendering/RenderTextLineBoxes.h: * rendering/line/BreakingContext.h: (WebCore::tryHyphenating): * rendering/style/GridArea.h: (WebCore::GridSpan::GridSpan): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::~RenderStyle): * rendering/style/RenderStyle.h: * rendering/updating/RenderTreeBuilderRuby.cpp: (WebCore::RenderTreeBuilder::Ruby::detach): * rendering/updating/RenderTreePosition.cpp: (WebCore::RenderTreePosition::computeNextSibling): * rendering/updating/RenderTreePosition.h: * svg/SVGToOTFFontConversion.cpp: (WebCore::SVGToOTFFontConverter::Placeholder::Placeholder): (WebCore::SVGToOTFFontConverter::Placeholder::populate): (WebCore::SVGToOTFFontConverter::appendCFFTable): (WebCore::SVGToOTFFontConverter::firstGlyph const): (WebCore::SVGToOTFFontConverter::appendKERNTable): * svg/SVGTransformDistance.cpp: (WebCore::SVGTransformDistance::SVGTransformDistance): (WebCore::SVGTransformDistance::scaledDistance const): (WebCore::SVGTransformDistance::addSVGTransforms): (WebCore::SVGTransformDistance::addToSVGTransform const): (WebCore::SVGTransformDistance::distance const): * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::nativeImage): * testing/InternalSettings.cpp: * workers/service/ServiceWorkerJob.h: * worklets/PaintWorkletGlobalScope.h: (WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope): * xml/XPathStep.cpp: Source/WebKit: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::invalidateAndCancel): * NetworkProcess/NetworkSession.h: * NetworkProcess/cache/NetworkCacheStorage.cpp: (WebKit::NetworkCache::Storage::setCapacity): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (toNSURLSessionResponseDisposition): (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): * Platform/IPC/Connection.cpp: (IPC::Connection::waitForMessage): * Platform/IPC/MessageReceiver.h: (IPC::MessageReceiver::willBeAddedToMessageReceiverMap): (IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap): * Platform/IPC/cocoa/ConnectionCocoa.mm: (IPC::readFromMachPort): * Platform/mac/MachUtilities.cpp: (setMachExceptionPort): * Shared/API/APIClient.h: (API::Client::Client): * Shared/API/Cocoa/WKRemoteObjectCoder.mm: * Shared/Cocoa/ArgumentCodersCocoa.h: * Shared/SharedStringHashTableReadOnly.cpp: * UIProcess/BackingStore.cpp: (WebKit::BackingStore::incorporateUpdate): * UIProcess/GenericCallback.h: * UIProcess/Launcher/mac/ProcessLauncherMac.mm: (WebKit::ProcessLauncher::launchProcess): * UIProcess/PageLoadState.h: (WebKit::PageLoadState::Transaction::Token::Token): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::~WebPageProxy): * WebProcess/Network/WebResourceLoader.cpp: (WebKit::WebResourceLoader::didReceiveResponse): * WebProcess/Network/WebResourceLoader.h: * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp: (WebKit::NetscapePluginStream::NetscapePluginStream): (WebKit::NetscapePluginStream::notifyAndDestroyStream): * WebProcess/Plugins/Netscape/NetscapePluginStream.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runModal): * WebProcess/WebProcess.cpp: (WebKit::checkDocumentsCaptureStateConsistency): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::updateProcessName): Source/WebKitLegacy: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * Storage/StorageAreaImpl.cpp: (WebKit::StorageAreaImpl::StorageAreaImpl): (WebKit::StorageAreaImpl::close): * Storage/StorageAreaImpl.h: Source/WebKitLegacy/mac: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * History/WebHistory.mm: (-[WebHistoryPrivate removeItemForURLString:]): * WebView/WebFrame.mm: Source/WebKitLegacy/win: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. * WebKitQuartzCoreAdditions/CAD3DRenderer.cpp: (WKQCA::CAD3DRenderer::swapChain): (WKQCA::CAD3DRenderer::initialize): * WebKitQuartzCoreAdditions/CAD3DRenderer.h: * WebView.cpp: (WebView::Release): * WebView.h: Source/WTF: Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED. https://bugs.webkit.org/show_bug.cgi?id=205776 Reviewed by Saam Barati. This patch did the following changes: 1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away with the need for the double negative !ASSERT_DISABLED test that is commonly used all over the code, thereby improving code readability. In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED, ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents as well. We'll do that in another patch. For now, they are left as is to minimize the size of this patch. See https://bugs.webkit.org/show_bug.cgi?id=205780. 2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be guarded by "#if ASSERT_ENABLED" instead. 3. In cases where the change is minimal, we move some code around so that we can test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED". * wtf/Assertions.h: * wtf/AutomaticThread.cpp: (WTF::AutomaticThread::start): * wtf/BitVector.h: * wtf/BlockObjCExceptions.mm: (ReportBlockedObjCException): * wtf/BloomFilter.h: * wtf/CallbackAggregator.h: (WTF::CallbackAggregator::CallbackAggregator): * wtf/CheckedArithmetic.h: (WTF::observesOverflow<AssertNoOverflow>): * wtf/CheckedBoolean.h: (CheckedBoolean::CheckedBoolean): (CheckedBoolean::operator bool): * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): * wtf/DateMath.cpp: (WTF::initializeDates): * wtf/Gigacage.cpp: (Gigacage::tryAllocateZeroedVirtualPages): * wtf/HashTable.h: (WTF::KeyTraits>::checkKey): (WTF::KeyTraits>::checkTableConsistencyExceptSize const): * wtf/LoggerHelper.h: * wtf/NaturalLoops.h: (WTF::NaturalLoops::headerOf const): * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): * wtf/OptionSet.h: (WTF::OptionSet::OptionSet): * wtf/Platform.h: * wtf/PtrTag.h: * wtf/RefCounted.h: (WTF::RefCountedBase::disableThreadingChecks): (WTF::RefCountedBase::enableThreadingChecksGlobally): (WTF::RefCountedBase::RefCountedBase): (WTF::RefCountedBase::applyRefDerefThreadingCheck const): * wtf/SingleRootGraph.h: (WTF::SingleRootGraph::assertIsConsistent const): * wtf/SizeLimits.cpp: * wtf/StackBounds.h: (WTF::StackBounds::checkConsistency const): * wtf/URLParser.cpp: (WTF::URLParser::URLParser): (WTF::URLParser::domainToASCII): * wtf/ValueCheck.h: * wtf/Vector.h: (WTF::Malloc>::checkConsistency): * wtf/WeakHashSet.h: * wtf/WeakPtr.h: (WTF::WeakPtrImpl::WeakPtrImpl): (WTF::WeakPtrFactory::WeakPtrFactory): * wtf/text/AtomStringImpl.cpp: * wtf/text/AtomStringImpl.h: * wtf/text/StringBuilder.cpp: (WTF::StringBuilder::reifyString const): * wtf/text/StringBuilder.h: * wtf/text/StringCommon.h: (WTF::hasPrefixWithLettersIgnoringASCIICaseCommon): * wtf/text/StringHasher.h: (WTF::StringHasher::addCharacters): * wtf/text/StringImpl.h: * wtf/text/SymbolImpl.h: * wtf/text/UniquedStringImpl.h: Tools: Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory https://bugs.webkit.org/show_bug.cgi?id=205754 Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06 Reviewed by Youenn Fablet. * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: * WebKitTestRunner/TestController.cpp: (WTR::TestController::websiteDataStore): (WTR::TestController::platformAdjustContext): * WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::initializeWebViewConfiguration): Canonical link: https://commits.webkit.org/218957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
#if ASSERT_ENABLED
// LazyNeverDestroyed objects are always static, so this variable is initialized to false.
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
// It must not be initialized dynamically; that would not be thread safe.
bool m_isConstructed;
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
#endif
// FIXME: Investigate whether we should allocate a hunk of virtual memory
// and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_storage;
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
};
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
template<typename T, typename AccessTraits> inline NeverDestroyed<T, AccessTraits> makeNeverDestroyed(T&& argument)
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
{
return std::forward<T>(argument);
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
}
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
template<typename T>
using MainThreadNeverDestroyed = NeverDestroyed<T, MainThreadAccessTraits>;
template<typename T>
using MainThreadLazyNeverDestroyed = LazyNeverDestroyed<T, MainThreadAccessTraits>;
} // namespace WTF;
Add a LazyNeverDestroyed class template and use it https://bugs.webkit.org/show_bug.cgi?id=133425 Reviewed by Darin Adler. Source/JavaScriptCore: * dfg/DFGFunctionWhitelist.cpp: (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): * dfg/DFGFunctionWhitelist.h: Source/WebCore: * Modules/webdatabase/DatabaseBackendBase.cpp: (WebCore::guidMutex): * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::registryMutex): * inspector/WorkerDebuggerAgent.cpp: * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): * platform/network/NetworkStateNotifier.cpp: (WebCore::networkStateNotifier): * workers/DefaultSharedWorkerRepository.cpp: (WebCore::DefaultSharedWorkerRepository::instance): * workers/DefaultSharedWorkerRepository.h: * workers/WorkerThread.cpp: (WebCore::threadSetMutex): * xml/XMLHttpRequest.cpp: (WebCore::staticData): Source/WebKit2: * Shared/mac/SecItemShim.cpp: (WebKit::responseMap): Source/WTF: LazyNeverDestroyed is similar to NeverDestroyed, except it's lazily constructed by calling construct(). This makes it useful for using inside std::call_once functions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::operator T&): (WTF::LazyNeverDestroyed::get): (WTF::LazyNeverDestroyed::asPtr): (WTF::LazyNeverDestroyed::MaybeRelax::MaybeRelax): * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: (WTF::atomicallyInitializedStaticMutex): * wtf/unicode/icu/CollatorICU.cpp: (WTF::cachedCollatorMutex): Canonical link: https://commits.webkit.org/151458@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-01 22:31:13 +00:00
using WTF::LazyNeverDestroyed;
using WTF::NeverDestroyed;
Improve use of NeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=174348 Reviewed by Sam Weinig. Source/JavaScriptCore: * heap/MachineStackMarker.cpp: * wasm/WasmMemory.cpp: Removed unneeded includes of NeverDestroyed.h in files that do not make use of NeverDestroyed. Source/WebCore: * Modules/encryptedmedia/MediaKeySession.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/encryptedmedia/legacy/LegacyCDM.cpp: (WebCore::installedCDMFactories): Use makeNeverDestroyed and a lambda rather than a separate boolean for initialization. * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: (WebCore::clearKeyVM): Removed unneeded use of NeverDestroyed to hold a RefPtr. Simple to just use leakRef instead. * Modules/gamepad/GamepadManager.cpp: Added an include of NeverDestroyed.h. * Modules/indexeddb/IDBTransaction.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/indexeddb/server/MemoryObjectStore.cpp: Ditto. * Modules/mediasession/MediaSessionManager.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasession/MediaSessionManager.h: ... from here. * Modules/mediasource/MediaSourceRegistry.cpp: Moved include of NeverDestroyed.h here ... * Modules/mediasource/MediaSourceRegistry.h: ... from here. * Modules/mediasource/SourceBuffer.cpp: Removed unneeded include of NeverDestroyed.h. * Modules/plugins/QuickTimePluginReplacement.h: Initialize m_scriptObject in the class definition. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::supportsMimeType): Use makeNeverDestroyed and the HashSet constructor instead of a loop. (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto. (WebCore::QuickTimePluginReplacement::QuickTimePluginReplacement): Did a slight cleanup of the initializers. (WebCore::QuickTimePluginReplacement::~QuickTimePluginReplacement): Added a FIXME; unclear why there is code here at all. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::inheritsPresentationalRole): Use makeNeverDestroyed and the Vector constructor instead of using empty vector checks and Vector::add. Use std::any_of rather than Vector::contains since we now are matching against pointers. * bindings/scripts/CodeGeneratorJS.pm: (GenerateEnumerationImplementationContent): Use const NeverDestroyed. * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Regenerated. * css/CSSProperty.cpp: (WebCore::borderDirections): Removed unnecesssary use of NeverDestroyed for a global object that has a trivial destructor. * css/ElementRuleCollector.cpp: (WebCore::leftToRightDeclaration): Removed unneeded use of NeverDestroyed to hold a Ref. Simple to just use leakRef instead. Also use a lambda instead of an explicit isEmpty check each time this is called. (WebCore::rightToLeftDeclaration): Ditto. * css/makeprop.pl: Removed unneeded include of NeverDestroyed.h and the uneeded global emptyShorthand. Constructing an empty StylePropertyShorthand is no less efficient than copying a global empty one was. * dom/CustomElementReactionQueue.cpp: Added an include of NeverDestroyed.h. * dom/DOMImplementation.cpp: Removed unneeded include of NeverDestroyed.h. * dom/InputEvent.cpp: Ditto. * dom/Microtasks.cpp: Moved include of NeverDestroyed.h here ... * dom/Microtasks.h: ... from here. * dom/MutationObserver.cpp: Added an include of NeverDestroyed.h. * dom/ScopedEventQueue.cpp: Moved include of NeverDestroyed.h here ... * dom/ScopedEventQueue.h: ... from here. Added Forward.h. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use makeNeverDestroyed and the HashSet constructor rather than an isEmpty check and a lot of add function calls. Also removed comments that don't have value any more, with dubious no longer relevant claims about the behavior of old web browsers. The function that calls this one already has sufficient comments about why we hope some day this function can be eliminated. * dom/SecurityContext.cpp: Removed unneeded include of NeverDestroyed.h. * dom/make_names.pl: (printFactoryCppFile): Instead of using a "populate" function, use a function that creates as HashMap. Then use const auto and makeNeverDestroyed. (printWrapperFactoryCppFile): Ditto. * editing/AlternativeTextController.cpp: (WebCore::markerTypesForAutocorrection): Use makeNeverDestroyed and the Vector constructor rather than an isEmpty check and a lot of append function calls. (WebCore::markerTypesForReplacement): Ditto. (WebCore::markerTypesForAppliedDictationAlternative): Ditto. * editing/EditingStyle.cpp: (WebCore::htmlElementEquivalents): Use const auto, makeNeverDestroyed, the Vector constructor, and new rather than make_unique. Changed return type to use const pointers rather than unique_ptr with non-const type. (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement): Updated for the above change to htmlElementEquivalents. (WebCore::htmlAttributeEquivalents): Same approach as above. (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes): Ditto. (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl): Take references instead of pointers. (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement): Updated for the above. * editing/FormatBlockCommand.cpp: (WebCore::isElementForFormatBlock): Use const auto, makeNeverDestroyed, and the HashSet constructor rather than isEmpty and a lot of calls to add. * editing/RemoveFormatCommand.cpp: (WebCore::isElementForRemoveFormatCommand): Ditto. * editing/ReplaceSelectionCommand.cpp: (WebCore::isProhibitedParagraphChild): Use const auto, makeNeverDestroyed, and a lambda, rather than isEmpty and a lot of calls to add. * html/Autofill.cpp: (WebCore::fieldNameMap): Changed return type to be const. Use const auto, makeNeverDestroyed, a lambda, and an array of values rather than isEmpty and a lot of calls to add. Stopped doing the ConstructFromLiteral optimization here. (Easy to add it back if that is a mistake.) * html/HTMLObjectElement.cpp: (WebCore::isRecognizedTagName): Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty. * html/HTMLStyleElement.cpp: Added include of NeverDestroyed.h. * html/HTMLVideoElement.cpp: Removed uneeded include of NeverDestroyed.h. * html/InputType.cpp: (WebCore::createInputTypeFactoryMap): Replaced the populate function with this create function. (WebCore::InputType::create): Use const auto and makeNeverDestroyed istead of isEmpty. Also put the map right where it is used so it's not initialized in code path where not needed. * html/parser/HTMLParserIdioms.cpp: Removed uneeded include of NeverDestroyed.h. * inspector/InspectorApplicationCacheAgent.cpp: (WebCore::InspectorApplicationCacheAgent::networkStateChanged): Merged into a single line. * loader/ContentFilter.cpp: (WebCore::blockedPageURL): Use const auto and makeNeverDestroyed rather than std::call_once. Since this is a URL and has a non-thread-safe reference count, this was not thread safe before, so no need to use the more roundabout and less efficient idiom for its thread safety. * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlResponseHeaderWhitelist): Deleted. * loader/CrossOriginAccessControl.h: Deleted unused function isOnAccessControlResponseHeaderWhitelist. * loader/EmptyClients.cpp: Use leakRef instead of NeverDestroyed<Ref>. * loader/appcache/ApplicationCacheStorage.cpp: Removed unneeded include of NeverDestroyed.h. * page/CaptionUserPreferences.cpp: Ditto. * page/DebugPageOverlays.cpp: (WebCore::touchEventRegionColors): Changed the return type to const, since the callers do not modify the map. Use const auto, makeNeverDestroyed, and a lambda rather than isEmpty and repeated calls to add. * page/MainFrame.cpp: Removed unneeded include of NeverDestroyed.h. * page/MemoryRelease.cpp: (WebCore::releaseMemory): Use a function directly instead of calling it inside a lambda. * page/NavigatorBase.cpp: (WebCore::NavigatorBase::onLine): Updated to call NetworkStateNotifier::singleton. * page/Page.cpp: (WebCore::allPages): Made this a function instead of a global to use the normal idiom for such globals. (WebCore::Page::forEachPage): Updated for change to allPages. (WebCore::networkStateChanged): Ditto. Also removed a bit of unnecessary churn by using const AtomicString& instead of AtomicString. (WebCore::Page::Page): Moved initialization of most data members to the class definition. Removed initialiation of allPages. Updated the use of NetworkStateNotifier for its new slightly changed interface. (WebCore::Page::~Page): Updated for change to allPages. (WebCore::Page::clearPreviousItemFromAllPages): Ditto. (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Ditto. (WebCore::Page::refreshPlugins): Ditto. * page/Page.h: Moved initialization of most data members here. * page/PerformanceUserTiming.cpp: Removed many unneded includes. (WebCore::restrictedMarkFunction): Use const auto, makeNeverDestroyed, and a lambda instead of isEmpty. Also use an array rather than std::array and got rid fo the unneeded use of anonymous namespace since this is fine in the top level WebCore namespace. (WebCore::clearPerformanceEntries): Tweaked coding style. (WebCore::UserTiming::mark): Ditto. (WebCore::UserTiming::findExistingMarkStartTime): Got rid of double hash table lookup by using find instead of using contains followed by get. removed unneeded explicit cast to double. Tweaked coding style. (WebCore::convertToEntrySequence): Tweaked coding style. (WebCore::getEntrySequenceByName): Deleted. (WebCore::UserTiming::getMarks): Call get directly instead of getEntrySequenceByName. (WebCore::UserTiming::getMeasures): Ditto. * page/RuntimeEnabledFeatures.cpp: Moved include of NeverDestroyed.h here ... * page/RuntimeEnabledFeatures.h: ... from here. Added Forward.h and Noncopyable.h. * platform/LocalizedStrings.cpp: Removed unneeded include of NeverDestroyed.h. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Added a missing const for a global constant array. (WebCore::initializeSupportedJavaScriptMIMETypes): Ditto. (WebCore::initializeSupportedNonImageMimeTypes): Ditto. (WebCore::typesForCommonExtension): Replaced the old mediaMIMETypeMap function with this one. Moved the common media types array here since it's only used here. Use const auto, makeNeverDestroyed, and a lambda instead of using an isEmpty check. Iterate the array using a mdoern for loop. Use HashMap::ensure to avoid the double hashing that the old code was doing. And moved the code to find an entry in the map in here from the client functions. (WebCore::MIMETypeRegistry::getMediaMIMETypeForExtension): Updated to use the typesForCommonExtension, and changed logic to use this first, and only call getMIMETypeForExtension for extensions not in the map. This gives the same result but should be slightly more efficient. (WebCore::MIMETypeRegistry::getMediaMIMETypesForExtension): Updated to use the typesForCommonExtension function. Comment about strategy is now in there. (WebCore::initializeUnsupportedTextMIMETypes): Added a missing const for a global constant array. Also started using ASCIILiteral. * platform/MainThreadSharedTimer.cpp: Moved include of NeverDestroyed.h here ... * platform/MainThreadSharedTimer.h: ... from here. Added Forward.h. * platform/SchemeRegistry.cpp: (WebCore::add): Added helper functions to keep code below simpler. (WebCore::makeNeverDestroyedSchemeSet): Ditto. (WebCore::allBuiltinSchemes): Use const auto, makeNeverDestroyed, a lambda, and the helper functions above, rather than isEmpty. (WebCore::builtinLocalURLSchemes): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of isEmpty and add calls. Also changed the return type to be const. (WebCore::localURLSchemes): Copy the map using assignment instead of an isEmpty function and a loop with calls to add. (WebCore::builtinSecureSchemes): Use const auto, makeNeverDestroyed, and the Vector constructor rather than isEmpty, repeated calls to append, and shrinkToFit. (WebCore::secureSchemes): Use auto and makeNeverDestroyedSchemeSet rather than isEmpty and repeated calls to add. (WebCore::builtinSchemesWithUniqueOrigins): More of the same. (WebCore::schemesWithUniqueOrigins): Ditto. (WebCore::builtinEmptyDocumentSchemes): Ditto. (WebCore::emptyDocumentSchemes): Ditto. (WebCore::schemesForbiddenFromDomainRelaxation): Ditto. (WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::canDisplayOnlyIfCanRequestSchemes): Ditto. (WebCore::builtinCORSEnabledSchemes): Ditto. (WebCore::CORSEnabledSchemes): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal): Replaced check for empty string with check for null string, since that's slightly more efficient for non-null, non-empty strings, and the hash table can handle empty strings just fine. (WebCore::SchemeRegistry::registerURLSchemeAsNoAccess): Added null check here. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument): Ditto. (WebCore::SchemeRegistry::setDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::isDomainRelaxationForbiddenForURLScheme): Ditto. (WebCore::SchemeRegistry::canDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated): Ditto. (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme): Ditto. (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned): Ditto. (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme): Ditto. (WebCore::SchemeRegistry::isUserExtensionScheme): Tweaked #if a bit. (WebCore::SchemeRegistry::isBuiltinScheme): Added null check. * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: (WebVideoFullscreenModelVideoElement::observedEventNames): Use const auto, makeNeverDestroyed, and the Vector constructor rather than a call to size and then append eacn time this funciton is called. * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Moved include of NeverDestroyed.h from here ... * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: ... to here. * platform/gamepad/mac/HIDGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * platform/gamepad/mac/HIDGamepadProvider.h: ... from here. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::hasValidAverageCharWidth): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::transformColorSpace): Removed unneeded use of NeverDestroyed<Vector<int>> here, instead using const std::array. * platform/graphics/ImageBuffer.h: Changed platformTransformColorSpace to take const std::array<uint8_t, 256>& instead of const Vector<int>&, since the whole pointer of the argument is that it's a table to map bytes onto other bytes. * platform/graphics/MediaPlaybackTarget.h: Removed unneeded include of NeverDestroyed.h, unneeded unused noMediaPlaybackTargetContext function, and unneeded include of MediaPlaybackTargetContext.h, forward declaring instead. Made most functions in this class pure virtual instead of having default implementations. * platform/graphics/avfoundation/MediaPlaybackTargetMac.h: Added include of MediaPlaybackTargetContext.h now that it was removed above. * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use const auto, makeNeverDestroyed, and the HashSet constructor. * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::isAvailable): Reversed the sense of the boolean logic here to make this simpler and easier to read. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Changed the implementation here, which empties out the passed in hash set, to use the clear function rather than assignment from a global empty hash set. Added a FIXME because it seems peculiar that this would be considered OK. (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Used ? : to make this a little more terse; I think it's clearer. * platform/graphics/cairo/ImageBufferCairo.cpp: (WebCore::ImageBuffer::platformTransformColorSpace): Updated for change to argument type. * platform/graphics/cg/ImageDecoderCG.cpp: Removed unneeded include of NeverDestroyed.h. (WebCore::appendImageSourceOption): Streamlined code using auto with adoptCF; there is no need to write out the type of the RetainPtr. (WebCore::imageSourceOptions): Instead of NeverDestroyed<RetainPtr>, just use const auto and leakRef. (WebCore::imageSourceAsyncOptions): Ditto. * platform/graphics/gtk/GdkCairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): Instead of using LazyNeverDestroyed on a pointer, just use a global pointer. There is no need to use any kind of NeverDestroyed on a type with a trivial destructor such as a pointer. * platform/graphics/ios/FontCacheIOS.mm: (WebCore::platformFontWithFamilySpecialCase): Instead of using NeverDestroyed<RetainPtr> just use a raw pointer global. * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamilySpecialCase): Ditto. * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: (WebCore::createFileTypesSet): Return the HashSet instead of adding to it. Use Objective-C for/in syntax for an NSArray, not C++ for syntax, although it seems the C++ syntax was working fine. (WebCore::mimeCommonTypesCache): Fixed return type so we won't copy the HashMap every time this function is called. Use const auto and makeNeverDestroyed instead of using a boolean to do one time initialization. (WebCore::mimeModernTypesCache): Ditto. (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Marked a constant array const. * platform/ios/Device.cpp: (WebCore::deviceClass): Use a lambda to initialize a variable here instead of using std::call_once. This function does not need to be thread safe. (WebCore::deviceName): Use const NeverDestroyed instead of LazyNeverDestroyed and std::call_once. This function does not need to be thread safe. * platform/ios/DragImageIOS.mm: Make defaultLinkIndicatorOptions be a constant instead of a variable. (WebCore::cascadeForSystemFont): Added helper function. (WebCore::createDragImageForLink): Use const auto and makeNeverDestroyed instead of LazyNeverDestroyed and dispatch_once. This code does not need to be thread safe since its arguments include, for example, a DOM element. * platform/ios/LegacyTileLayerPool.h: Removed unneeded include of NeverDestroyed.h. * platform/ios/QuickLook.mm: (WebCore::QLPreviewGetSupportedMIMETypesSet): Use a global raw pointer instead of NeverDestroyed<RetainPtr<NSSet>>. (WebCore::createQLPreviewProtocol): Deleted. (WebCore::QLPreviewProtocol): Use a global raw pointer instead of a NeverDestroyed<Vector<char>>. It's cleaner to use fastStrdup instead of appending to an array, and less wasteful of memory too. * platform/ios/WebCoreMotionManager.mm: Removed unneeded include of NeverDestroyed.h. * platform/ios/WebSQLiteDatabaseTrackerClient.h: Ditto. * platform/mac/DragImageMac.mm: Ditto. * platform/mediastream/CaptureDeviceManager.cpp: Ditto. * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto. * platform/mock/MockRealtimeMediaSource.cpp: (WebCore::MockRealtimeMediaSource::audioDevices): Use auto, makeNeverDestroyed, and a lambda instead of checking size each time. (WebCore::MockRealtimeMediaSource::videoDevices): Ditto. * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::mimeTypeCache): Use const auto, makeNeverDestroyed, and the HashSet constructor instead of an explicit boolean to initialize. * platform/network/BlobRegistryImpl.cpp: (WebCore::blobUtilityQueue): Use a global with a raw reference instead of a NeverDestroyed<Ref>. * platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::singleton): Renamed this from networkStateNotifier. We must have missed this when we changed to use the singleton idiom consistently. Also changed to use normal NeverDestroyed rather than using LazyNeverDestroyed and call_once, because this is not used from multiple threads and has no special thread safety requirements. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Moved the constructor here and construct the timer. Before the timer was used only on the Mac platform but now it is there for all platforms. (WebCore::NetworkStateNotifier::onLine): Moved function here from the header. It's a littlel less trivial than before because it now triggers a call to updateState as needed. (WebCore::NetworkStateNotifier::addListener): Renamed from addNetworkStateChangeListener since there is only one kind of listener and the old name was too wordy. Changed to call the new startObserving function, and guaranteed to call it onlh once. The platform-specific logic for iOS is now inside the iOS version of that function instead of here. (WebCore::NetworkStateNotifier::updateState): Moved here now that it is the same for all platforms. The actual state updating is done in a function named updateStateWithoutNotifying, which is implemented for each platform. (WebCore::NetworkStateNotifier::updateStateSoon): New function which takes advantage of the timer to coalesce network state updates. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Empty stub version of this function. (WebCore::NetworkStateNotifier::startObserving): Ditto. (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Deleted. Code from this has moved into updateState. * platform/network/NetworkStateNotifier.h: Greatly cut down what part of this class is platform-specific. * platform/network/ios/NetworkStateNotifierIOS.mm: (-[WebNetworkStateObserver initWithBlock:]): Simplified this class so it takes a block, rather than using a pointer to the C++ notifier and doing WebThreadRun. (-[WebNetworkStateObserver dealloc]): Ditto. (-[WebNetworkStateObserver networkStateChanged:]): Ditto. (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): This now calls isNetworkReachable. (WebCore::NetworkStateNotifier::startObserving): Check the Settings::shouldOptOutOfNetworkStateObservation function, and if it's OK to observe, then create the observer. This code now takes care of the WebThreadRun and calls updateStateSoon. (WebCore::NetworkStateNotifier::NetworkStateNotifier): Deleted. The constructor is now platform independent. (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Deleted. This object is never destroyed so we should not write a destructor for it. (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Deleted. Replaced by startObserving. (WebCore::NetworkStateNotifier::onLine): Deleted. This function is now platform-independent. (WebCore::setOnLine): Deleted. The logic from this is now in updateState and updateStateWithoutNotifying. * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed this from updateState and tightened up the code a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor into this function. (WebCore::NetworkStateNotifier::dynamicStoreCallback): Deleted. This is now a lambda inside startObserving. (WebCore::NetworkStateNotifier::networkStateChangeTimerFired): Deleted. This function is now platform-independent and is named updateState. * platform/network/win/NetworkStateNotifierWin.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Renamed from updateState and tightened the code up a bit. Also changed to not assume anything. If there is an error, we leave m_isOnLine alone. Default behavior is now in the platform-independent code, and the default is to treat things as on-line if updateStateWithoutNotifying was called and it was never able to update the state even once. (WebCore::NetworkStateNotifier::addressChanged): Deleted. This function is now platform-independent and is named updateState. (WebCore::NetworkStateNotifier::addressChangeCallback): Renamed from addrChangeCallback. Simplified by using the singleton function instead of relying on the context pointer. (WebCore::NetworkStateNotifier::startObserving): Moved most of the code from the constructor here. * platform/text/LocaleToScriptMappingDefault.cpp: (WebCore::scriptNameToCode): Use makeNeverDestroyed. (WebCore::localeToScriptCodeForFontSelection): Ditto. * platform/text/ios/LocalizedDateCache.h: Moved include of NeverDestroyed.h from here ... * platform/text/ios/LocalizedDateCache.mm: ... to here. * platform/wpe/RenderThemeWPE.cpp: (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * platform/wpe/RenderThemeWPE.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderTheme.h: Made RenderTheme no longer reference counted. * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeGtk.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/RenderThemeIOS.h: Ditto. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeMac.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. Also marked a lot of functions final rather than override and initialized data members in the class deifnition. * rendering/RenderThemeMac.mm: Moved some SPI interfaces to the top of the file. They should really go into SPI headers. (-[WebCoreRenderThemeNotificationObserver init]): Removed the theme argument here because the theme is a singleton and we don't need a pointer to it. Add the observer here instead of doing it in the caller. (-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Call platformColorsDidChange through the singleton rather than using a pointer. (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]): Tightened up the code a bit by using CFAutorelease instead of using a combination of NSMakeCollectable, autorelease, and a typecast to accomplish the same thing. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. (WebCore::RenderThemeMac::create): Deleted. (WebCore::RenderThemeMac::RenderThemeMac): Moved initialization into the class definition and observing into the WebCoreRenderThemeNotificationObserver init function. (WebCore::RenderThemeMac::~RenderThemeMac): Deleted. No need for this since the object will never be destroyed. (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType): Removed an unnecessary conversion from C string literal to WTF::String and then to NSString. Instead, just use an NSString literal. * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::create): Deleted. (WebCore::RenderTheme::singleton): Use a theme that is never destroyed rather than Ref that is never destroyed. * rendering/RenderThemeWin.h: Use friend NeverDestroyed rather than a create function since RenderTheme is no longer reference counted. * rendering/svg/RenderSVGResource.cpp: (WebCore::removeFromCacheAndInvalidateDependencies): Moved a global into the code where it is used. * svg/SVGAnimatedLength.cpp: Removed unneeded include of NeverDestroyed.h. * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGClipPathElement.cpp: (WebCore::SVGClipPathElement::isSupportedAttribute): Ditto. * svg/SVGComponentTransferFunctionElement.cpp: (WebCore::SVGComponentTransferFunctionElement::isSupportedAttribute): Ditto. * svg/SVGCursorElement.cpp: (WebCore::SVGCursorElement::isSupportedAttribute): Ditto. * svg/SVGElement.cpp: (WebCore::createAttributeNameToCSSPropertyIDMap): Replaced the populate function with this create function. (WebCore::createAttributeNameToAnimatedPropertyTypeMap): Ditto. (WebCore::attributeNameToAnimatedPropertyTypeMap): Changed return type to const reference. Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. (WebCore::createCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): More of the same. (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Ditto. (WebCore::SVGElement::childShouldCreateRenderer): Use an array instead of a HashSet since we are checking against only 3 or 4 values. (WebCore::addQualifiedName): Deleted. (WebCore::SVGElement::animatableAttributeForName): Use const auto, makeNeverDestroyed, and a lambda to efficiently build the map in this function. (WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use const auto and makeNeverDestroyed instead of using isEmpty and a populate function. * svg/SVGFilterElement.cpp: (WebCore::SVGFilterElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::isSupportedAttribute): Ditto. * svg/SVGForeignObjectElement.cpp: (WebCore::SVGForeignObjectElement::isSupportedAttribute): Ditto. * svg/SVGGElement.cpp: (WebCore::SVGGElement::isSupportedAttribute): Ditto. * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::isSupportedAttribute): Ditto. * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::isSupportedAttribute): Ditto. * svg/SVGImageElement.cpp: (WebCore::SVGImageElement::isSupportedAttribute): Ditto. * svg/SVGLangSpace.cpp: (WebCore::addWithAndWithoutXMLPrefix): Added helper. Uses xmlAtom instead of making our own NeverDestroyed local xmlPrefix. (WebCore::SVGLangSpace::addSupportedAttributes): Rewrote to use helper. * svg/SVGLineElement.cpp: (WebCore::SVGLineElement::isSupportedAttribute): Use const auto, makeNeverDestroyed, a lambda, and the new HashSet::add overload instead of an isEmpty check and lots of separate add function calls. * svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::isSupportedAttribute): Ditto. * svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::isSupportedAttribute): Ditto. * svg/SVGMaskElement.cpp: (WebCore::SVGMaskElement::isSupportedAttribute): Ditto. * svg/SVGPathElement.cpp: (WebCore::SVGPathElement::isSupportedAttribute): Ditto. * svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::isSupportedAttribute): Ditto. * svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::isSupportedAttribute): Ditto. * svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::isSupportedAttribute): Ditto. * svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::isSupportedAttribute): Ditto. * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::isSupportedAttribute): Ditto. * testing/MockContentFilterSettings.h: Removed unneeded include of NeverDestroyed.h. * testing/MockGamepadProvider.cpp: Moved include of NeverDestroyed.h here ... * testing/MockGamepadProvider.h: ... from here. * testing/MockPreviewLoaderClient.h: Removed unneeded include of NeverDestroyed.h. * workers/Worker.cpp: (WebCore::allWorkers): Changed this from a global to a function. (WebCore::Worker::networkStateChanged): Updated for above change and made this a member function. (WebCore::Worker::Worker): Updated for above change and change to NetworkStateNotifier. (WebCore::Worker::~Worker): Ditto. * workers/Worker.h: Made networkStateChanged a static member instead of a friend since that is a cleaner way to give it access to private member functions. * xml/XPathFunctions.cpp: (WebCore::XPath::createFunctionMap): Use create instead of populate style. (WebCore::XPath::Function::create): Use const auto and makeNeverDestroyed instead of an isEmpty check. * xml/XPathParser.cpp: (WebCore::XPath::createAxisNamesMap): Use create instead of populate style. (WebCore::XPath::parseAxisName): Use const auto and makeNeverDestroyed instead of an isEmpty check. Source/WebKit: * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of NeverDestroyed.h. * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto. * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of NeverDestroyed.h here ... * NetworkProcess/capture/NetworkCaptureManager.h: ... from here. * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h here ... * PluginProcess/PluginProcess.h: ... from here. * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (isContainerClass): Removed trivial inefficient use of LazyNeverDestroyed<HashSet> to check against two classes. Instead wrote out the boolean expression. * Shared/mac/SecItemShim.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): Call installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton. * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include of NeverDestroyed.h. * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/Plugins/PluginProcessManager.h: ... from here. * UIProcess/WebInspectorProxy.cpp: Removed unneeded include of NeverDestroyed.h. * UIProcess/WebPageProxy.h: Added now-needed include of MediaPlaybackTargetContext.h. * UIProcess/WebPasteboardProxy.cpp: Moved include of NeverDestroyed.h here ... * UIProcess/WebPasteboardProxy.h: ... from here. * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the WebMemoryPressureHandler class from this header. Callers don't need to know if there is a class. They simply indicate when it's time to install the handler. Another way to put it is that this class had no functions other than the singleton function. * UIProcess/ios/WebMemoryPressureHandlerIOS.mm: (WebKit::installMemoryPressureHandler): Replaced the class with this function. It creates a dispatch source and then resumes it. To avoid having the source look like a leak, we keep it in a global variable. * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of NeverDestroyed.h. * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of NeverDestroyed.h here ... * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here. * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded include of NeverDestroyed.h. Source/WebKitLegacy: * Storage/StorageThread.cpp: (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): Simplify code by using a modern for loop and passing a function without wrapping it in a lambda. Source/WebKitLegacy/mac: * Misc/WebStringTruncator.mm: (+[WebStringTruncator centerTruncateString:toWidth:]): Replace NeverDestroyed<RetainPtr> with just an NSFont * global. * Plugins/Hosted/NetscapePluginHostManager.h: Removed unneeded include of NeverDestroyed.h. * Storage/WebDatabaseManager.mm: Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: Ditto. * WebCoreSupport/WebPlatformStrategies.mm: Ditto. * WebView/WebView.mm: Removed unneeded include of NetworkStateNotifier.h. (aeDescFromJSValue): Removed double hashing by using the return value from add rather than calling contains before calling add. Source/WTF: * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of const references. This is handy to add a bunch of values all at once. Later we can consider optimizing to grow the hash table only once instead of deciding whether to grow repeatedly as we add each value. (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here. * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ... * wtf/MemoryPressureHandler.h: ... not here. * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed. Added a makeNeverDestroyed function that deduces the type from the argument. With auto, this can be used to avoid writing out a long type twice. * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h. * wtf/text/AtomicString.cpp: Ditto. Canonical link: https://commits.webkit.org/191408@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 01:53:34 +00:00
using WTF::makeNeverDestroyed;
Introduce MainThreadNeverDestroyed / MainThreadLazyNeverDestroyed https://bugs.webkit.org/show_bug.cgi?id=211264 Reviewed by Mark Lam. Source/WebCore: No behavior change. Adding assertions additionally. * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.cpp: (WebCore::stringForPlaybackTargetAvailability): * Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::InitDataRegistry::cencName): (WebCore::InitDataRegistry::keyidsName): (WebCore::InitDataRegistry::webmName): * Modules/mediacontrols/MediaControlsHost.cpp: (WebCore::MediaControlsHost::automaticKeyword): (WebCore::MediaControlsHost::forcedOnlyKeyword): (WebCore::alwaysOnKeyword): (WebCore::manualKeyword): * Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::kind const): (WebCore::MediaStreamTrack::contentHint const): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::blobKeyword): (WebCore::arraybufferKeyword): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::liveRegionRelevant const): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::nameForProperty const): * dom/Document.cpp: (WebCore::Document::validateCustomElementName): * dom/InlineStyleSheetOwner.cpp: (WebCore::isValidCSSContentType): * dom/MutationRecord.cpp: * dom/make_names.pl: (printNamesHeaderFile): (printNamesCppFile): * html/Autocapitalize.cpp: (WebCore::stringForAutocapitalizeType): * html/Autofill.cpp: (WebCore::isContactToken): (WebCore::AutofillData::createFromHTMLFormControlElement): * html/BaseCheckableInputType.cpp: (WebCore::BaseCheckableInputType::fallbackValue const): * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree): * html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): * html/FileInputType.cpp: (WebCore::UploadButtonElement::UploadButtonElement): * html/FormController.cpp: (WebCore::FormKeyGenerator::formKey): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::parseAttribute): (WebCore::HTMLAnchorElement::isSystemPreviewLink const): * html/HTMLButtonElement.cpp: (WebCore::HTMLButtonElement::formControlType const): * html/HTMLDetailsElement.cpp: (WebCore::summarySlotName): * html/HTMLElement.cpp: (WebCore::toValidDirValue): (WebCore::trueName): (WebCore::falseName): (WebCore::plaintextOnlyName): (WebCore::HTMLElement::setAutocorrect): * html/HTMLFieldSetElement.cpp: (WebCore::HTMLFieldSetElement::formControlType const): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::autocomplete const): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::loadingForBindings const): * html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::formControlType const): * html/HTMLOptGroupElement.cpp: (WebCore::HTMLOptGroupElement::formControlType const): * html/HTMLOutputElement.cpp: (WebCore::HTMLOutputElement::formControlType const): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::partOfSnapshotOverlay const): * html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::formControlType const): * html/HTMLTableCellElement.cpp: (WebCore::HTMLTableCellElement::scope const): * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::formControlType const): * html/HTMLTextFormControlElement.cpp: (WebCore::directionString): (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): * html/InputMode.cpp: (WebCore::InputModeNames::none): (WebCore::InputModeNames::text): (WebCore::InputModeNames::tel): (WebCore::InputModeNames::url): (WebCore::InputModeNames::email): (WebCore::InputModeNames::numeric): (WebCore::InputModeNames::decimal): (WebCore::InputModeNames::search): * html/InputTypeNames.cpp: (WebCore::InputTypeNames::button): (WebCore::InputTypeNames::checkbox): (WebCore::InputTypeNames::color): (WebCore::InputTypeNames::date): (WebCore::InputTypeNames::datetime): (WebCore::InputTypeNames::datetimelocal): (WebCore::InputTypeNames::email): (WebCore::InputTypeNames::file): (WebCore::InputTypeNames::hidden): (WebCore::InputTypeNames::image): (WebCore::InputTypeNames::month): (WebCore::InputTypeNames::number): (WebCore::InputTypeNames::password): (WebCore::InputTypeNames::radio): (WebCore::InputTypeNames::range): (WebCore::InputTypeNames::reset): (WebCore::InputTypeNames::search): (WebCore::InputTypeNames::submit): (WebCore::InputTypeNames::telephone): (WebCore::InputTypeNames::text): (WebCore::InputTypeNames::time): (WebCore::InputTypeNames::url): (WebCore::InputTypeNames::week): * html/MediaController.cpp: (WebCore::playbackStateWaiting): (WebCore::playbackStatePlaying): (WebCore::playbackStateEnded): * html/RangeInputType.cpp: (WebCore::RangeInputType::createShadowSubtree): * html/SearchInputType.cpp: (WebCore::updateResultButtonPseudoType): * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::createShadowSubtree): (WebCore::TextFieldInputType::createDataListDropdownIndicator): (WebCore::TextFieldInputType::createContainer): (WebCore::TextFieldInputType::createAutoFillButton): * html/ValidationMessage.cpp: (WebCore::ValidationMessage::buildBubbleTree): * html/shadow/DetailsMarkerControl.cpp: (WebCore::DetailsMarkerControl::DetailsMarkerControl): * html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): * html/shadow/ProgressShadowElement.cpp: (WebCore::ProgressInnerElement::create): (WebCore::ProgressBarElement::create): (WebCore::ProgressValueElement::create): * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::SpinButtonElement): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): * html/shadow/YouTubeEmbedShadowElement.cpp: (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement): * html/shadow/mac/ImageControlsButtonElementMac.cpp: (WebCore::ImageControlsButtonElementMac::tryCreate): * html/shadow/mac/ImageControlsRootElementMac.cpp: (WebCore::ImageControlsRootElement::tryCreate): * html/track/AudioTrack.cpp: (WebCore::AudioTrack::alternativeKeyword): (WebCore::AudioTrack::descriptionKeyword): (WebCore::AudioTrack::mainKeyword): (WebCore::AudioTrack::mainDescKeyword): (WebCore::AudioTrack::translationKeyword): (WebCore::AudioTrack::commentaryKeyword): * html/track/TextTrack.cpp: (WebCore::TextTrack::subtitlesKeyword): (WebCore::captionsKeyword): (WebCore::descriptionsKeyword): (WebCore::chaptersKeyword): (WebCore::metadataKeyword): (WebCore::forcedKeyword): * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::cueShadowPseudoId): (WebCore::TextTrackCue::cueBoxShadowPseudoId): (WebCore::TextTrackCue::cueBackdropShadowPseudoId): (WebCore::TextTrackCue::rebuildDisplayTree): * html/track/VTTRegion.cpp: (WebCore::upKeyword): (WebCore::VTTRegion::textTrackCueContainerScrollingClass): (WebCore::VTTRegion::textTrackCueContainerShadowPseudoId): (WebCore::VTTRegion::textTrackRegionShadowPseudoId): * html/track/VideoTrack.cpp: (WebCore::VideoTrack::alternativeKeyword): (WebCore::VideoTrack::captionsKeyword): (WebCore::VideoTrack::mainKeyword): (WebCore::VideoTrack::signKeyword): (WebCore::VideoTrack::subtitlesKeyword): (WebCore::VideoTrack::commentaryKeyword): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName const): * page/EventHandler.cpp: (WebCore::focusDirectionForKey): * page/Quirks.cpp: (WebCore::Quirks::shouldBypassBackForwardCache const): * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::updateKeyframeAnimations): * platform/cocoa/PlaybackSessionModelMediaElement.mm: (WebCore::PlaybackSessionModelMediaElement::eventNameAll): * platform/cocoa/VideoFullscreenModelVideoElement.mm: (WebCore::VideoFullscreenModelVideoElement::eventNameAll): * platform/graphics/FontCache.cpp: (WebCore::FontCache::alternateFamilyName): * platform/graphics/MediaPlayer.cpp: (WebCore::applicationOctetStream): (WebCore::textPlain): * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::CDMPrivateFairPlayStreaming::sinfName): (WebCore::CDMPrivateFairPlayStreaming::skdName): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::metadataType): * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::similarFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: (WebCore::SystemFontDatabaseCoreText::systemFontParameters): * platform/graphics/filters/SourceAlpha.cpp: (WebCore::SourceAlpha::effectName): * platform/graphics/filters/SourceGraphic.cpp: (WebCore::SourceGraphic::effectName): * platform/graphics/ios/FontCacheIOS.mm: (WebCore::FontCache::getCustomFallbackFont): * platform/graphics/texmap/TextureMapperShaderProgram.h: * platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::lastResortFallbackFont): (WebCore::FontCache::platformAlternateFamilyName): * platform/network/cocoa/ResourceResponseCocoa.mm: (WebCore::extractHTTPStatusText): * rendering/ComplexLineLayout.cpp: (WebCore::ComplexLineLayout::checkLinesForTextOverflow): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::hyphenString const): (WebCore::RenderStyle::textEmphasisMarkString const): * style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): * svg/SVGAnimateMotionElement.cpp: (WebCore::SVGAnimateMotionElement::rotateMode const): * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::setCalcMode): (WebCore::SVGAnimationElement::setAttributeType): (WebCore::SVGAnimationElement::isAdditive const): (WebCore::SVGAnimationElement::isAccumulated const): (WebCore::inheritsFromProperty): * svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): (WebCore::SVGStyleElement::media const): * svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::parseClockValue): (WebCore::SVGSMILElement::restart const): (WebCore::SVGSMILElement::fill const): (WebCore::SVGSMILElement::repeatCount const): * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: (WebCore::SVGAnimationColorFunction::colorFromString): * svg/properties/SVGPropertyAnimator.h: (WebCore::SVGPropertyAnimator::adjustForInheritance const): Source/WTF: Since AtomString has thread-affinity, `static NeverDestroyed<const AtomString>` is basically only safe for the main-thread use. We should ensure that this is only used in the main-thread. To do that, this patch introduces MainThreadNeverDestroyed and MainThreadLazyNeverDestroyed. They are NeverDestroyed and LazyNeverDestroyed + main-thread assertions. * wtf/Forward.h: * wtf/NeverDestroyed.h: (WTF::AnyThreadsAccessTraits::assertAccess): (WTF::MainThreadAccessTraits::assertAccess): (WTF::NeverDestroyed::NeverDestroyed): (WTF::NeverDestroyed::storagePointer const): (WTF::LazyNeverDestroyed::construct): (WTF::LazyNeverDestroyed::storagePointer const): (WTF::makeNeverDestroyed): * wtf/text/AtomString.cpp: * wtf/text/AtomString.h: Canonical link: https://commits.webkit.org/224193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-01 19:47:39 +00:00
using WTF::MainThreadNeverDestroyed;
using WTF::MainThreadLazyNeverDestroyed;
using WTF::AnyThreadsAccessTraits;
using WTF::MainThreadAccessTraits;