Ignore:
Timestamp:
Dec 16, 2021, 8:54:13 AM (3 years ago)
Author:
Darin Adler
Message:

Many call sites use makeNeverDestroyed, but could instead take advantage of the NeverDestroyed deduction guide
https://bugs.webkit.org/show_bug.cgi?id=234350

Reviewed by Sam Weinig.

Source/WebCore:

  • Modules/encryptedmedia/legacy/LegacyCDM.cpp:

(WebCore::installedCDMFactories): Use NeverDestroyed directly instead of via makeNeverDestroyed.

  • Modules/mediasession/MediaSession.cpp:

(WebCore::platformCommandForMediaSessionAction): Use SortedArrayMap, obviating the need for
any use of NeverDestroyed.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::inheritsPresentationalRole const): Use Span instead of
Vector, allowing us to use constexpr arrays rather than allocating memory for a Vector.

  • accessibility/mac/WebAccessibilityObjectWrapperMac.mm:

(-[WebAccessibilityObjectWrapper accessibilityAttributeNames]): Use deduction.

  • dom/make_names.pl:

(printFactoryCppFile): Ditto.
(printWrapperFactoryCppFile): Ditto.

  • editing/EditingStyle.cpp:

(WebCore::htmlElementEquivalents): Return a Span instead of a Vector&,
allowing us to use const arrays rather than allocating memory for a Vector.
(WebCore::htmlAttributeEquivalents): Ditto.

  • editing/FormatBlockCommand.cpp:

(WebCore::isElementForFormatBlock): Use deduction.

  • editing/RemoveFormatCommand.cpp:

(WebCore::isElementForRemoveFormatCommand): Ditto.

  • editing/ReplaceSelectionCommand.cpp:

(WebCore::isProhibitedParagraphChild): Use deduction, also change the tags array
to be a constexpr array so we don't have to use read/write memory for it.

  • editing/cocoa/HTMLConverter.mm:

(WebDefaultFont): Use deduction.
(defaultParagraphStyle): Ditto.

  • html/Autofill.cpp:

(WebCore::fieldNameMap): Ditto.

  • html/HTMLDocument.cpp:

(WebCore::HTMLDocument::isCaseSensitiveAttribute): Use deduction, also change
the names array to be a constexpr array so we don't have to use read/write memory for it.

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::eventNameForEventHandlerAttribute): Use std::array deduction
so we don't have to write out the LazyNeverDestroyed type here.

  • html/HTMLObjectElement.cpp:

(WebCore::preventsParentObjectFromExposure): Use deduction.

  • html/InputType.cpp:

(WebCore::InputType::create): Ditto.

  • loader/ContentFilter.cpp:

(WebCore::blockedPageURL): Ditto.

  • page/DebugPageOverlays.cpp:

(WebCore::touchEventRegionColors): Ditto.

  • page/PerformanceUserTiming.cpp:

(WebCore::restrictedMarkNamesToNavigationTimingFunctionMap): Ditto.

  • platform/LegacySchemeRegistry.cpp:

(WebCore::add): Use Span instead of Vector, allowing us to use constexpr arrays
rather thna allocating memory for a Vector.
(WebCore::makeNeverDestroyedSchemeSet): Ditto.
(WebCore::allBuiltinSchemes): Ditto. Also use deduction.
(WebCore::builtinLocalURLSchemes): Ditto.
(WebCore::builtinSecureSchemes): Ditto.
(WebCore::builtinSchemesWithUniqueOrigins): Ditto.
(WebCore::builtinEmptyDocumentSchemes): Ditto.
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes): Ditto.
(WebCore::builtinCORSEnabledSchemes): Ditto.

  • platform/MIMETypeRegistry.cpp:

(WebCore::MIMETypeRegistry::supportedNonImageMIMETypes): Use deduction.
(WebCore::MIMETypeRegistry::supportedMediaMIMETypes): Ditto.

  • platform/cocoa/AGXCompilerService.cpp:

(WebCore::agxCompilerServices): Use Span instead of a Vector&, allowing us
to use a constexpr array rather than allocating memory for a vector.
(WebCore::agxCompilerClasses): Ditto.

  • platform/cocoa/AGXCompilerService.h: Ditto.
  • platform/cocoa/MIMETypeRegistryCocoa.mm:

(WebCore::extensionsForMIMETypeMap): Use deduction.

  • platform/cocoa/RemoteCommandListenerCocoa.mm:

(WebCore::mediaRemoteCommandForPlatformCommand): Use SortedArrayMap, ovbviating the
need for any use of NeverDestroyed.

  • platform/cocoa/VideoFullscreenModelVideoElement.h:
  • platform/cocoa/VideoFullscreenModelVideoElement.mm:

(WebCore::VideoFullscreenModelVideoElement::observedEventNames): Return a Span
instead of a Vector&, allowing us to use an array rather than allocating
memory for a Vector.

  • platform/encryptedmedia/CDMProxy.cpp:

(WebCore::CDMProxyFactory::registeredFactories): Use deduction.

  • platform/graphics/FontCascade.cpp:

(WebCore::useBackslashAsYenSignForFamily): Use deduction.
(WebCore::FontCascade::hasValidAverageCharWidth const): Ditto.

  • platform/graphics/ImageDecoder.cpp:

(WebCore::installedFactories): Use NeverDestroyed directly, not makeNeverDestroyed.

  • platform/graphics/IntSize.h: Added constexpr so many operations can be done

at compile time as needed; mainly this was so we can make a constexpr array of
these sizes. This same enhancement can be applied to other types, but just did
it here for now. Also fixed return values for min/maxDimension that were accidentally
returning float, hurting performance because of the round trip int to float,
also not cleanly round tripping very large and small values.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList): Use deduction.

  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:

(WebCore::AVFWrapper::checkPlayability): Ditto.

  • platform/graphics/cg/ImageSourceCGWin.cpp:

(WebCore::preferredExtensionForImageType): Ditto.

  • platform/graphics/cg/UTIRegistry.cpp:

(WebCore::defaultSupportedImageTypes): Ditto.

  • platform/graphics/cocoa/FontDescriptionCocoa.cpp:

(WebCore::matchSystemFontUse): Ditto.

  • platform/graphics/cocoa/SourceBufferParserWebM.cpp:

(WebCore::SourceBufferParserWebM::webmMIMETypes): Ditto.
(WebCore::SourceBufferParserWebM::supportedVideoCodecs): Ditto.
(WebCore::SourceBufferParserWebM::supportedAudioCodecs): Ditto.

  • platform/ios/DragImageIOS.mm:

(WebCore::createDragImageForLink): Ditto.

  • platform/mac/WebNSAttributedStringExtras.mm:

(WebCore::attributedStringByStrippingAttachmentCharacters): Ditto.

  • platform/mediacapabilities/MediaEngineConfigurationFactory.cpp:

(WebCore::factories): Ditto.

  • platform/mediastream/RealtimeVideoCaptureSource.cpp:

(WebCore::RealtimeVideoCaptureSource::standardVideoSizes): Return a Span
instead of a Vector& so we can use a constexpr array and don't need to
allocate memory or use read/write storage.

  • platform/mediastream/RealtimeVideoCaptureSource.h: Ditto. Also make

this a static member function.

  • platform/mock/MockRealtimeMediaSourceCenter.cpp:

(WebCore::devices): Use deduction.
(WebCore::deviceMap): Ditto.
(WebCore::MockRealtimeMediaSourceCenter::microphoneDevices): Ditto.
(WebCore::MockRealtimeMediaSourceCenter::speakerDevices): Ditto.
(WebCore::MockRealtimeMediaSourceCenter::videoDevices): Ditto.
(WebCore::MockRealtimeMediaSourceCenter::displayDevices): Ditto.

  • platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:

(WebCore::mimeTypeCache): Ditto.

  • platform/network/mac/ResourceHandleMac.mm:

(WebCore::operationQueueForAsyncClients): Ditto.

  • platform/text/mac/TextBoundaries.mm:

(WebCore::tokenizerForString): Ditto.

  • rendering/RenderTheme.cpp:

(WebCore::RenderTheme::cachedSystemFontDescription const): Use
NeverDestroyed directly instead of makeNeverDestroyed.

  • rendering/RenderThemeCocoa.mm:

(WebCore::RenderThemeCocoa::cachedSystemFontDescription const): Ditto.

  • svg/SVGAnimationElement.cpp:

(WebCore::SVGAnimationElement::isSupportedAttribute): Use deduction.

  • svg/SVGElement.cpp:

(WebCore::createAttributeNameToCSSPropertyIDMap): Use a constexpr array
instead of a const one that has to be initialized at runtime.
(WebCore::SVGElement::animatableAttributeForName): Ditto, also use deduction.
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName): Use deduction.

  • svg/animation/SVGSMILElement.cpp:

(WebCore::SVGSMILElement::isSupportedAttribute): Use deduction.

  • xml/XPathFunctions.cpp:

(WebCore::XPath::Function::create): Ditto.

  • xml/XPathParser.cpp:

(WebCore::XPath::parseAxisName): Ditto.

Source/WebKit:

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:

(WebKit::ResourceLoadStatisticsDatabaseStore::expectedTableAndIndexQueries):
Use deduction.

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:

(WebKit::PCM::Database::expectedTableAndIndexQueries): Ditto.

  • Shared/Cocoa/DefaultWebBrowserChecks.mm:

(WebKit::getAppBoundDomainsTesting): Ditto.

  • Shared/Cocoa/SandboxExtensionCocoa.mm:

(WebKit::createHandlesForResources): Make this more generic so it works with
other kinds of collections, not just Vector. Also right-size the Vector this
returns rather than letting it grow organically.
(WebKit::SandboxExtension::createReadOnlyHandlesForFiles): Ditto.
(WebKit::SandboxExtension::createHandleForReadWriteDirectory): Ditto.
(WebKit::SandboxExtension::createHandlesForMachLookup): Ditto. Also update this
function to take a Span or an initializer_list instead of a Vector.
(WebKit::SandboxExtension::createHandlesForIOKitClassExtensions): Ditto.
(WebKit::SandboxExtension::consumePermanently): Ditto.

  • Shared/SandboxExtension.h: Updated for the above. Also corrected some unusual

use of #if to share a single declaration of some functions for both enabled
and disabled SANDBOX_EXTENSIONS.

  • UIProcess/GPU/GPUProcessProxy.cpp:

(WebKit::nonBrowserServices): Use deduction.

  • UIProcess/WebPageProxy.cpp: Remove unused MERGE_WHEEL_EVENTS.

(WebKit::attachmentElementServices): Return a Span, allowing us to use a
constexpr obviating the need for memory allocation or read/write memory,
(WebKit::gpuIOKitClasses): Ditto.
(WebKit::gpuMachServices): Ditto.
(WebKit::mediaRelatedMachServices): Ditto.
(WebKit::mediaRelatedIOKitClasses): Ditto.

  • UIProcess/ios/TextCheckerIOS.mm:

(WebKit::mutableState): Use deduction.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView supportedPasteboardTypesForCurrentSelection]): Ditto.

  • UIProcess/mac/TextCheckerMac.mm:

(WebKit::mutableState): Ditto.

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::temporaryPDFDirectoryPath): Ditto.

Source/WebKitLegacy/mac:

  • Misc/WebNSPasteboardExtras.mm:

(writableTypesForImageWithoutArchive): Use deduction.
(writableTypesForImageWithArchive):

  • Misc/WebNSURLExtras.mm:

(-[NSString _webkit_rangeOfURLScheme]): Ditto.

  • WebView/WebDataSource.mm:

(+[WebDataSource _repTypesAllowImageTypeOmission:]): Ditto.

  • WebView/WebFrameView.mm:

(+[WebFrameView _viewTypesAllowImageTypeOmission:]): Ditto.

Source/WTF:

  • wtf/NeverDestroyed.h:

(WTF::makeNeverDestroyed): Deleted.

  • wtf/text/cf/StringImplCF.cpp:

(WTF::StringWrapperCFAllocator::allocator): Use deduction guide.

Tools:

  • DumpRenderTree/mac/DumpRenderTree.mm:

(fontAllowList): Use deduction.

  • TestWebKitAPI/Tests/WTF/NeverDestroyed.cpp:

(TestWebKitAPI::TEST): Remove tests of makeNeverDestroyed.
(TestWebKitAPI::list): Use deduction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/xml/XPathFunctions.cpp

    r283851 r287138  
    716716std::unique_ptr<Function> Function::create(const String& name, unsigned numArguments)
    717717{
    718     static const auto functionMap = makeNeverDestroyed(createFunctionMap());
     718    static NeverDestroyed functionMap = createFunctionMap();
    719719
    720720    auto it = functionMap.get().find(name);
Note: See TracChangeset for help on using the changeset viewer.