[Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Apr 2020 02:11:30 +0000 (02:11 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Apr 2020 02:11:30 +0000 (02:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=210138

Reviewed by Alex Christensen.

Source/JavaScriptCore:

* API/JSValue.mm:
(valueToObjectWithoutCopy): Use @().
(valueToNumber): Ditto.
* API/tests/testapi.mm:
(-[TestObject callback:]): Use @[], @(), and @{}.
(-[TextXYZ click]): Ditto.
(testObjectiveCAPIMain): Ditto.

Source/WebCore:

- Added createNSArray and makeVector.
- Use createNSArray and makeVector<String> in many places where we convert
  between NSArray and Vector, replacing multiple existing functions that were
  doing the same job before; later can use them even more.
- Use @[] many places where we create an autoreleased NSArray.
- Use @{} many places where we create an autoreleased NSDictionary.
- Use @() many places where we create an autoreleased NSNumber.

* PlatformMac.cmake: Moved Float/IntRectMac.mm to Float/IntRectCocoa.mm.
* SourcesCocoa.txt: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(AXAttributeStringSetBlockquoteLevel): Use @().
(AXAttributeStringSetHeadingLevel): Use @().
(-[WebAccessibilityObjectWrapper textMarkerRangeForSelection]): Use @[].
(-[WebAccessibilityObjectWrapper _stringFromStartMarker:toEndMarker:attributed:]): Use @[].
(-[WebAccessibilityObjectWrapper elementsForRange:]): Use @[].
(-[WebAccessibilityObjectWrapper textMarkersForRange:]): Use @[].

* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::textReplacementChangeDictionary): Use @().

* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(makeVectorElement): Aded overload for AccessibilitySearchKey.
(accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute):
Use makeVector<AccessibilitySearchKey>.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(accessibilityTextCriteriaForParameterizedAttribute): Use makeVector<String>.
(accessibilitySearchTextCriteriaForParameterizedAttribute): Use makeVector<String>.
(AXAttributeStringSetStyle): Use @().
(AXAttributeStringSetBlockquoteLevel): Use @().
(AXAttributeStringSetHeadingLevel): Use @().
(-[WebAccessibilityObjectWrapper accessibilityActionNames]): Use @[].
(convertStringsToNSArray): Deleted.
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
Use @(), @[], and createNSArray.
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
Ditto.

* bridge/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
Use @().

* editing/cocoa/AlternativeTextUIController.mm:
(WebCore::AlternativeTextUIController::alternativesForContext):
Use makeVector<String>.

* editing/cocoa/HTMLConverter.mm:
(defaultParagraphStyle): Use @[].
(HTMLConverter::computedAttributesForElement): Use @().
(HTMLConverter::_processMetaElementWithName): Use @().
(HTMLConverter::_addTableForElement): Use @().

* page/ios/FrameIOS.mm:
(WebCore::Frame::interpretationsForCurrentRoot const): Use @[].

* platform/cocoa/MIMETypeRegistryCocoa.mm:
(WebCore::MIMETypeRegistry::getExtensionsForMIMEType): Use makeVector<String>.

* platform/graphics/FloatRect.h: Added makeNSArrayElement overload so we can
convert Vector<FloatRect> into NSArray<NSValue>.
* platform/graphics/IntRect.h: Similarly for IntRect.

* platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
(WebCore::MediaSelectionGroupAVFObjC::updateOptions): Use createNSArray.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::mediaDescriptionForKind): Use @[].
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Use @().
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Use @().
(WebCore::MediaPlayerPrivateAVFoundationObjC::checkPlayability): Use @[].
(WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoOutput): Use @{} and @().

* platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
(WebCore::PlatformCAAnimationCocoa::valueFunction const):
(WebCore::PlatformCAAnimationCocoa::setFromValue):
(WebCore::PlatformCAAnimationCocoa::copyFromValueFrom):
(WebCore::PlatformCAAnimationCocoa::setToValue):
(WebCore::PlatformCAAnimationCocoa::copyToValueFrom):
(WebCore::PlatformCAAnimationCocoa::setValues):
(WebCore::PlatformCAAnimationCocoa::copyValuesFrom):
(WebCore::PlatformCAAnimationCocoa::setKeyTimes):
(WebCore::PlatformCAAnimationCocoa::copyKeyTimesFrom):
(WebCore::PlatformCAAnimationCocoa::setTimingFunctions):
(WebCore::PlatformCAAnimationCocoa::copyTimingFunctionsFrom):
Use @(), @[], modern for loops, auto, and allocate with capacity.

* platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm:
(WebCore::PlatformCAFilters::filterValueForOperation): Use @().

* platform/graphics/cocoa/FloatRectCocoa.mm: Moved from mac/FloatRectMac.mm.
(WebCore::makeNSArrayElement): Added so we can convert Vector<FloatRect>
into NSArray<NSValue>.
* platform/graphics/cocoa/IntRectCocoa.mm: Moved from mac/IntRectMac.mm.
(WebCore::makeNSArrayElement): Similarly for IntRect.
(WebCore::enclosingIntRect): Use clampTo to be consistent with what
enclosingIntRect(FloatRect) does (while fixing check-webkit-style complaint).

* platform/graphics/cocoa/WebGLLayer.mm:
(-[WebGLLayer display]): Add WebCore namespace prefix; needed depending on
how sources get unified (and was affecting my local build when it temporarily
had an additional source file).
(-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]): Ditto.
(-[WebGLLayer bindFramebufferToNextAvailableSurface]): Ditto.

* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::systemFontModificationAttributes): Use @().

* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::getTypes): Use makeVector<String>.
(WebCore::createItemProviderRegistrationList): Use createNSArray.
(WebCore::PlatformPasteboard::updateSupportedTypeIdentifiers): Use createNSArray.

* platform/ios/WebItemProviderPasteboard.mm:
(-[WebItemProviderPasteboard setItemProviders:]): Use @[].
* platform/ios/wak/WAKView.mm:
(-[WAKView subviews]): Dittto.

* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::getTypes): Use makeVector<String>.
(WebCore::PlatformPasteboard::getPathnamesForType const): Use makeVector<String>.
(WebCore::PlatformPasteboard::addTypes): Use makeVector<String>.
(WebCore::PlatformPasteboard::setTypes): Use makeVector<String>.

* platform/mac/StringUtilities.h: Removed
webCoreStringVectorFromNSStringArray, replaced by makeVector<String>
* platform/mac/StringUtilities.mm:
(WebCore::webCoreStringVectorFromNSStringArray): Deleted.

* platform/mac/WebCoreNSURLExtras.mm: Removed unneeded include.

* platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
(WebCore::MediaRecorderPrivateWriter::setVideoInput): Use @().
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::setupCaptureSession): Use @().
* platform/network/cocoa/CookieCocoa.mm:
(WebCore::Cookie::operator NSHTTPCookie * _Nullable  const): Use @().

* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::NetworkStorageSession::setCookiesFromDOM const): Use @{}.

* platform/network/cocoa/ResourceRequestCocoa.mm:
(WebCore::ResourceRequest::doUpdatePlatformRequest): Use @YES/@NO.

Source/WebKit:

* NetworkProcess/cocoa/NetworkSessionCocoa.mm: Remove uneeded include.
* Platform/mac/StringUtilities.mm: Ditto.

* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::replacedNSConcreteTask_launch): Use makeVector<String>.
(WebKit::replacedNSWorkspace_launchApplicationAtURL_options_configuration_error):
Ditto.

* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::toSupportedNetworks): Deleted.
(WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Use createNSArray.

* Shared/mac/PasteboardTypes.mm:
(WebKit::PasteboardTypes::forEditing): Use @[].
(WebKit::PasteboardTypes::forURL): Ditto.
(WebKit::PasteboardTypes::forImages): Ditto.
(WebKit::PasteboardTypes::forImagesWithArchive): Ditto.
(WebKit::PasteboardTypes::forSelection): Ditto.

* UIProcess/API/Cocoa/WKContentRuleListStore.mm:
(-[WKContentRuleListStore getAvailableContentRuleListIdentifiers:]): Use createNSArray.
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _getActivePagesOriginsInWebProcessForTesting:completionHandler:]): Ditto.

* UIProcess/API/Cocoa/WKUserScript.mm:
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]):
(-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:deferRunningUntilNotification:]):
Use makeVector<String>.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setupPageConfiguration:]): Use makeVector<String>.
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration _corsDisablingPatterns]): Use createNSArray.
(-[WKWebViewConfiguration _setCORSDisablingPatterns:]): Use makeVector<String>.
* UIProcess/API/Cocoa/WKWebViewTesting.mm:
(-[WKWebView _contentsOfUserInterfaceItem:]): Use @().
* UIProcess/API/Cocoa/_WKContentRuleListAction.mm:
(-[_WKContentRuleListAction notifications]): Use createNSArray.
* UIProcess/API/Cocoa/_WKCustomHeaderFields.mm:
(-[_WKCustomHeaderFields thirdPartyDomains]): Use createNSArray.
(-[_WKCustomHeaderFields setThirdPartyDomains:]): Use makeVector<String>.
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration cachePartitionedURLSchemes]): Use createNSArray.
(-[_WKProcessPoolConfiguration setCachePartitionedURLSchemes:]): Use makeVector<String>.
(-[_WKProcessPoolConfiguration alwaysRevalidatedURLSchemes]): Use createNSArray.
(-[_WKProcessPoolConfiguration setAlwaysRevalidatedURLSchemes:]): Use makeVector<String>.

* UIProcess/API/Cocoa/_WKUserContentWorldInternal.h:
(API::toStringVector): Deleted.

* UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
(-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
(-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]):
Use makeVector<String>.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::accessibilityAttributeValue): Use @[].
(WebKit::WebViewImpl::performDragOperation): Use makeVector<String>.
(WebKit::WebViewImpl::namesOfPromisedFilesDroppedAtDestination): Use @[].
(WebKit::WebViewImpl::collectKeyboardLayoutCommandsForEvent): Use @[].

* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::launchProcess): Use createNSArray.
(WebKit::isJavaUpdaterURL): Use @[].
(WebKit::PluginProcessProxy::launchApplicationAtURL): Use @{} and createNSArray.
(WebKit::isSilverlightPreferencesURL): Use @[].

* UIProcess/WebAuthentication/Cocoa/HidService.mm:
(WebKit::HidService::HidService): Use @() and fixed an over-release mistake.
This code was doing adoptNS on the result of +[NSNumberWithInt:], which is incorrect.

* UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
(WebKit::MockLocalConnection::getAttestation const): Use @[].

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView textStylingAtPosition:inDirection:]): Use @().
(-[WKContentView requestRectsToEvadeForSelectionCommandsWithCompletionHandler:]): Use createNSArray.
(-[WKContentView _itemsForBeginningOrAddingToSessionWithRegistrationLists:stagedDragSource:]):
Fixed a wasteful call to autorelease where we are adding an item to a dictionary. Calling get
is more efficient and still correct.

* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel imagePickerController:didFinishPickingMediaWithInfo:]): Use @[].

* UIProcess/ios/forms/WKFormColorPicker.mm:
(-[WKColorMatrixView initWithFrame:colorMatrix:]): Removed uneeded RetainPtr
local variable.

* UIProcess/mac/CorrectionPanel.mm:
(WebKit::CorrectionPanel::show): Use createNSArray.

* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::updateSpellingUIWithGrammarString): Use createNSArray.
(WebKit::TextChecker::getGuessesForWord): Use makeVector<String>.

* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView _adjustPrintingMarginsForHeaderAndFooter]): Use @().

* UIProcess/mac/WKTextFinderClient.mm:
(arrayFromRects): Deleted.
(-[WKTextFinderClient didFindStringMatchesWithRects:didWrapAround:]): Use createNSArray.

* UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
(-[WKDataListSuggestionsController notifyAccessibilityClients:]): Use @{}
and fix a bug where this was creating a backwards dictionary. So this never
could have been working before, making me wonder how we test it.

* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::searchTheWeb): Use @[].

* WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Removed toNSArray.
* WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm:
(WebKit::toNSArray): Deleted.

* WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
(-[WKDOMNode textRects]): Use createNSArray.
* WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
(-[WKDOMRange textRects]): Ditto.

* WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
(WebKit::InjectedBundle::setBundleParameter): Use @{}.

* WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:
(WebKit::makeRenderLayer): Use @[].

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::writeItemsToPasteboard): Use makeVector<String>.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::applicationDidEnterBackground): Use @().

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::suspendPainting): Use @{}.
(WebKit::TiledCoreAnimationDrawingArea::resumePainting): Use @{}.

* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
Removed an unneeded include.
* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm: Ditto.
(-[WKAccessibilityWebPageObject accessibilityActionNames]): Use @[].
(-[WKAccessibilityWebPageObject accessibilityChildren]): Use @[].

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::getActivePagesOriginsForTesting): Use makeVector<String>.

Source/WebKitLegacy/ios:

* WebCoreSupport/WebChromeClientIOS.mm:
(WebChromeClientIOS::runOpenPanel): Use createNSArray.

* WebCoreSupport/WebVisiblePosition.mm:
(-[WebVisiblePosition enclosingRangeWithDictationPhraseAlternatives:]):
Use createNSArray.

* WebCoreSupport/WebVisiblePositionInternal.h:
Added #if so that this correctly doesn't compile anything on Mac.

* WebView/WebPDFViewIOS.mm:
(+[WebPDFView supportedMIMETypes]): Use @[].

Source/WebKitLegacy/mac:

* DOM/DOM.mm:
(kit): Deleted overload that takes Vector<IntRect>.
(-[DOMNode textRects]): Use createNSArray.
(-[DOMRange textRects]): Ditto.

* DOM/ExceptionHandlers.mm:
(raiseDOMErrorException): Use @().

* History/WebBackForwardList.mm:
(-[WebBackForwardList dictionaryRepresentation]): Use @{}.

* History/WebHistory.mm:
(+[WebHistoryPrivate initialize]): Use @{}.
(-[WebHistory _sendNotification:entries:]): Use @{}.

* History/WebHistoryItem.mm:
(-[WebHistoryItem initFromDictionaryRepresentation:]): Use makeVector<String>.
(-[WebHistoryItem dictionaryRepresentation:]): Use createNSArray and @().

* History/WebURLsWithTitles.m:
(+[WebURLsWithTitles arrayWithIFURLsWithTitlesPboardType]): Use @[].
(+[WebURLsWithTitles writeURLs:andTitles:toPasteboard:]): Use @[].

* Misc/WebCache.mm:
(+[WebCache statistics]): Use @[], @{}, and @().
* Misc/WebCoreStatistics.mm:
(+[WebCoreStatistics memoryStatistics]): Ditto.

* Misc/WebKitErrors.m:
(-[NSError _webkit_initWithDomain:code:URL:]): Use @().
(+[NSError _registerWebKitErrors]): Use @().
(-[NSError _initWithPluginErrorCode:contentURL:pluginPageURL:pluginName:MIMEType:]): Use @().

* Misc/WebKitNSStringExtras.mm:
(-[NSString _web_drawAtPoint:font:textColor:]): Use @{}.
(-[NSString _web_widthWithFont:]): Use @{}.

* Misc/WebNSFileManagerExtras.mm: Removed unneeded include.

* Misc/WebNSPasteboardExtras.mm:
(+[NSPasteboard _web_dragTypesForURL]): Use @[].
(-[NSPasteboard _web_writeURL:andTitle:types:]): Use @[].
(+[NSPasteboard _web_setFindPasteboardString:withOwner:]): Use @[].

* Misc/WebNSURLExtras.mm: Removed unneeded include.

* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::spawnPluginHost): Use @{}.

* Plugins/Hosted/NetscapePluginHostProxy.mm:
(WKPCIdentifierInfo): Use @().

* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::addValueToArray): Use @().

* Plugins/Hosted/WebHostedNetscapePluginView.mm: Removed unneeded include.
* Plugins/WebBasePluginPackage.mm: Ditto.

* Plugins/WebPluginContainerCheck.mm:
(-[WebPluginContainerCheck _actionInformationWithURL:]): Use @{}.

* Plugins/WebPluginDatabase.mm:
(+[WebPluginDatabase _defaultPlugInPaths]): Use @[].

* Storage/WebDatabaseManager.mm:
(-[WebDatabaseManager databasesWithOrigin:]): Use createNSArray.

* WebCoreSupport/CorrectionPanel.mm:
(CorrectionPanel::show): Use createNSArray.

* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::addMessageToConsole): Use @().

* WebCoreSupport/WebEditorClient.mm:
(attributesForAttributedStringConversion): Use @().
(WebEditorClient::getGuessesForWord): Use makeVector<String>.

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::actionDictionary const): Use @().
(kit): Deleted overload that takes Vector<String>.
(pluginView): Use @{}.
(WebFrameLoaderClient::createPlugin): Use createNSArray, @{}, and @().
(WebFrameLoaderClient::createJavaAppletWidget): Use createNSArray.

* WebCoreSupport/WebOpenPanelResultListener.mm:
(-[WebOpenPanelResultListener chooseFilenames:]): Use makeVector<String>.
(-[WebOpenPanelResultListener chooseFilename:displayString:iconImage:]): Use @[].
(-[WebOpenPanelResultListener chooseFilenames:displayString:iconImage:]): Use makeVector<String>.

* WebCoreSupport/WebSelectionServiceController.mm:
(WebSelectionServiceController::handleSelectionServiceClick):
Comment out an unused argument.

* WebView/WebFrame.mm:
(-[WebFrame _rectsForRange:]): Use createNSArrray.
(-[WebFrame _computePageRectsWithPrintScaleFactor:pageSize:]): Use createNSArray and @[].
(-[WebFrame childFrames]): Use @[].

* WebView/WebHTMLView.mm:
(+[WebHTMLView _selectionPasteboardTypes]): Use @[].
(-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]): Use @[].
(-[WebHTMLView knowsPageRange:]): Use @[].
(-[WebHTMLView accessibilityAttributeValue:]): Use @[].
(-[WebHTMLView copyFont:]): Use @[].
(-[WebHTMLView _interpretKeyEvent:savingCommands:]): Use @[].
(-[WebHTMLView selectionTextRects]): Use createNSArray.
(-[WebHTMLView rectsForTextMatches]): Use createNSArray and @[].

* WebView/WebPDFRepresentation.mm: Removed unneeded include.
(+[WebPDFRepresentation postScriptMIMETypes]): Use @[].
(+[WebPDFRepresentation supportedMIMETypes]): Use @[].

* WebView/WebPDFView.mm:
(-[WebPDFView elementAtPoint:]): Use @{} and @().
(-[WebPDFView viewState]): Use @().
(-[WebPDFView selectionTextRects]): Use @[].
(-[WebPDFView pasteboardTypesForSelection]): Use @[].
(-[WebPDFView _menuItemsFromPDFKitForEvent:]): Use @().
(-[WebPDFView _openWithFinder:]): Use @{} and @().

* WebView/WebPreferences.mm:
(+[WebPreferences initialize]): Use @().
(-[WebPreferences _setUnsignedIntValue:forKey:]): Use @().
(+[WebPreferences _setInitialDefaultTextEncodingToSystemEncoding]): Use @().
(-[WebPreferences setStorageBlockingPolicy:]): Use @{} and @().

* WebView/WebScriptDebugger.mm:
(WebScriptDebugger::sourceParsed): Use @().

* WebView/WebTextCompletionController.mm:
(-[WebTextCompletionController _placePopupWindow:]): Use @{}.

* WebView/WebView.mm:
(-[WebView _preferencesChanged:]): Use makeVector<String>.
(-[WebView _contentsOfUserInterfaceItem:]): Use @().
(toStringVector): Deleted.
(+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:injectedFrames:]):
Use makeVector<String>.
(+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:injectedFrames:]):
Use makeVector<String>.
(-[WebView _elementAtWindowPoint:]): Use @{}.
(-[WebView pasteboardTypesForSelection]): Use @[].
(-[WebView pasteboardTypesForElement:]): Use @[].
(-[WebView rectsForTextMatches]): Use @[].
(-[WebView _searchWithGoogleFromMenu:]): Use @[].
(-[WebView _setFontWhitelist:]): Use makeVector<String>.

Source/WTF:

* WTF.xcodeproj/project.pbxproj: Added VectorCocoa.h.
* wtf/PlatformMac.cmake: Ditto.

* wtf/cocoa/NSURLExtras.mm: Removed unneeded include.
* wtf/cocoa/URLCocoa.mm: Ditto.

* wtf/cocoa/VectorCocoa.h: Added. Contains createNSArray and makeVector
function templates for converting NSArray to and from Vector.

* wtf/text/WTFString.h: Added makeNSArrayElement and makeVectorElement
functions, making createNSArray and makeVector compatible with String.
* wtf/text/cocoa/StringCocoa.mm:
(WTF::makeNSArrayElement): Added.
(WTF::makeVectorElement): Added.

Tools:

* DumpRenderTree/AccessibilityController.h: Remove use of NotificationHandler
type; it's just "id".

* DumpRenderTree/AccessibilityUIElement.cpp:
(convertElementsToObjectArray): Moved this up in the file, removed unneeded
use of JSValueToObject and unused exception argument.
(elementsForRangeCallback): Use convertElementsToObjectArray.
(columnHeadersCallback): Updated for removed exception argument.
(rowHeadersCallback): Ditto.
(uiElementArrayAttributeValueCallback): Ditto.

* DumpRenderTree/AccessibilityUIElement.h: Changed to use RetainPtr.

* DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm:
(createCoreAnimationLayer): Use @{}.

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::AccessibilityUIElement): Removed some unneeded
code now that we use RetainPtr.
(AccessibilityUIElement::~AccessibilityUIElement): Deleted.
(AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use @[].
(AccessibilityUIElement::textMarkerRangeForMarkers): Use @[].
(AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers): Use @[].
* DumpRenderTree/ios/TextInputControllerIOS.m:
(-[TextInputController markedRange]): Use @[].

* DumpRenderTree/mac/AccessibilityCommonMac.mm:
(searchPredicateParameterizedAttributeForSearchCriteria): Tweak a little.

* DumpRenderTree/mac/AccessibilityNotificationHandler.mm:
(-[NSString createJSStringRef]): Deleted. Duplicate of a method already
implemented in anothe file.

* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(makeVectorElement): Added overloads to make both
makeVector<AccessibilityTextMarkerRange> and
makeVector<AccessibilityUIElement> work.
(AccessibilityUIElement::AccessibilityUIElement): Removed some unneeded
code now that we use RetainPtr.
(convertVectorToObjectArray): Removed unneeded use of JSValueToObject
and unneeded exception argument.
(convertNSArrayToVector): Deleted.
(AccessibilityUIElement::getLinkedUIElements): Use
makeVector<AccessibilityUIElement>.
(AccessibilityUIElement::getDocumentLinks): Ditto.
(AccessibilityUIElement::getChildren): Ditto.
(AccessibilityUIElement::getChildrenWithRange): Ditto.
(AccessibilityUIElement::rowHeaders const): Ditto.
(AccessibilityUIElement::columnHeaders const): Ditto.
(AccessibilityUIElement::uiElementArrayAttributeValue const): Ditto.
(AccessibilityUIElement::role): Updated since m_element is a RetainPtr.
(AccessibilityUIElement::subrole): Ditto.
(AccessibilityUIElement::roleDescription): Ditto.
(AccessibilityUIElement::computedRoleString): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::orientation const): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::helpText const): Ditto.
(AccessibilityUIElement::lineForIndex): Use @().
(AccessibilityUIElement::rangeForLine): Use @().
(AccessibilityUIElement::searchTextWithCriteria): Use
makeVector<AccessibilityTextMarkerRange>.
(AccessibilityUIElement::attributesOfColumnHeaders): Use
makeVector<AccessibilityUIElement>.
(AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(AccessibilityUIElement::attributesOfColumns): Ditto.
(AccessibilityUIElement::attributesOfRows): Ditto.
(AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(AccessibilityUIElement::cellForColumnAndRow): Use @[] and @().
(AccessibilityUIElement::setSelectedChild const): Use @[].
(AccessibilityUIElement::setSelectedChildAtIndex const): Use @[].
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
Use @{}, @YES, and @NO.
(AccessibilityUIElement::textMarkerRangeForMarkers): Use @[].

* DumpRenderTree/mac/DumpRenderTree.mm:
(addTestPluginsToPluginSearchPath): Use @[].
(resetWebViewToConsistentStateBeforeTesting): Use @[].
* DumpRenderTree/mac/DumpRenderTreePasteboard.mm:
(-[DumpRenderTreePasteboard declareType:owner:]): Use @[].
* DumpRenderTree/mac/EventSendingController.mm:
(-[EventSendingController beginDragWithFiles:]): Use @().
(-[EventSendingController sentTouchEventOfType:]): Use @().
* DumpRenderTree/mac/MockWebNotificationProvider.mm:
(-[MockWebNotificationProvider cancelNotification:]): Use @[].

* DumpRenderTree/mac/ObjCController.m:
(-[ObjCController objectOfClass:]): Use @().
(-[ObjCController arrayOfString]): Use @[].
(-[ObjCController testWrapperRoundTripping:]): Use @().
(-[ObjCController testArray]): Use @[].

* DumpRenderTree/mac/TestRunnerMac.mm:
(originsArrayToJS): Removed unneeded use of JSValueToObject.

* DumpRenderTree/mac/TextInputControllerMac.m:
(-[TextInputController markedRange]): Use @[] and @().
(-[TextInputController selectedRange]): Use @[] and @().
(-[TextInputController firstRectForCharactersFrom:length:]):
Use @[] and @().
(-[TextInputController dictatedStringWithPrimaryString:alternative:alternativeOffset:alternativeLength:]):
Use @[].
(-[TextInputController interpretKeyEvents:withSender:]): Use @[].

* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptControllerMac::copyText): Use [].

* DumpRenderTree/win/AccessibilityUIElementWin.cpp: Deleted an
unneeded copy constructor and destructor.

* TestRunnerShared/cocoa/LayoutTestSpellChecker.mm:
(-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Use @{}.

* TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm:
(toVector): Deleted.
(-[ContentRuleListNotificationDelegate _webView:contentRuleListWithIdentifier:performedAction:forURL:]):
Use makeVector<String>.

* TestWebKitAPI/Tests/WebKitCocoa/InAppBrowserPrivacy.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm:
(writeImageDataToPasteboard): Use @[] and @{}.
(writeBundleFileToPasteboard): Use @[].
* TestWebKitAPI/Tests/WebKitCocoa/PasteWebArchive.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
(runWebsiteDataStoreCustomPaths): Use @[].
* TestWebKitAPI/Tests/mac/WebViewCanPasteURL.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/mac/WebViewCanPasteZeroPng.mm:
(TestWebKitAPI::TEST): Use @[].
* TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm:
(-[DidCreateJavaScriptContextFrameLoadDelegate webView:didCreateJavaScriptContext:forFrame:]):
Use @[].
* TestWebKitAPI/ios/mainIOS.mm:
(main): Use @{}.
* TestWebKitAPI/mac/InjectedBundleControllerMac.mm:
(TestWebKitAPI::InjectedBundleController::platformInitialize): Use @{} and @().
* TestWebKitAPI/mac/mainMac.mm:
(main): Use {}.

* WebKitTestRunner/InjectedBundle/AccessibilityController.h:
Use id instead of NotificationHandler.
* WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.h:
Use id for PlatformTextMarkerRange. Added an overload of makeVectorElement
to make makeVector<RefPtr<AccessibilityTextMarkerRange>> work.
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
Use RetainPtr. Added an overload of makeVectorElement to make
makeVector<RefPtr<AccessibilityUIElement>> work.

* WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
Removed unneeded include.

* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::convertNSArrayToVector): Deleted.
(WTR::AccessibilityUIElement::AccessibilityUIElement): Simplified
since we use RetainPtr.
(WTR::AccessibilityUIElement::~AccessibilityUIElement): Ditto.
(WTR::convertElementsToObjectArray): Removed unneeded use of
JSValueToObject.
(WTR::AccessibilityUIElement::elementsForRange): Use
makeVector<RefPtr<AccessibilityUIElement>>.
(WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker):
Use @[].
(WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Use @[].
(WTR::AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers):

* WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm:
(WTR::InjectedBundle::platformInitialize): Use @{}.

* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::AccessibilityUIElement): Simplified
since we use RetainPtr.
(WTR::AccessibilityUIElement::~AccessibilityUIElement): Ditto.
(WTR::convertNSArrayToVector): Deleted.
(WTR::AccessibilityUIElement::getLinkedUIElements): Use
makeVector<RefPtr<AccessibilityUIElement>>.
(WTR::AccessibilityUIElement::getDocumentLinks): Ditto.
(WTR::AccessibilityUIElement::getUIElementsWithAttribute const): Ditto.
(WTR::AccessibilityUIElement::getChildren): Ditto.
(WTR::AccessibilityUIElement::getChildrenWithRange): Ditto.
(WTR::AccessibilityUIElement::rowHeaders const): Ditto.
(WTR::AccessibilityUIElement::columnHeaders const): Ditto.
(WTR::AccessibilityUIElement::allAttributes): Updated since m_element
is a RetainPtr.
(WTR::AccessibilityUIElement::stringDescriptionOfAttributeValue): Ditto.
(WTR::AccessibilityUIElement::role): Ditto.
(WTR::AccessibilityUIElement::subrole): Ditto.
(WTR::AccessibilityUIElement::roleDescription): Ditto.
(WTR::AccessibilityUIElement::computedRoleString): Ditto.
(WTR::AccessibilityUIElement::title): Ditto.
(WTR::AccessibilityUIElement::description): Ditto.
(WTR::AccessibilityUIElement::orientation const): Ditto.
(WTR::AccessibilityUIElement::stringValue): Ditto.
(WTR::AccessibilityUIElement::language): Ditto.
(WTR::AccessibilityUIElement::helpText const): Ditto.
(WTR::AccessibilityUIElement::lineForIndex): Use @().
(WTR::AccessibilityUIElement::rangeForLine): Use @().
(WTR::AccessibilityUIElement::searchTextWithCriteria): Use
makeVector<RefPtr<AccessibilityTextMarkerRange>>.
(WTR::AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
(WTR::AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(WTR::AccessibilityUIElement::attributesOfColumns): Ditto.
(WTR::AccessibilityUIElement::attributesOfRows): Ditto.
(WTR::AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(WTR::AccessibilityUIElement::cellForColumnAndRow): Use @[] and @().
(WTR::AccessibilityUIElement::setSelectedChild const): Use @[].
(WTR::AccessibilityUIElement::setSelectedChildAtIndex const): Use @[].
(WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Use @[].

* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveAllStorageAccessEntries): Take Vector&&.
(WTR::TestInvocation::didReceiveWebViewCategory): Take String&&.
* WebKitTestRunner/TestInvocation.h: Updated for the above.

* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::cocoaPlatformInitialize): Use @{}and @().
(WTR::TestController::getAllStorageAccessEntries): Use makeVector<String>.
(WTR::TestController::loadedThirdPartyDomains): Use makeVector<String>.
(WTR::TestController::getWebViewCategory): Update to pass String&&.
(WTR::TestController::setAllowedMenuActions): Use createNSArray.

* WebKitTestRunner/ios/HIDEventGenerator.mm:
(-[HIDEventGenerator interpolatedEvents:]): Use @().
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::changeWindowScaleIfNeeded): Use @{} and @().

* WebKitTestRunner/mac/TestControllerMac.mm: Removed unneeded include.

* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptControllerMac::copyText): Use @[].
* WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm:
(-[WebKitTestRunnerPasteboard declareType:owner:]): Use @[].

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259843 268f45cc-cd09-0410-ab3c-d52691b4dbfc

189 files changed:
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/API/tests/testapi.mm
Source/JavaScriptCore/ChangeLog
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/PlatformMac.cmake
Source/WTF/wtf/cocoa/NSURLExtras.mm
Source/WTF/wtf/cocoa/URLCocoa.mm
Source/WTF/wtf/cocoa/VectorCocoa.h [new file with mode: 0644]
Source/WTF/wtf/text/WTFString.h
Source/WTF/wtf/text/cocoa/StringCocoa.mm
Source/WebCore/ChangeLog
Source/WebCore/PlatformMac.cmake
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/AXObjectCacheMac.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/bridge/objc/WebScriptObject.mm
Source/WebCore/editing/cocoa/AlternativeTextUIController.mm
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/page/ios/FrameIOS.mm
Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm
Source/WebCore/platform/graphics/FloatPoint.h
Source/WebCore/platform/graphics/FloatRect.h
Source/WebCore/platform/graphics/IntPoint.h
Source/WebCore/platform/graphics/IntRect.h
Source/WebCore/platform/graphics/IntSize.h
Source/WebCore/platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm
Source/WebCore/platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm
Source/WebCore/platform/graphics/cocoa/FloatRectCocoa.mm [moved from Source/WebCore/platform/graphics/mac/FloatRectMac.mm with 71% similarity]
Source/WebCore/platform/graphics/cocoa/IntRectCocoa.mm [moved from Source/WebCore/platform/graphics/mac/IntRectMac.mm with 68% similarity]
Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm
Source/WebCore/platform/graphics/ios/FontCacheIOS.mm
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Source/WebCore/platform/ios/WebItemProviderPasteboard.mm
Source/WebCore/platform/ios/wak/WAKView.mm
Source/WebCore/platform/mac/PlatformPasteboardMac.mm
Source/WebCore/platform/mac/StringUtilities.h
Source/WebCore/platform/mac/StringUtilities.mm
Source/WebCore/platform/mac/WebCoreNSURLExtras.mm
Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
Source/WebCore/platform/network/cocoa/CookieCocoa.mm
Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm
Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Source/WebKit/Platform/mac/StringUtilities.mm
Source/WebKit/PluginProcess/mac/PluginProcessMac.mm
Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
Source/WebKit/Shared/mac/PasteboardTypes.mm
Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm
Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.mm
Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm
Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/_WKUserContentWorldInternal.h
Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
Source/WebKit/UIProcess/WebAuthentication/Cocoa/HidService.mm
Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm
Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm
Source/WebKit/UIProcess/mac/CorrectionPanel.mm
Source/WebKit/UIProcess/mac/TextCheckerMac.mm
Source/WebKit/UIProcess/mac/WKPrintingView.mm
Source/WebKit/UIProcess/mac/WKTextFinderClient.mm
Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm
Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm
Source/WebKit/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm
Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm
Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm
Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePositionInternal.h
Source/WebKitLegacy/ios/WebView/WebPDFViewIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/DOM/DOM.mm
Source/WebKitLegacy/mac/DOM/ExceptionHandlers.mm
Source/WebKitLegacy/mac/History/WebBackForwardList.mm
Source/WebKitLegacy/mac/History/WebHistory.mm
Source/WebKitLegacy/mac/History/WebHistoryItem.mm
Source/WebKitLegacy/mac/History/WebURLsWithTitles.m
Source/WebKitLegacy/mac/Misc/WebCache.mm
Source/WebKitLegacy/mac/Misc/WebCoreStatistics.mm
Source/WebKitLegacy/mac/Misc/WebKitErrors.m
Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.mm
Source/WebKitLegacy/mac/Misc/WebNSFileManagerExtras.mm
Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm
Source/WebKitLegacy/mac/Misc/WebNSURLExtras.mm
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
Source/WebKitLegacy/mac/Plugins/WebBasePluginPackage.mm
Source/WebKitLegacy/mac/Plugins/WebPluginContainerCheck.mm
Source/WebKitLegacy/mac/Plugins/WebPluginDatabase.mm
Source/WebKitLegacy/mac/Storage/WebDatabaseManager.mm
Source/WebKitLegacy/mac/WebCoreSupport/CorrectionPanel.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebOpenPanelResultListener.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm
Source/WebKitLegacy/mac/WebView/WebFrame.mm
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm
Source/WebKitLegacy/mac/WebView/WebPDFView.mm
Source/WebKitLegacy/mac/WebView/WebPreferences.mm
Source/WebKitLegacy/mac/WebView/WebScriptDebugger.mm
Source/WebKitLegacy/mac/WebView/WebTextCompletionController.mm
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/DumpRenderTree/AccessibilityController.h
Tools/DumpRenderTree/AccessibilityTextMarker.h
Tools/DumpRenderTree/AccessibilityUIElement.cpp
Tools/DumpRenderTree/AccessibilityUIElement.h
Tools/DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm
Tools/DumpRenderTree/ios/AccessibilityTextMarkerIOS.mm
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/DumpRenderTree/ios/TextInputControllerIOS.m
Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm
Tools/DumpRenderTree/mac/AccessibilityNotificationHandler.mm
Tools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm
Tools/DumpRenderTree/mac/EventSendingController.mm
Tools/DumpRenderTree/mac/MockWebNotificationProvider.mm
Tools/DumpRenderTree/mac/ObjCController.m
Tools/DumpRenderTree/mac/TestRunnerMac.mm
Tools/DumpRenderTree/mac/TextInputControllerMac.m
Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
Tools/TestRunnerShared/cocoa/LayoutTestSpellChecker.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/InAppBrowserPrivacy.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteWebArchive.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm
Tools/TestWebKitAPI/Tests/mac/WebViewCanPasteURL.mm
Tools/TestWebKitAPI/Tests/mac/WebViewCanPasteZeroPng.mm
Tools/TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm
Tools/TestWebKitAPI/ios/mainIOS.mm
Tools/TestWebKitAPI/mac/InjectedBundleControllerMac.mm
Tools/TestWebKitAPI/mac/mainMac.mm
Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h
Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.h
Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.h
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityTextMarkerIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityTextMarkerMac.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
Tools/WebKitTestRunner/ios/HIDEventGenerator.mm
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm
Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm
Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm

index f60d1fb..c91e6ea 100644 (file)
@@ -46,7 +46,6 @@
 #import <wtf/HashMap.h>
 #import <wtf/HashSet.h>
 #import <wtf/Lock.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/Vector.h>
 #import <wtf/text/WTFString.h>
 #import <wtf/text/StringHash.h>
@@ -742,7 +741,7 @@ static JSContainerConvertor::Task valueToObjectWithoutCopy(JSGlobalContextRef co
             // Normalize the number, so it will unique correctly in the hash map -
             // it's nicer not to leak this internal implementation detail!
             value = JSValueMakeNumber(context, JSValueToNumber(context, value, 0));
-            primitive = [NSNumber numberWithDouble:JSValueToNumber(context, value, 0)];
+            primitive = @(JSValueToNumber(context, value, 0));
         } else if (JSValueIsString(context, value)) {
             // Would be nice to unique strings, too.
             auto jsstring = adoptRef(JSValueToStringCopy(context, value, 0));
@@ -837,7 +836,7 @@ id valueToNumber(JSGlobalContextRef context, JSValueRef value, JSValueRef* excep
         return JSValueToBoolean(context, value) ? @YES : @NO;
 
     double result = JSValueToNumber(context, value, exception);
-    return [NSNumber numberWithDouble:*exception ? std::numeric_limits<double>::quiet_NaN() : result];
+    return @(*exception ? std::numeric_limits<double>::quiet_NaN() : result);
 }
 
 id valueToString(JSGlobalContextRef context, JSValueRef value, JSValueRef* exception)
index efaf30d..422cba5 100644 (file)
@@ -128,7 +128,7 @@ JSExportAs(testArgumentTypes,
 }
 - (void)callback:(JSValue *)function
 {
-    [function callWithArguments:[NSArray arrayWithObject:[NSNumber numberWithInt:42]]];
+    [function callWithArguments:@[@(42)]];
 }
 - (void)bogusCallback:(void(^)(int))function
 {
@@ -199,7 +199,7 @@ bool testXYZTested = false;
         return;
 
     JSValue *function = [m_onclickHandler value];
-    [function callWithArguments:[NSArray array]];
+    [function callWithArguments:@[]];
 }
 @end
 
@@ -1171,10 +1171,8 @@ static void testObjectiveCAPIMain()
         JSContext *context = [[JSContext alloc] init];
         context[@"handleTheDictionary"] = ^(NSDictionary *dict) {
             NSDictionary *expectedDict = @{
-                @"foo" : [NSNumber numberWithInt:1],
-                @"bar" : @{
-                    @"baz": [NSNumber numberWithInt:2]
-                }
+                @"foo": @(1),
+                @"bar": @{ @"baz": @(2) }
             };
             checkResult(@"recursively convert nested dictionaries", [dict isEqualToDictionary:expectedDict]);
         };
index 0b76a2c..3cd1f0f 100644 (file)
@@ -1,3 +1,18 @@
+2020-04-08  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=210138
+
+        Reviewed by Alex Christensen.
+
+        * API/JSValue.mm:
+        (valueToObjectWithoutCopy): Use @().
+        (valueToNumber): Ditto.
+        * API/tests/testapi.mm:
+        (-[TestObject callback:]): Use @[], @(), and @{}.
+        (-[TextXYZ click]): Ditto.
+        (testObjectiveCAPIMain): Ditto.
+
 2020-04-09  Devin Rousso  <drousso@apple.com>
 
         Don't emit the rhs twice in `AssignResolveNode`
index 6d27072..a540eab 100644 (file)
@@ -1,3 +1,25 @@
+2020-04-08  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=210138
+
+        Reviewed by Alex Christensen.
+
+        * WTF.xcodeproj/project.pbxproj: Added VectorCocoa.h.
+        * wtf/PlatformMac.cmake: Ditto.
+
+        * wtf/cocoa/NSURLExtras.mm: Removed unneeded include.
+        * wtf/cocoa/URLCocoa.mm: Ditto.
+
+        * wtf/cocoa/VectorCocoa.h: Added. Contains createNSArray and makeVector
+        function templates for converting NSArray to and from Vector.
+
+        * wtf/text/WTFString.h: Added makeNSArrayElement and makeVectorElement
+        functions, making createNSArray and makeVector compatible with String.
+        * wtf/text/cocoa/StringCocoa.mm:
+        (WTF::makeNSArrayElement): Added.
+        (WTF::makeVectorElement): Added.
+
 2020-04-09  David Kilzer  <ddkilzer@apple.com>
 
         Add using WTF::isInBounds to CheckedArithmetic.h
index ba25e93..e43b3b4 100644 (file)
                83F2BADE1CF9524E003E99C3 /* Function.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Function.h; sourceTree = "<group>"; };
                83FBA93119DF459700F30ADB /* TypeCasts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCasts.h; sourceTree = "<group>"; };
                86F46F5F1A2840EE00CCBF22 /* RefCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCounter.h; sourceTree = "<group>"; };
+               93241657243BC2E50032FAAE /* VectorCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VectorCocoa.h; sourceTree = "<group>"; };
                933D63191FCB6AB90032ECD6 /* StringHasher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringHasher.h; sourceTree = "<group>"; };
                9384B73E20DEA284005B73B2 /* CFXPCBridgeSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFXPCBridgeSPI.h; sourceTree = "<group>"; };
                93934BD218A1E8C300D0D6A1 /* StringViewCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringViewCocoa.mm; sourceTree = "<group>"; };
                                A30D412C1F0DE0BA00B71954 /* SoftLinking.h */,
                                EB61EDC62409CCC0001EFE36 /* SystemTracingCocoa.cpp */,
                                5CC0EE862162BC2200A1A842 /* URLCocoa.mm */,
+                               93241657243BC2E50032FAAE /* VectorCocoa.h */,
                                E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */,
                        );
                        path = cocoa;
index 6e86332..b74a277 100644 (file)
@@ -18,6 +18,7 @@ list(APPEND WTF_PUBLIC_HEADERS
     cocoa/NSURLExtras.h
     cocoa/RuntimeApplicationChecksCocoa.h
     cocoa/SoftLinking.h
+    cocoa/VectorCocoa.h
 
     darwin/WeakLinking.h
 
index 3a4fca9..47dee62 100644 (file)
@@ -30,7 +30,6 @@
 #import "NSURLExtras.h"
 
 #import <wtf/Function.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/URLHelpers.h>
 #import <wtf/URLParser.h>
index 23ee9e6..6bdae80 100644 (file)
@@ -26,7 +26,6 @@
 #import "config.h"
 #import <wtf/URL.h>
 
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/URLParser.h>
 #import <wtf/cf/CFURLExtras.h>
 #import <wtf/cocoa/NSURLExtras.h>
diff --git a/Source/WTF/wtf/cocoa/VectorCocoa.h b/Source/WTF/wtf/cocoa/VectorCocoa.h
new file mode 100644 (file)
index 0000000..e629c2f
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2020 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.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+
+namespace WTF {
+
+// Specialize the behavior of these functions by overloading the makeNSArrayElement
+// functions and makeVectorElement functions. The makeNSArrayElement function takes
+// a const& to a vector element and can return either a RetainPtr<id> or an id
+// if the value is autoreleased. The makeVectorElement function takes an ignored
+// pointer to the vector element type, making argument-dependent lookup work, and an
+// id for the array element, and returns an Optional<T> of the the vector element,
+// allowing us to filter out array elements that are not of the expected type.
+//
+//    RetainPtr<id> makeNSArrayElement(const VectorElementType& vectorElement);
+//        -or-
+//    id makeNSArrayElement(const VectorElementType& vectorElement);
+//
+//    Optional<VectorElementType> makeVectorElement(const VectorElementType*, id arrayElement);
+
+template<typename VectorType> RetainPtr<NSArray> createNSArray(const VectorType&);
+template<typename VectorElementType> Vector<VectorElementType> makeVector(NSArray *);
+
+// Implementation details of the function templates above.
+
+template<typename VectorType> RetainPtr<NSArray> createNSArray(const VectorType& vector)
+{
+    auto size = vector.size();
+    auto array = adoptNS([[NSMutableArray alloc] initWithCapacity:size]);
+    for (auto& element : vector)
+        [array addObject:getPtr(makeNSArrayElement(element))];
+    return array;
+}
+
+template<typename VectorElementType> Vector<VectorElementType> makeVector(NSArray *array)
+{
+    Vector<VectorElementType> vector;
+    vector.reserveInitialCapacity(array.count);
+    for (id element in array) {
+        constexpr const VectorElementType* typedNull = nullptr;
+        if (auto vectorElement = makeVectorElement(typedNull, element))
+            vector.uncheckedAppend(WTFMove(*vectorElement));
+    }
+    return vector;
+}
+
+} // namespace WTF
+
+using WTF::makeVector;
index c2adfbe..a2370c7 100644 (file)
@@ -454,6 +454,13 @@ template<> struct IntegerToStringConversionTrait<String> {
     static String flush(LChar* characters, unsigned length, void*) { return { characters, length }; }
 };
 
+#ifdef __OBJC__
+
+WTF_EXPORT_PRIVATE RetainPtr<id> makeNSArrayElement(const String&);
+WTF_EXPORT_PRIVATE Optional<String> makeVectorElement(const String*, id);
+
+#endif
+
 // Definitions of string operations
 
 inline String::String(StringImpl& string)
index 1bfc528..958bcf0 100644 (file)
@@ -48,4 +48,16 @@ String::String(NSString *str)
     }
 }
 
+RetainPtr<id> makeNSArrayElement(const String& vectorElement)
+{
+    return adoptNS((__bridge_transfer id)vectorElement.createCFString().leakRef());
+}
+
+Optional<String> makeVectorElement(const String*, id arrayElement)
+{
+    if (![arrayElement isKindOfClass:NSString.class])
+        return WTF::nullopt;
+    return { { arrayElement } };
+}
+
 }
index 39bc99a..071ec5b 100644 (file)
@@ -1,3 +1,156 @@
+2020-04-08  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=210138
+
+        Reviewed by Alex Christensen.
+
+        - Added createNSArray and makeVector.
+        - Use createNSArray and makeVector<String> in many places where we convert
+          between NSArray and Vector, replacing multiple existing functions that were
+          doing the same job before; later can use them even more.
+        - Use @[] many places where we create an autoreleased NSArray.
+        - Use @{} many places where we create an autoreleased NSDictionary.
+        - Use @() many places where we create an autoreleased NSNumber.
+
+        * PlatformMac.cmake: Moved Float/IntRectMac.mm to Float/IntRectCocoa.mm.
+        * SourcesCocoa.txt: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (AXAttributeStringSetBlockquoteLevel): Use @().
+        (AXAttributeStringSetHeadingLevel): Use @().
+        (-[WebAccessibilityObjectWrapper textMarkerRangeForSelection]): Use @[].
+        (-[WebAccessibilityObjectWrapper _stringFromStartMarker:toEndMarker:attributed:]): Use @[].
+        (-[WebAccessibilityObjectWrapper elementsForRange:]): Use @[].
+        (-[WebAccessibilityObjectWrapper textMarkersForRange:]): Use @[].
+
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::textReplacementChangeDictionary): Use @().
+
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (makeVectorElement): Aded overload for AccessibilitySearchKey.
+        (accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute):
+        Use makeVector<AccessibilitySearchKey>.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (accessibilityTextCriteriaForParameterizedAttribute): Use makeVector<String>.
+        (accessibilitySearchTextCriteriaForParameterizedAttribute): Use makeVector<String>.
+        (AXAttributeStringSetStyle): Use @().
+        (AXAttributeStringSetBlockquoteLevel): Use @().
+        (AXAttributeStringSetHeadingLevel): Use @().
+        (-[WebAccessibilityObjectWrapper accessibilityActionNames]): Use @[].
+        (convertStringsToNSArray): Deleted.
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        Use @(), @[], and createNSArray.
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+        Ditto.
+
+        * bridge/objc/WebScriptObject.mm:
+        (+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
+        Use @().
+
+        * editing/cocoa/AlternativeTextUIController.mm:
+        (WebCore::AlternativeTextUIController::alternativesForContext):
+        Use makeVector<String>.
+
+        * editing/cocoa/HTMLConverter.mm:
+        (defaultParagraphStyle): Use @[].
+        (HTMLConverter::computedAttributesForElement): Use @().
+        (HTMLConverter::_processMetaElementWithName): Use @().
+        (HTMLConverter::_addTableForElement): Use @().
+
+        * page/ios/FrameIOS.mm:
+        (WebCore::Frame::interpretationsForCurrentRoot const): Use @[].
+
+        * platform/cocoa/MIMETypeRegistryCocoa.mm:
+        (WebCore::MIMETypeRegistry::getExtensionsForMIMEType): Use makeVector<String>.
+
+        * platform/graphics/FloatRect.h: Added makeNSArrayElement overload so we can
+        convert Vector<FloatRect> into NSArray<NSValue>.
+        * platform/graphics/IntRect.h: Similarly for IntRect.
+
+        * platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
+        (WebCore::MediaSelectionGroupAVFObjC::updateOptions): Use createNSArray.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::mediaDescriptionForKind): Use @[].
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Use @().
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Use @().
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::checkPlayability): Use @[].
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoOutput): Use @{} and @().
+
+        * platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
+        (WebCore::PlatformCAAnimationCocoa::valueFunction const):
+        (WebCore::PlatformCAAnimationCocoa::setFromValue):
+        (WebCore::PlatformCAAnimationCocoa::copyFromValueFrom):
+        (WebCore::PlatformCAAnimationCocoa::setToValue):
+        (WebCore::PlatformCAAnimationCocoa::copyToValueFrom):
+        (WebCore::PlatformCAAnimationCocoa::setValues):
+        (WebCore::PlatformCAAnimationCocoa::copyValuesFrom):
+        (WebCore::PlatformCAAnimationCocoa::setKeyTimes):
+        (WebCore::PlatformCAAnimationCocoa::copyKeyTimesFrom):
+        (WebCore::PlatformCAAnimationCocoa::setTimingFunctions):
+        (WebCore::PlatformCAAnimationCocoa::copyTimingFunctionsFrom):
+        Use @(), @[], modern for loops, auto, and allocate with capacity.
+
+        * platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm:
+        (WebCore::PlatformCAFilters::filterValueForOperation): Use @().
+
+        * platform/graphics/cocoa/FloatRectCocoa.mm: Moved from mac/FloatRectMac.mm.
+        (WebCore::makeNSArrayElement): Added so we can convert Vector<FloatRect>
+        into NSArray<NSValue>.
+        * platform/graphics/cocoa/IntRectCocoa.mm: Moved from mac/IntRectMac.mm.
+        (WebCore::makeNSArrayElement): Similarly for IntRect.
+        (WebCore::enclosingIntRect): Use clampTo to be consistent with what
+        enclosingIntRect(FloatRect) does (while fixing check-webkit-style complaint).
+
+        * platform/graphics/cocoa/WebGLLayer.mm:
+        (-[WebGLLayer display]): Add WebCore namespace prefix; needed depending on
+        how sources get unified (and was affecting my local build when it temporarily
+        had an additional source file).
+        (-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]): Ditto.
+        (-[WebGLLayer bindFramebufferToNextAvailableSurface]): Ditto.
+
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::systemFontModificationAttributes): Use @().
+
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::getTypes): Use makeVector<String>.
+        (WebCore::createItemProviderRegistrationList): Use createNSArray.
+        (WebCore::PlatformPasteboard::updateSupportedTypeIdentifiers): Use createNSArray.
+
+        * platform/ios/WebItemProviderPasteboard.mm:
+        (-[WebItemProviderPasteboard setItemProviders:]): Use @[].
+        * platform/ios/wak/WAKView.mm:
+        (-[WAKView subviews]): Dittto.
+
+        * platform/mac/PlatformPasteboardMac.mm:
+        (WebCore::PlatformPasteboard::getTypes): Use makeVector<String>.
+        (WebCore::PlatformPasteboard::getPathnamesForType const): Use makeVector<String>.
+        (WebCore::PlatformPasteboard::addTypes): Use makeVector<String>.
+        (WebCore::PlatformPasteboard::setTypes): Use makeVector<String>.
+
+        * platform/mac/StringUtilities.h: Removed
+        webCoreStringVectorFromNSStringArray, replaced by makeVector<String>
+        * platform/mac/StringUtilities.mm:
+        (WebCore::webCoreStringVectorFromNSStringArray): Deleted.
+
+        * platform/mac/WebCoreNSURLExtras.mm: Removed unneeded include.
+
+        * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+        (WebCore::MediaRecorderPrivateWriter::setVideoInput): Use @().
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::setupCaptureSession): Use @().
+        * platform/network/cocoa/CookieCocoa.mm:
+        (WebCore::Cookie::operator NSHTTPCookie * _Nullable  const): Use @().
+
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+        (WebCore::NetworkStorageSession::setCookiesFromDOM const): Use @{}.
+
+        * platform/network/cocoa/ResourceRequestCocoa.mm:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest): Use @YES/@NO.
+
 2020-04-09  Daniel Bates  <dabates@apple.com>
 
         [ macOS debug wk2 ] REGRESSION(r259761): ASSERTION FAILED: !needsLayout() on fast/events/scroll-subframe-in-rendering-update.html
index c23e494..622b43a 100644 (file)
@@ -307,16 +307,18 @@ list(APPEND WebCore_SOURCES
     platform/graphics/cg/TransformationMatrixCG.cpp
     platform/graphics/cg/UTIRegistry.cpp
 
-    platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm
-    platform/graphics/cocoa/GraphicsContextCocoa.mm
+    platform/graphics/cocoa/FloatRectCocoa.mm
     platform/graphics/cocoa/FontCacheCoreText.cpp
     platform/graphics/cocoa/FontCascadeCocoa.mm
     platform/graphics/cocoa/FontCocoa.mm
     platform/graphics/cocoa/FontDescriptionCocoa.cpp
     platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
     platform/graphics/cocoa/FontPlatformDataCocoa.mm
+    platform/graphics/cocoa/GraphicsContextCocoa.mm
+    platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm
     platform/graphics/cocoa/IOSurface.mm
     platform/graphics/cocoa/IOSurfacePoolCocoa.mm
+    platform/graphics/cocoa/IntRectCocoa.mm
     platform/graphics/cocoa/WebActionDisablingCALayerDelegate.mm
     platform/graphics/cocoa/WebCoreCALayerExtras.mm
     platform/graphics/cocoa/WebCoreDecompressionSession.mm
@@ -335,7 +337,6 @@ list(APPEND WebCore_SOURCES
     platform/graphics/mac/ComplexTextControllerCoreText.mm
     platform/graphics/mac/DisplayRefreshMonitorMac.cpp
     platform/graphics/mac/FloatPointMac.mm
-    platform/graphics/mac/FloatRectMac.mm
     platform/graphics/mac/FloatSizeMac.mm
     platform/graphics/mac/FontCacheMac.mm
     platform/graphics/mac/FontCustomPlatformData.cpp
@@ -343,7 +344,6 @@ list(APPEND WebCore_SOURCES
     platform/graphics/mac/IconMac.mm
     platform/graphics/mac/ImageMac.mm
     platform/graphics/mac/IntPointMac.mm
-    platform/graphics/mac/IntRectMac.mm
     platform/graphics/mac/IntSizeMac.mm
     platform/graphics/mac/PDFDocumentImageMac.mm
     platform/graphics/mac/SimpleFontDataCoreText.cpp
index ffc61b4..0bafd36 100644 (file)
@@ -315,6 +315,7 @@ platform/graphics/cg/UTIRegistry.cpp
 platform/graphics/cocoa/ColorCocoa.mm
 platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm
 platform/graphics/cocoa/GraphicsContextCocoa.mm
+platform/graphics/cocoa/FloatRectCocoa.mm
 platform/graphics/cocoa/FontCacheCoreText.cpp
 platform/graphics/cocoa/FontCascadeCocoa.mm
 platform/graphics/cocoa/FontCocoa.mm
@@ -324,6 +325,7 @@ platform/graphics/cocoa/FontPlatformDataCocoa.mm
 platform/graphics/cocoa/HEVCUtilitiesCocoa.mm
 platform/graphics/cocoa/IOSurface.mm
 platform/graphics/cocoa/IOSurfacePoolCocoa.mm
+platform/graphics/cocoa/IntRectCocoa.mm
 platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp
 platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
 platform/graphics/cocoa/WebActionDisablingCALayerDelegate.mm
@@ -367,7 +369,6 @@ platform/graphics/mac/ColorMac.mm
 platform/graphics/mac/ComplexTextControllerCoreText.mm
 platform/graphics/mac/DisplayRefreshMonitorMac.cpp
 platform/graphics/mac/FloatPointMac.mm
-platform/graphics/mac/FloatRectMac.mm
 platform/graphics/mac/FloatSizeMac.mm
 platform/graphics/mac/FontCacheMac.mm
 platform/graphics/mac/FontCustomPlatformData.cpp
@@ -375,7 +376,6 @@ platform/graphics/mac/GlyphPageMac.cpp
 platform/graphics/mac/IconMac.mm
 platform/graphics/mac/ImageMac.mm
 platform/graphics/mac/IntPointMac.mm
-platform/graphics/mac/IntRectMac.mm
 platform/graphics/mac/IntSizeMac.mm
 platform/graphics/mac/PDFDocumentImageMac.mm
 platform/graphics/mac/SimpleFontDataCoreText.cpp
index 3ad53cf..7acdc4d 100644 (file)
                B27535480B053814002CE64F /* IntSizeHash.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IntSizeHash.h; sourceTree = "<group>"; };
                B275354A0B053814002CE64F /* ColorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ColorMac.mm; sourceTree = "<group>"; };
                B275354B0B053814002CE64F /* FloatPointMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FloatPointMac.mm; sourceTree = "<group>"; };
-               B275354C0B053814002CE64F /* FloatRectMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FloatRectMac.mm; sourceTree = "<group>"; };
+               B275354C0B053814002CE64F /* FloatRectCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FloatRectCocoa.mm; sourceTree = "<group>"; };
                B275354D0B053814002CE64F /* FloatSizeMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FloatSizeMac.mm; sourceTree = "<group>"; };
                B275354E0B053814002CE64F /* ImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ImageMac.mm; sourceTree = "<group>"; };
                B275354F0B053814002CE64F /* IntPointMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntPointMac.mm; sourceTree = "<group>"; };
-               B27535500B053814002CE64F /* IntRectMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntRectMac.mm; sourceTree = "<group>"; };
+               B27535500B053814002CE64F /* IntRectCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntRectCocoa.mm; sourceTree = "<group>"; };
                B27535510B053814002CE64F /* IntSizeMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntSizeMac.mm; sourceTree = "<group>"; };
                B27535520B053814002CE64F /* Path.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Path.cpp; sourceTree = "<group>"; };
                B27535530B053814002CE64F /* Path.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Path.h; sourceTree = "<group>"; };
                                49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */,
                                2DE70022192FE82A00B0975C /* DisplayRefreshMonitorMac.h */,
                                B275354B0B053814002CE64F /* FloatPointMac.mm */,
-                               B275354C0B053814002CE64F /* FloatRectMac.mm */,
                                B275354D0B053814002CE64F /* FloatSizeMac.mm */,
                                B2AFFC740D00A5C10030074D /* FontCacheMac.mm */,
                                B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */,
                                B275358D0B053A66002CE64F /* IconMac.mm */,
                                B275354E0B053814002CE64F /* ImageMac.mm */,
                                B275354F0B053814002CE64F /* IntPointMac.mm */,
-                               B27535500B053814002CE64F /* IntRectMac.mm */,
                                B27535510B053814002CE64F /* IntSizeMac.mm */,
                                2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */,
                                163E88F5118A39D200ED9231 /* SimpleFontDataCoreText.cpp */,
                        children = (
                                F48D2AA32159740D00C6752B /* ColorCocoa.h */,
                                F48D2AA42159740D00C6752B /* ColorCocoa.mm */,
+                               B275354C0B053814002CE64F /* FloatRectCocoa.mm */,
                                1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */,
                                C2458E611FE8979E00594759 /* FontCacheCoreText.h */,
                                B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
                                49FFBF1C11C8550E006A7118 /* GraphicsContextGLOpenGLCocoa.mm */,
                                CDA595962146DF7800A84185 /* HEVCUtilitiesCocoa.h */,
                                CDA595972146DF7800A84185 /* HEVCUtilitiesCocoa.mm */,
+                               B27535500B053814002CE64F /* IntRectCocoa.mm */,
                                2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
                                2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
                                AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */,
index 149a6f2..ad471cc 100644 (file)
@@ -2136,7 +2136,7 @@ static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrS
     int quoteLevel = blockquoteLevel(renderer);
     
     if (quoteLevel)
-        [attrString addAttribute:UIAccessibilityTokenBlockquoteLevel value:[NSNumber numberWithInt:quoteLevel] range:range];
+        [attrString addAttribute:UIAccessibilityTokenBlockquoteLevel value:@(quoteLevel) range:range];
     else
         [attrString removeAttribute:UIAccessibilityTokenBlockquoteLevel range:range];
 }
@@ -2150,7 +2150,7 @@ static void AXAttributeStringSetHeadingLevel(NSMutableAttributedString* attrStri
     int parentHeadingLevel = parentObject->headingLevel();
     
     if (parentHeadingLevel)
-        [attrString addAttribute:UIAccessibilityTokenHeadingLevel value:[NSNumber numberWithInt:parentHeadingLevel] range:range];
+        [attrString addAttribute:UIAccessibilityTokenHeadingLevel value:@(parentHeadingLevel) range:range];
     else
         [attrString removeAttribute:UIAccessibilityTokenHeadingLevel range:range];
 }
@@ -2443,7 +2443,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     if (!startMarker || !endMarker)
         return nil;
     
-    return [NSArray arrayWithObjects:startMarker, endMarker, nil];
+    return @[startMarker, endMarker];
 }
 
 - (WebAccessibilityTextMarker *)textMarkerForPosition:(NSInteger)position
@@ -2468,7 +2468,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     if (!startMarker || !endMarker)
         return nil;
     
-    NSArray* array = [self arrayOfTextForTextMarkers:[NSArray arrayWithObjects:startMarker, endMarker, nil] attributed:attributed];
+    NSArray* array = [self arrayOfTextForTextMarkers:@[startMarker, endMarker] attributed:attributed];
     Class returnClass = attributed ? [NSMutableAttributedString class] : [NSMutableString class];
     id returnValue = [[(NSString *)[returnClass alloc] init] autorelease];
     
@@ -2586,7 +2586,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     if (!startMarker || !endMarker)
         return nil;
     
-    NSArray* array = [self arrayOfTextForTextMarkers:[NSArray arrayWithObjects:startMarker, endMarker, nil] attributed:NO];
+    NSArray* array = [self arrayOfTextForTextMarkers:@[startMarker, endMarker] attributed:NO];
     NSMutableArray* elements = [NSMutableArray array];
     for (id element in array) {
         if (![element isKindOfClass:[AccessibilityObjectWrapper class]])
@@ -2852,7 +2852,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     WebAccessibilityTextMarker* end = [WebAccessibilityTextMarker startOrEndTextMarkerForRange:range isStart:NO cache:self.axBackingObject->axObjectCache()];
     if (!start || !end)
         return nil;
-    return [NSArray arrayWithObjects:start, end, nil];
+    return @[start, end];
 }
 
 - (NSString *)accessibilityExpandedTextValue
index 688782c..b15cd05 100644 (file)
@@ -445,7 +445,7 @@ static NSDictionary *textReplacementChangeDictionary(AXCoreObject& object, AXTex
     NSMutableDictionary *change = [[NSMutableDictionary alloc] initWithCapacity:4];
     [change setObject:@(platformEditTypeForWebCoreEditType(type)) forKey:NSAccessibilityTextEditType];
     if (length > AXValueChangeTruncationLength) {
-        [change setObject:[NSNumber numberWithInt:length] forKey:NSAccessibilityTextChangeValueLength];
+        [change setObject:@(length) forKey:NSAccessibilityTextChangeValueLength];
         text = [text substringToIndex:AXValueChangeTruncationLength];
     }
     [change setObject:text forKey:NSAccessibilityTextChangeValue];
index 66d3526..71882b8 100644 (file)
@@ -65,6 +65,7 @@
 #import "TextCheckingHelper.h"
 #import "VisibleUnits.h"
 #import "WebCoreFrameView.h"
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if PLATFORM(MAC)
 #import <pal/spi/mac/HIServicesSPI.h>
@@ -692,6 +693,13 @@ static AccessibilitySearchKey accessibilitySearchKeyForString(const String& valu
     return static_cast<int>(searchKey) ? searchKey : AccessibilitySearchKey::AnyType;
 }
 
+static Optional<AccessibilitySearchKey> makeVectorElement(const AccessibilitySearchKey*, id arrayElement)
+{
+    if (![arrayElement isKindOfClass:NSString.class])
+        return WTF::nullopt;
+    return { { accessibilitySearchKeyForString(arrayElement) } };
+}
+
 AccessibilitySearchCriteria accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute(const NSDictionary *parameterizedAttribute)
 {
     NSString *directionParameter = [parameterizedAttribute objectForKey:@"AXDirection"];
@@ -730,16 +738,9 @@ AccessibilitySearchCriteria accessibilitySearchCriteriaForSearchPredicateParamet
     
     if ([searchKeyParameter isKindOfClass:[NSString class]])
         criteria.searchKeys.append(accessibilitySearchKeyForString(searchKeyParameter));
-    else if ([searchKeyParameter isKindOfClass:[NSArray class]]) {
-        size_t searchKeyCount = static_cast<size_t>([searchKeyParameter count]);
-        criteria.searchKeys.reserveInitialCapacity(searchKeyCount);
-        for (size_t i = 0; i < searchKeyCount; ++i) {
-            NSString *searchKey = [searchKeyParameter objectAtIndex:i];
-            if ([searchKey isKindOfClass:[NSString class]])
-                criteria.searchKeys.uncheckedAppend(accessibilitySearchKeyForString(searchKey));
-        }
-    }
-    
+    else if ([searchKeyParameter isKindOfClass:[NSArray class]])
+        criteria.searchKeys = makeVector<AccessibilitySearchKey>(searchKeyParameter);
+
     return criteria;
 }
 
index 3640433..b403d3f 100644 (file)
@@ -78,7 +78,7 @@
 #import "WebCoreFrameView.h"
 #import <pal/spi/cocoa/NSAccessibilitySPI.h>
 #import <pal/spi/mac/HIServicesSPI.h>
-#import <wtf/ObjCRuntimeExtras.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if ENABLE(TREE_DEBUGGING)
 #import <wtf/text/StringBuilder.h>
@@ -645,14 +645,8 @@ static std::pair<AccessibilitySearchTextCriteria, AccessibilityTextOperation> ac
     if ([replacementStringParameter isKindOfClass:[NSString class]])
         operation.replacementText = replacementStringParameter;
 
-    if ([searchStringsParameter isKindOfClass:[NSArray class]]) {
-        size_t searchStringsCount = static_cast<size_t>([searchStringsParameter count]);
-        criteria.searchStrings.reserveInitialCapacity(searchStringsCount);
-        for (NSString *searchString in searchStringsParameter) {
-            if ([searchString isKindOfClass:[NSString class]])
-                criteria.searchStrings.uncheckedAppend(searchString);
-        }
-    }
+    if ([searchStringsParameter isKindOfClass:[NSArray class]])
+        criteria.searchStrings = makeVector<String>(searchStringsParameter);
 
     return std::make_pair(criteria, operation);
 }
@@ -665,14 +659,8 @@ static AccessibilitySearchTextCriteria accessibilitySearchTextCriteriaForParamet
     NSString *start = [params objectForKey:NSAccessibilitySearchTextStartFrom];
     NSString *direction = [params objectForKey:NSAccessibilitySearchTextDirection];
 
-    if ([searchStrings isKindOfClass:[NSArray class]]) {
-        size_t searchStringsCount = static_cast<size_t>([searchStrings count]);
-        criteria.searchStrings.reserveInitialCapacity(searchStringsCount);
-        for (NSString *searchString in searchStrings) {
-            if ([searchString isKindOfClass:[NSString class]])
-                criteria.searchStrings.uncheckedAppend(searchString);
-        }
-    }
+    if ([searchStrings isKindOfClass:[NSArray class]])
+        criteria.searchStrings = makeVector<String>(searchStrings);
 
     if ([start isKindOfClass:[NSString class]]) {
         if ([start isEqualToString:NSAccessibilitySearchTextStartFromBegin])
@@ -1019,9 +1007,9 @@ static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, Ren
     // set super/sub scripting
     VerticalAlign alignment = style.verticalAlign();
     if (alignment == VerticalAlign::Sub)
-        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, [NSNumber numberWithInt:(-1)], range);
+        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, @(-1), range);
     else if (alignment == VerticalAlign::Super)
-        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, [NSNumber numberWithInt:1], range);
+        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, @(1), range);
     else
         [attrString removeAttribute:NSAccessibilitySuperscriptTextAttribute range:range];
     
@@ -1074,7 +1062,7 @@ static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrS
     int quoteLevel = obj->blockquoteLevel();
     
     if (quoteLevel)
-        [attrString addAttribute:NSAccessibilityBlockQuoteLevelAttribute value:[NSNumber numberWithInt:quoteLevel] range:range];
+        [attrString addAttribute:NSAccessibilityBlockQuoteLevelAttribute value:@(quoteLevel) range:range];
     else
         [attrString removeAttribute:NSAccessibilityBlockQuoteLevelAttribute range:range];
 }
@@ -1153,7 +1141,7 @@ static void AXAttributeStringSetHeadingLevel(NSMutableAttributedString* attrStri
     }
     
     if (parentHeadingLevel)
-        [attrString addAttribute:@"AXHeadingLevel" value:[NSNumber numberWithInt:parentHeadingLevel] range:range];
+        [attrString addAttribute:@"AXHeadingLevel" value:@(parentHeadingLevel) range:range];
     else
         [attrString removeAttribute:@"AXHeadingLevel" range:range];
 }
@@ -1312,17 +1300,17 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 
     // All elements should get ShowMenu and ScrollToVisible.
     // But certain earlier VoiceOver versions do not support scroll to visible, and it confuses them to see it in the list.
-    static NSArray *defaultElementActions = [[NSArray alloc] initWithObjects:NSAccessibilityShowMenuAction, NSAccessibilityScrollToVisibleAction, nil];
+    static NSArray *defaultElementActions = [@[NSAccessibilityShowMenuAction, NSAccessibilityScrollToVisibleAction] retain];
 
     // Action elements allow Press.
     // The order is important to VoiceOver, which expects the 'default' action to be the first action. In this case the default action should be press.
-    static NSArray *actionElementActions = [[NSArray alloc] initWithObjects:NSAccessibilityPressAction, NSAccessibilityShowMenuAction, NSAccessibilityScrollToVisibleAction, nil];
+    static NSArray *actionElementActions = [@[NSAccessibilityPressAction, NSAccessibilityShowMenuAction, NSAccessibilityScrollToVisibleAction] retain];
 
     // Menu elements allow Press and Cancel.
     static NSArray *menuElementActions = [[actionElementActions arrayByAddingObject:NSAccessibilityCancelAction] retain];
 
     // Slider elements allow Increment/Decrement.
-    static NSArray *sliderActions = [[defaultElementActions arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:NSAccessibilityIncrementAction, NSAccessibilityDecrementAction, nil]] retain];
+    static NSArray *sliderActions = [[defaultElementActions arrayByAddingObjectsFromArray:@[NSAccessibilityIncrementAction, NSAccessibilityDecrementAction]] retain];
 
     NSArray *actions;
     if (backingObject->supportsPressAction())
@@ -1888,14 +1876,6 @@ static void convertToVector(NSArray* array, AccessibilityObject::AccessibilityCh
     }
 }
 
-static NSMutableArray *convertStringsToNSArray(const Vector<String>& vector)
-{
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:vector.size()];
-    for (const auto& string : vector)
-        [array addObject:string];
-    return array;
-}
-
 - (id)textMarkerRangeForSelection
 {
     VisibleSelection selection = self.axBackingObject->selection();
@@ -2402,9 +2382,9 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         if ([attributeName isEqualToString:@"AXLoaded"])
             return [NSNumber numberWithBool:backingObject->isLoaded()];
         if ([attributeName isEqualToString:@"AXLayoutCount"])
-            return [NSNumber numberWithInt:backingObject->layoutCount()];
+            return @(backingObject->layoutCount());
         if ([attributeName isEqualToString:NSAccessibilityLoadingProgressAttribute])
-            return [NSNumber numberWithDouble:backingObject->estimatedLoadingProgress()];
+            return @(backingObject->estimatedLoadingProgress());
         if ([attributeName isEqualToString:NSAccessibilityPreventKeyboardDOMEventDispatchAttribute])
             return [NSNumber numberWithBool:backingObject->preventKeyboardDOMEventDispatch()];
         if ([attributeName isEqualToString:NSAccessibilityCaretBrowsingEnabledAttribute])
@@ -2418,7 +2398,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
             int length = backingObject->textLength();
             if (length < 0)
                 return nil;
-            return [NSNumber numberWithUnsignedInt:length];
+            return @(length);
         }
         if ([attributeName isEqualToString: NSAccessibilitySelectedTextAttribute]) {
             String selectedText = backingObject->selectedText();
@@ -2447,7 +2427,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
             if (lineNumber < 0)
                 return nil;
 
-            return [NSNumber numberWithInt:lineNumber];
+            return @(lineNumber);
         }
     }
 
@@ -2506,16 +2486,16 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         if (backingObject->roleValue() == AccessibilityRole::SliderThumb)
             return [NSNumber numberWithFloat:backingObject->parentObject()->valueForRange()];
         if (backingObject->isHeading())
-            return [NSNumber numberWithInt:backingObject->headingLevel()];
+            return @(backingObject->headingLevel());
 
         if (backingObject->isCheckboxOrRadio() || backingObject->isMenuItem() || backingObject->isSwitch() || backingObject->isToggleButton()) {
             switch (backingObject->checkboxOrRadioValue()) {
             case AccessibilityButtonState::Off:
-                return [NSNumber numberWithInt:0];
+                return @(0);
             case AccessibilityButtonState::On:
-                return [NSNumber numberWithInt:1];
+                return @(1);
             case AccessibilityButtonState::Mixed:
-                return [NSNumber numberWithInt:2];
+                return @(2);
             }
         }
 
@@ -2535,7 +2515,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         }
 
         if (backingObject->isTabItem())
-            return [NSNumber numberWithInt:backingObject->isSelected()];
+            return @(backingObject->isSelected());
 
         if (backingObject->isColorWell()) {
             int r, g, b;
@@ -2691,7 +2671,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 
     if (backingObject->isTableColumn()) {
         if ([attributeName isEqualToString:NSAccessibilityIndexAttribute])
-            return [NSNumber numberWithUnsignedInt:backingObject->columnIndex()];
+            return @(backingObject->columnIndex());
 
         // rows attribute for a column is the list of all the elements in that column at each row
         if ([attributeName isEqualToString:NSAccessibilityRowsAttribute]
@@ -2742,7 +2722,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 
         // TreeRoles do not support columns, but Mac AX expects to be able to ask about columns at the least.
         if ([attributeName isEqualToString:NSAccessibilityColumnsAttribute])
-            return [NSArray array];
+            return @[];
     }
 
     if ([attributeName isEqualToString:NSAccessibilityIndexAttribute]) {
@@ -2760,13 +2740,13 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
             size_t count = rowsCopy.size();
             for (size_t k = 0; k < count; ++k)
                 if (rowsCopy[k]->wrapper() == self)
-                    return [NSNumber numberWithUnsignedInt:k];
+                    return @(k);
 
             return nil;
         }
 
         if (backingObject->isTableRow())
-            return [NSNumber numberWithInt:backingObject->rowIndex()];
+            return @(backingObject->rowIndex());
     }
 
     // The rows that are considered inside this row.
@@ -2801,7 +2781,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         int level = backingObject->hierarchicalLevel();
         if (level > 0)
             level -= 1;
-        return [NSNumber numberWithInt:level];
+        return @(level);
     }
     if ([attributeName isEqualToString:NSAccessibilityDisclosingAttribute])
         return [NSNumber numberWithBool:backingObject->isExpanded()];
@@ -2832,9 +2812,9 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     }
 
     if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
-        return [NSNumber numberWithUnsignedInt:backingObject->blockquoteLevel()];
+        return @(backingObject->blockquoteLevel());
     if ([attributeName isEqualToString:@"AXTableLevel"])
-        return [NSNumber numberWithInt:backingObject->tableLevel()];
+        return @(backingObject->tableLevel());
 
     if ([attributeName isEqualToString: NSAccessibilityLinkedUIElementsAttribute]) {
         AccessibilityObject::AccessibilityChildrenVector linkedUIElements;
@@ -2851,7 +2831,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     if ([attributeName isEqualToString: NSAccessibilityServesAsTitleForUIElementsAttribute] && backingObject->isMenuButton()) {
         AccessibilityObject* uiElement = downcast<AccessibilityRenderObject>(*backingObject).menuForMenuButton();
         if (uiElement)
-            return [NSArray arrayWithObject:uiElement->wrapper()];
+            return @[uiElement->wrapper()];
     }
 
     if ([attributeName isEqualToString:NSAccessibilityTitleUIElementAttribute]) {
@@ -2921,17 +2901,15 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     }
 
     if ([attributeName isEqualToString:NSAccessibilityARIAPosInSetAttribute])
-        return [NSNumber numberWithInt:backingObject->posInSet()];
+        return @(backingObject->posInSet());
     if ([attributeName isEqualToString:NSAccessibilityARIASetSizeAttribute])
-        return [NSNumber numberWithInt:backingObject->setSize()];
+        return @(backingObject->setSize());
 
     if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
         return [NSNumber numberWithBool:backingObject->isARIAGrabbed()];
 
-    if ([attributeName isEqualToString:NSAccessibilityDropEffectsAttribute]) {
-        Vector<String> dropEffects = backingObject->determineARIADropEffects();
-        return convertStringsToNSArray(dropEffects);
-    }
+    if ([attributeName isEqualToString:NSAccessibilityDropEffectsAttribute])
+        return createNSArray(backingObject->determineARIADropEffects()).autorelease();
 
     if ([attributeName isEqualToString:NSAccessibilityPlaceholderValueAttribute])
         return backingObject->placeholderValue();
@@ -3016,7 +2994,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     if ([attributeName isEqualToString:NSAccessibilityDOMClassListAttribute]) {
         Vector<String> classList;
         backingObject->classList(classList);
-        return convertStringsToNSArray(classList);
+        return createNSArray(classList).autorelease();
     }
 
     // This allows us to connect to a plugin that creates a shadow node for editing (like PDFs).
@@ -4101,7 +4079,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
             VisiblePosition visiblePos = [protectedSelf visiblePositionForTextMarker:textMarker];
             return backingObject->lineForPosition(visiblePos);
         });
-        return [NSNumber numberWithInt:result];
+        return @(result);
     }
 
     if ([attribute isEqualToString:@"AXTextMarkerRangeForLine"]) {
@@ -4329,7 +4307,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         });
         if (length < 0)
             return nil;
-        return [NSNumber numberWithInt:length];
+        return @(length);
     }
 
     // Used only by DumpRenderTree (so far).
@@ -4379,7 +4357,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
             int lineNumber = backingObject->doAXLineForIndex([number intValue]);
             if (lineNumber < 0)
                 return nil;
-            return [NSNumber numberWithUnsignedInt:lineNumber];
+            return @(lineNumber);
         }
 
         if ([attribute isEqualToString: (NSString *)kAXRangeForLineParameterizedAttribute]) {
index de3a43d..e906221 100644 (file)
@@ -586,7 +586,7 @@ static void getListFromNSArray(JSC::JSGlobalObject* lexicalGlobalObject, NSArray
         return asString(value)->value(rootObject->globalObject());
 
     if (value.isNumber())
-        return [NSNumber numberWithDouble:value.asNumber()];
+        return @(value.asNumber());
 
     if (value.isBoolean())
         return [NSNumber numberWithBool:value.asBoolean()];
index 5072d6b..e58eaed 100644 (file)
@@ -28,7 +28,8 @@
 
 #if USE(DICTATION_ALTERNATIVES)
 
-#import <WebCore/FloatRect.h>
+#import "FloatRect.h"
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if USE(APPKIT)
 #import <AppKit/NSSpellChecker.h>
@@ -47,12 +48,7 @@ uint64_t AlternativeTextUIController::addAlternatives(const RetainPtr<NSTextAlte
 
 Vector<String> AlternativeTextUIController::alternativesForContext(uint64_t context)
 {
-    NSTextAlternatives *textAlternatives = m_contextController.alternativesForContext(context);
-    Vector<String> alternativeStrings;
-    alternativeStrings.reserveInitialCapacity(textAlternatives.alternativeStrings.count);
-    for (NSString *string in textAlternatives.alternativeStrings)
-        alternativeStrings.uncheckedAppend(string);
-    return alternativeStrings;
+    return makeVector<String>(m_contextController.alternativesForContext(context).alternativeStrings);
 }
 
 void AlternativeTextUIController::clear()
index a543ac2..4f46352 100644 (file)
@@ -539,7 +539,7 @@ static NSParagraphStyle *defaultParagraphStyle()
     if (!defaultParagraphStyle) {
         defaultParagraphStyle = [[PlatformNSParagraphStyle defaultParagraphStyle] mutableCopy];
         [defaultParagraphStyle setDefaultTabInterval:36];
-        [defaultParagraphStyle setTabStops:[NSArray array]];
+        [defaultParagraphStyle setTabStops:@[]];
     }
     return defaultParagraphStyle;
 }
@@ -1027,7 +1027,7 @@ NSDictionary *HTMLConverter::computedAttributesForElement(Element& element)
     float strokeWidth = 0.0;
     if (_caches->floatPropertyValueForNode(element, CSSPropertyWebkitTextStrokeWidth, strokeWidth)) {
         float textStrokeWidth = strokeWidth / ([font pointSize] * 0.01);
-        [attrs setObject:[NSNumber numberWithDouble:textStrokeWidth] forKey:NSStrokeWidthAttributeName];
+        [attrs setObject:@(textStrokeWidth) forKey:NSStrokeWidthAttributeName];
     }
     if (strokeColor)
         [attrs setObject:strokeColor forKey:NSStrokeColorAttributeName];
@@ -1042,7 +1042,7 @@ NSDictionary *HTMLConverter::computedAttributesForElement(Element& element)
             if (UIFloatIsZero(kernVal))
                 [attrs setObject:@0.0 forKey:NSKernAttributeName]; // auto and normal, the other possible values, are both "kerning enabled"
             else
-                [attrs setObject:[NSNumber numberWithDouble:kernVal] forKey:NSKernAttributeName];
+                [attrs setObject:@(kernVal) forKey:NSKernAttributeName];
         }
     }
 
@@ -1074,7 +1074,7 @@ NSDictionary *HTMLConverter::computedAttributesForElement(Element& element)
 
     float baselineOffset = 0.0;
     if (_caches->floatPropertyValueForNode(element, CSSPropertyVerticalAlign, baselineOffset))
-        [attrs setObject:[NSNumber numberWithDouble:baselineOffset] forKey:NSBaselineOffsetAttributeName];
+        [attrs setObject:@(baselineOffset) forKey:NSBaselineOffsetAttributeName];
 
     String textShadow = _caches->propertyValueForNode(element, CSSPropertyTextShadow);
     if (textShadow.length() > 4) {
@@ -1556,7 +1556,7 @@ void HTMLConverter::_processMetaElementWithName(NSString *name, NSString *conten
         if (versionNumber > 0.0) {
             // ??? this should be keyed off of version number in future
             [_documentAttrs removeObjectForKey:NSConvertedDocumentAttribute];
-            [_documentAttrs setObject:[NSNumber numberWithDouble:versionNumber] forKey:NSCocoaVersionDocumentAttribute];
+            [_documentAttrs setObject:@(versionNumber) forKey:NSCocoaVersionDocumentAttribute];
         }
 #if PLATFORM(IOS_FAMILY)
     } else if (NSOrderedSame == [@"Generator" compare:name options:NSCaseInsensitiveSearch]) {
@@ -1672,8 +1672,8 @@ void HTMLConverter::_addTableForElement(Element *tableElement)
     }
     
     [_textTables addObject:table.get()];
-    [_textTableSpacings addObject:[NSNumber numberWithDouble:cellSpacingVal]];
-    [_textTablePaddings addObject:[NSNumber numberWithDouble:cellPaddingVal]];
+    [_textTableSpacings addObject:@(cellSpacingVal)];
+    [_textTablePaddings addObject:@(cellPaddingVal)];
     [_textTableRows addObject:[NSNumber numberWithInteger:0]];
     [_textTableRowArrays addObject:[NSMutableArray array]];
 }
index c0f31c2..a207cb0 100644 (file)
@@ -730,7 +730,7 @@ NSArray *Frame::interpretationsForCurrentRoot() const
 
     // There are no phrases with alternatives, so there is just one interpretation.
     if (markersInRoot.isEmpty())
-        return [NSArray arrayWithObject:plainText(rangeOfRootContents)];
+        return @[plainText(rangeOfRootContents)];
 
     // The number of interpretations will be i1 * i2 * ... * iN, where iX is the number of interpretations for the Xth phrase with alternatives.
     size_t interpretationsCount = 1;
index a87cf5c..2b3fe05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  *
  * Redistribution and use in source and binary forms, with or without
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "MIMETypeRegistry.h"
+#import "config.h"
+#import "MIMETypeRegistry.h"
 
-#include <pal/spi/cocoa/NSURLFileTypeMappingsSPI.h>
+#import <pal/spi/cocoa/NSURLFileTypeMappingsSPI.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 namespace WebCore {
 
@@ -38,16 +39,7 @@ String MIMETypeRegistry::getMIMETypeForExtension(const String& extension)
 
 Vector<String> MIMETypeRegistry::getExtensionsForMIMEType(const String& type)
 {
-    NSArray *stringsArray = [[NSURLFileTypeMappings sharedMappings] extensionsForMIMEType:(NSString *)type];
-    Vector<String> stringsVector = Vector<String>();
-    unsigned count = [stringsArray count];
-    if (count > 0) {
-        NSEnumerator* enumerator = [stringsArray objectEnumerator];
-        NSString* string;
-        while ((string = [enumerator nextObject]) != nil)
-            stringsVector.append(string);
-    }
-    return stringsVector;
+    return makeVector<String>([[NSURLFileTypeMappings sharedMappings] extensionsForMIMEType:type]);
 }
 
 String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
index 455bb25..75c928d 100644 (file)
 #include "IntPoint.h"
 #include <wtf/MathExtras.h>
 
-#if PLATFORM(MAC) && defined __OBJC__
-#import <Foundation/NSGeometry.h>
-#endif
-
 #if USE(CG)
 typedef struct CGPoint CGPoint;
 #endif
index 33170eb..1b6d493 100644 (file)
@@ -279,5 +279,8 @@ WEBCORE_EXPORT IntRect roundedIntRect(const FloatRect&);
 
 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const FloatRect&);
 
-}
+#ifdef __OBJC__
+WEBCORE_EXPORT id makeNSArrayElement(const FloatRect&);
+#endif
 
+}
index d34880a..16c9236 100644 (file)
 #include "IntSize.h"
 #include <cmath>
 
-#if PLATFORM(MAC) && defined __OBJC__
-#import <Foundation/NSGeometry.h>
-#endif
-
 #if USE(CG)
 typedef struct CGPoint CGPoint;
 #endif
 
-
 #if !PLATFORM(IOS_FAMILY)
 #if OS(DARWIN)
 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
index 122dd50..03c5aaf 100644 (file)
@@ -250,5 +250,8 @@ WEBCORE_EXPORT IntRect enclosingIntRect(const NSRect&);
 
 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const IntRect&);
 
-} // namespace WebCore
+#ifdef __OBJC__
+WEBCORE_EXPORT id makeNSArrayElement(const IntRect&);
+#endif
 
+} // namespace WebCore
index ee7c6c0..7568341 100644 (file)
 #include <wtf/JSONValues.h>
 #include <wtf/Forward.h>
 
-#if PLATFORM(MAC) && defined __OBJC__
-#import <Foundation/NSGeometry.h>
-#endif
-
 #if USE(CG)
 typedef struct CGSize CGSize;
 #endif
index 83b6421..8f847b8 100644 (file)
@@ -33,6 +33,7 @@
 #import <AVFoundation/AVPlayerItem.h>
 #import <objc/runtime.h>
 #import <wtf/Language.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/WTFString.h>
 
 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
@@ -132,10 +133,8 @@ void MediaSelectionGroupAVFObjC::updateOptions(const Vector<String>& characteris
     if (!m_shouldSelectOptionAutomatically)
         return;
 
-    RetainPtr<NSMutableArray> nsLanguages = adoptNS([[NSMutableArray alloc] initWithCapacity:userPreferredLanguages().size()]);
-    for (auto& language : userPreferredLanguages())
-        [nsLanguages addObject:(NSString*)language];
-    NSArray* filteredOptions = [PAL::getAVMediaSelectionGroupClass() mediaSelectionOptionsFromArray:[m_mediaSelectionGroup options] filteredAndSortedAccordingToPreferredLanguages:nsLanguages.get()];
+    NSArray* filteredOptions = [PAL::getAVMediaSelectionGroupClass() mediaSelectionOptionsFromArray:[m_mediaSelectionGroup options]
+        filteredAndSortedAccordingToPreferredLanguages:createNSArray(userPreferredLanguages()).get()];
 
     if (![filteredOptions count] && characteristics.isEmpty())
         return;
@@ -144,11 +143,7 @@ void MediaSelectionGroupAVFObjC::updateOptions(const Vector<String>& characteris
     if (![filteredOptions count])
         filteredOptions = [m_mediaSelectionGroup options];
 
-    RetainPtr<NSMutableArray> nsCharacteristics = adoptNS([[NSMutableArray alloc] initWithCapacity:characteristics.size()]);
-    for (auto& characteristic : characteristics)
-        [nsCharacteristics addObject:(NSString *)characteristic];
-
-    NSArray* optionsWithCharacteristics = [PAL::getAVMediaSelectionGroupClass() mediaSelectionOptionsFromArray:filteredOptions withMediaCharacteristics:nsCharacteristics.get()];
+    NSArray* optionsWithCharacteristics = [PAL::getAVMediaSelectionGroupClass() mediaSelectionOptionsFromArray:filteredOptions withMediaCharacteristics:createNSArray(characteristics).get()];
     if (optionsWithCharacteristics && [optionsWithCharacteristics count])
         filteredOptions = optionsWithCharacteristics;
 
index 5a62a1e..8a77162 100644 (file)
@@ -697,7 +697,8 @@ bool MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame() const
 }
 
 #if ENABLE(AVF_CAPTIONS)
-static const NSArray* mediaDescriptionForKind(PlatformTextTrack::TrackKind kind)
+
+static const NSArray *mediaDescriptionForKind(PlatformTextTrack::TrackKind kind)
 {
     static bool manualSelectionMode = MTEnableCaption2015BehaviorPtr() && MTEnableCaption2015BehaviorPtr()();
     if (manualSelectionMode)
@@ -705,18 +706,18 @@ static const NSArray* mediaDescriptionForKind(PlatformTextTrack::TrackKind kind)
 
     // FIXME: Match these to correct types:
     if (kind == PlatformTextTrack::Caption)
-        return [NSArray arrayWithObjects: AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, nil];
+        return @[ AVMediaCharacteristicTranscribesSpokenDialogForAccessibility ];
 
     if (kind == PlatformTextTrack::Subtitle)
-        return [NSArray arrayWithObjects: AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, nil];
+        return @[ AVMediaCharacteristicTranscribesSpokenDialogForAccessibility ];
 
     if (kind == PlatformTextTrack::Description)
-        return [NSArray arrayWithObjects: AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, nil];
+        return @[ AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility ];
 
     if (kind == PlatformTextTrack::Forced)
-        return [NSArray arrayWithObjects: AVMediaCharacteristicContainsOnlyForcedSubtitles, nil];
+        return @[ AVMediaCharacteristicContainsOnlyForcedSubtitles ];
 
-    return [NSArray arrayWithObjects: AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, nil];
+    return @[ AVMediaCharacteristicTranscribesSpokenDialogForAccessibility ];
 }
     
 void MediaPlayerPrivateAVFoundationObjC::notifyTrackModeChanged()
@@ -754,8 +755,8 @@ void MediaPlayerPrivateAVFoundationObjC::synchronizeTextTrackState()
         }
     }
 }
-#endif
 
+#endif
 
 static NSURL *canonicalURL(const URL& url)
 {
@@ -785,7 +786,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const URL& url)
 
     RetainPtr<NSMutableDictionary> options = adoptNS([[NSMutableDictionary alloc] init]);    
 
-    [options.get() setObject:[NSNumber numberWithInt:AVAssetReferenceRestrictionForbidRemoteReferenceToLocal | AVAssetReferenceRestrictionForbidLocalReferenceToRemote] forKey:AVURLAssetReferenceRestrictionsKey];
+    [options.get() setObject:@(AVAssetReferenceRestrictionForbidRemoteReferenceToLocal | AVAssetReferenceRestrictionForbidLocalReferenceToRemote) forKey:AVURLAssetReferenceRestrictionsKey];
 
     RetainPtr<NSMutableDictionary> headerFields = adoptNS([[NSMutableDictionary alloc] init]);
 
@@ -989,7 +990,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem()
 
     const NSTimeInterval avPlayerOutputAdvanceInterval = 2;
 
-    RetainPtr<NSArray> subtypes = adoptNS([[NSArray alloc] initWithObjects:[NSNumber numberWithUnsignedInt:kCMSubtitleFormatType_WebVTT], nil]);
+    RetainPtr<NSArray> subtypes = adoptNS([[NSArray alloc] initWithObjects:@(kCMSubtitleFormatType_WebVTT), nil]);
     m_legibleOutput = adoptNS([PAL::allocAVPlayerItemLegibleOutputInstance() initWithMediaSubtypesForNativeRepresentation:subtypes.get()]);
     [m_legibleOutput.get() setSuppressesPlayerRendering:YES];
 
@@ -1028,7 +1029,7 @@ void MediaPlayerPrivateAVFoundationObjC::checkPlayability()
     INFO_LOG(LOGIDENTIFIER);
     auto weakThis = makeWeakPtr(*this);
 
-    [m_avAsset.get() loadValuesAsynchronouslyForKeys:[NSArray arrayWithObjects:@"playable", @"tracks", nil] completionHandler:^{
+    [m_avAsset.get() loadValuesAsynchronouslyForKeys:@[@"playable", @"tracks"] completionHandler:^{
         callOnMainThread([weakThis] {
             if (weakThis)
                 weakThis->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::AssetPlayabilityKnown);
@@ -2171,7 +2172,7 @@ void MediaPlayerPrivateAVFoundationObjC::createVideoOutput()
 #if USE(VIDEOTOOLBOX)
     NSDictionary* attributes = nil;
 #else
-    NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey, nil];
+    NSDictionary* attributes = @{ kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA) };
 #endif
     m_videoOutput = adoptNS([PAL::allocAVPlayerItemVideoOutputInstance() initWithPixelBufferAttributes:attributes]);
     ASSERT(m_videoOutput);
index d97ccb3..4816b00 100644 (file)
@@ -35,7 +35,7 @@
 
 namespace WebCore {
 
-static NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplicitBeginTimeFlag";
+constexpr NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplicitBeginTimeFlag";
 
 bool hasExplicitBeginTime(CAAnimation *animation)
 {
@@ -362,8 +362,7 @@ void PlatformCAAnimationCocoa::setAdditive(bool value)
 
 PlatformCAAnimation::ValueFunctionType PlatformCAAnimationCocoa::valueFunction() const
 {
-    CAValueFunction* vf = [m_animation valueFunction];
-    return fromCAValueFunctionType([vf name]);
+    return fromCAValueFunctionType([[m_animation valueFunction] name]);
 }
 
 void PlatformCAAnimationCocoa::setValueFunction(ValueFunctionType value)
@@ -375,14 +374,13 @@ void PlatformCAAnimationCocoa::setFromValue(float value)
 {
     if (!isBasicAnimation())
         return;
-    [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[NSNumber numberWithDouble:value]];
+    [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:@(value)];
 }
 
 void PlatformCAAnimationCocoa::setFromValue(const TransformationMatrix& value)
 {
     if (!isBasicAnimation())
         return;
-
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[NSValue valueWithCATransform3D:value]];
 }
 
@@ -390,32 +388,19 @@ void PlatformCAAnimationCocoa::setFromValue(const FloatPoint3D& value)
 {
     if (!isBasicAnimation())
         return;
-
-    NSArray* array = [NSArray arrayWithObjects:
-        [NSNumber numberWithDouble:value.x()],
-        [NSNumber numberWithDouble:value.y()],
-        [NSNumber numberWithDouble:value.z()],
-        nil];
-    [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:array];
+    [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:@[ @(value.x()), @(value.y()), @(value.z()) ]];
 }
 
 void PlatformCAAnimationCocoa::setFromValue(const Color& value)
 {
     if (!isBasicAnimation())
         return;
-
-    NSArray* array = [NSArray arrayWithObjects:
-        [NSNumber numberWithDouble:value.red()],
-        [NSNumber numberWithDouble:value.green()],
-        [NSNumber numberWithDouble:value.blue()],
-        [NSNumber numberWithDouble:value.alpha()],
-        nil];
-    [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:array];
+    [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:@[@(value.red()), @(value.green()), @(value.blue()), @(value.alpha())]];
 }
 
 void PlatformCAAnimationCocoa::setFromValue(const FilterOperation* operation, int internalFilterPropertyIndex)
 {
-    RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
+    auto value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:value.get()];
 }
 
@@ -423,8 +408,7 @@ void PlatformCAAnimationCocoa::copyFromValueFrom(const PlatformCAAnimation& valu
 {
     if (!isBasicAnimation() || !value.isBasicAnimation())
         return;
-
-    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
+    auto otherAnimation = static_cast<CABasicAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
     [static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[otherAnimation fromValue]];
 }
 
@@ -432,14 +416,13 @@ void PlatformCAAnimationCocoa::setToValue(float value)
 {
     if (!isBasicAnimation())
         return;
-    [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[NSNumber numberWithDouble:value]];
+    [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:@(value)];
 }
 
 void PlatformCAAnimationCocoa::setToValue(const TransformationMatrix& value)
 {
     if (!isBasicAnimation())
         return;
-
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[NSValue valueWithCATransform3D:value]];
 }
 
@@ -447,32 +430,19 @@ void PlatformCAAnimationCocoa::setToValue(const FloatPoint3D& value)
 {
     if (!isBasicAnimation())
         return;
-
-    NSArray* array = [NSArray arrayWithObjects:
-        [NSNumber numberWithDouble:value.x()],
-        [NSNumber numberWithDouble:value.y()],
-        [NSNumber numberWithDouble:value.z()],
-        nil];
-    [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:array];
+    [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:@[ @(value.x()), @(value.y()), @(value.z()) ]];
 }
 
 void PlatformCAAnimationCocoa::setToValue(const Color& value)
 {
     if (!isBasicAnimation())
         return;
-
-    NSArray* array = [NSArray arrayWithObjects:
-        [NSNumber numberWithDouble:value.red()],
-        [NSNumber numberWithDouble:value.green()],
-        [NSNumber numberWithDouble:value.blue()],
-        [NSNumber numberWithDouble:value.alpha()],
-        nil];
-    [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:array];
+    [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:@[@(value.red()), @(value.green()), @(value.blue()), @(value.alpha())]];
 }
 
 void PlatformCAAnimationCocoa::setToValue(const FilterOperation* operation, int internalFilterPropertyIndex)
 {
-    RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
+    auto value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:value.get()];
 }
 
@@ -481,7 +451,7 @@ void PlatformCAAnimationCocoa::copyToValueFrom(const PlatformCAAnimation& value)
     if (!isBasicAnimation() || !value.isBasicAnimation())
         return;
 
-    CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
+    auto otherAnimation = static_cast<CABasicAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
     [static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[otherAnimation toValue]];
 }
 
@@ -492,9 +462,9 @@ void PlatformCAAnimationCocoa::setValues(const Vector<float>& value)
     if (animationType() != Keyframe)
         return;
 
-    NSMutableArray* array = [NSMutableArray array];
-    for (size_t i = 0; i < value.size(); ++i)
-        [array addObject:[NSNumber numberWithDouble:value[i]]];
+    auto array = [NSMutableArray arrayWithCapacity:value.size()];
+    for (auto number : value)
+        [array addObject:@(number)];
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
@@ -503,11 +473,9 @@ void PlatformCAAnimationCocoa::setValues(const Vector<TransformationMatrix>& val
     if (animationType() != Keyframe)
         return;
 
-    NSMutableArray* array = [NSMutableArray array];
-
-    for (size_t i = 0; i < value.size(); ++i)
-        [array addObject:[NSValue valueWithCATransform3D:value[i]]];
-
+    auto array = [NSMutableArray arrayWithCapacity:value.size()];
+    for (auto& matrix : value)
+        [array addObject:[NSValue valueWithCATransform3D:matrix]];
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
@@ -516,16 +484,9 @@ void PlatformCAAnimationCocoa::setValues(const Vector<FloatPoint3D>& value)
     if (animationType() != Keyframe)
         return;
 
-    NSMutableArray* array = [NSMutableArray array];
-
-    for (size_t i = 0; i < value.size(); ++i) {
-        NSArray* object = [NSArray arrayWithObjects:
-            [NSNumber numberWithDouble:value[i].x()],
-            [NSNumber numberWithDouble:value[i].y()],
-            [NSNumber numberWithDouble:value[i].z()],
-            nil];
-        [array addObject:object];
-    }
+    auto array = [NSMutableArray arrayWithCapacity:value.size()];
+    for (auto& point : value)
+        [array addObject:@[@(point.x()), @(point.y()), @(point.z())]];
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
@@ -534,17 +495,9 @@ void PlatformCAAnimationCocoa::setValues(const Vector<Color>& value)
     if (animationType() != Keyframe)
         return;
 
-    NSMutableArray* array = [NSMutableArray array];
-
-    for (size_t i = 0; i < value.size(); ++i) {
-        NSArray* object = [NSArray arrayWithObjects:
-            [NSNumber numberWithDouble:value[i].red()],
-            [NSNumber numberWithDouble:value[i].green()],
-            [NSNumber numberWithDouble:value[i].blue()],
-            [NSNumber numberWithDouble:value[i].alpha()],
-            nil];
-        [array addObject:object];
-    }
+    auto array = [NSMutableArray arrayWithCapacity:value.size()];
+    for (auto& color : value)
+        [array addObject:@[@(color.red()), @(color.green()), @(color.blue()), @(color.alpha())]];
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
@@ -553,12 +506,9 @@ void PlatformCAAnimationCocoa::setValues(const Vector<RefPtr<FilterOperation>>&
     if (animationType() != Keyframe)
         return;
 
-    NSMutableArray* array = [NSMutableArray array];
-
-    for (size_t i = 0; i < values.size(); ++i) {
-        RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(values[i].get(), internalFilterPropertyIndex);
-        [array addObject:value.get()];
-    }
+    auto array = [NSMutableArray arrayWithCapacity:values.size()];
+    for (auto& value : values)
+        [array addObject:PlatformCAFilters::filterValueForOperation(value.get(), internalFilterPropertyIndex).get()];
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
 }
 
@@ -567,39 +517,35 @@ void PlatformCAAnimationCocoa::copyValuesFrom(const PlatformCAAnimation& value)
     if (animationType() != Keyframe || value.animationType() != Keyframe)
         return;
 
-    CAKeyframeAnimation* otherAnimation = static_cast<CAKeyframeAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
+    auto otherAnimation = static_cast<CAKeyframeAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:[otherAnimation values]];
 }
 
 void PlatformCAAnimationCocoa::setKeyTimes(const Vector<float>& value)
 {
-    NSMutableArray* array = [NSMutableArray array];
-
-    for (size_t i = 0; i < value.size(); ++i)
-        [array addObject:[NSNumber numberWithFloat:value[i]]];
-
+    auto array = [NSMutableArray arrayWithCapacity:value.size()];
+    for (auto time : value)
+        [array addObject:@(time)];
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setKeyTimes:array];
 }
 
 void PlatformCAAnimationCocoa::copyKeyTimesFrom(const PlatformCAAnimation& value)
 {
-    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
+    auto other = static_cast<CAKeyframeAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setKeyTimes:[other keyTimes]];
 }
 
 void PlatformCAAnimationCocoa::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse)
 {
-    NSMutableArray* array = [NSMutableArray array];
-
-    for (size_t i = 0; i < value.size(); ++i)
-        [array addObject:toCAMediaTimingFunction(value[i], reverse)];
-
+    auto array = [NSMutableArray arrayWithCapacity:value.size()];
+    for (auto& function : value)
+        [array addObject:toCAMediaTimingFunction(function, reverse)];
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setTimingFunctions:array];
 }
 
 void PlatformCAAnimationCocoa::copyTimingFunctionsFrom(const PlatformCAAnimation& value)
 {
-    CAKeyframeAnimation* other = static_cast<CAKeyframeAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
+    auto other = static_cast<CAKeyframeAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
     [static_cast<CAKeyframeAnimation*>(m_animation.get()) setTimingFunctions:[other timingFunctions]];
 }
 
index e1ae5d9..3c4dce2 100644 (file)
@@ -324,7 +324,7 @@ RetainPtr<NSValue> PlatformCAFilters::filterValueForOperation(const FilterOperat
         if (operation)
             amount = downcast<BasicColorMatrixFilterOperation>(*operation).amount();
         
-        value = [NSNumber numberWithDouble:amount];
+        value = @(amount);
         break;
     }
     case FilterOperation::SEPIA: {
@@ -363,7 +363,7 @@ RetainPtr<NSValue> PlatformCAFilters::filterValueForOperation(const FilterOperat
         if (operation)
             amount = downcast<BasicColorMatrixFilterOperation>(*operation).amount();
         
-        value = [NSNumber numberWithDouble:amount];
+        value = @(amount);
         break;
     }
     case FilterOperation::HUE_ROTATE: {
@@ -374,7 +374,7 @@ RetainPtr<NSValue> PlatformCAFilters::filterValueForOperation(const FilterOperat
             amount = downcast<BasicColorMatrixFilterOperation>(*operation).amount();
         
         amount = deg2rad(amount);
-        value = [NSNumber numberWithDouble:amount];
+        value = @(amount);
         break;
     }
     case FilterOperation::INVERT: {
@@ -452,7 +452,7 @@ RetainPtr<NSValue> PlatformCAFilters::filterValueForOperation(const FilterOperat
         if (operation)
             amount = downcast<BasicComponentTransferFilterOperation>(*operation).amount();
         
-        value = [NSNumber numberWithDouble:amount];
+        value = @(amount);
 #endif
         break;
     }
@@ -463,7 +463,7 @@ RetainPtr<NSValue> PlatformCAFilters::filterValueForOperation(const FilterOperat
         if (operation)
             amount = floatValueForLength(downcast<BlurFilterOperation>(*operation).stdDeviation(), 0);
         
-        value = [NSNumber numberWithDouble:amount];
+        value = @(amount);
         break;
     }
     default:
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2003, 2006 Apple Inc.  All rights reserved.
- * Copyright (C) 2005 Nokia.  All rights reserved.
+ * Copyright (C) 2003-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2005 Nokia. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "FloatRect.h"
+#import "config.h"
+#import "FloatRect.h"
+
+#if !PLATFORM(MAC)
+#import <UIKit/UIGeometry.h>
+#endif
 
 namespace WebCore {
 
-#if !PLATFORM(IOS_FAMILY)
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+id makeNSArrayElement(const WebCore::FloatRect& rect)
+{
+#if PLATFORM(MAC)
+    return [NSValue valueWithRect:rect];
+#else
+    return [NSValue valueWithCGRect:rect];
+#endif
+}
+
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
 
-FloatRect::FloatRect(const NSRect& r) : m_location(r.origin), m_size(r.size)
+FloatRect::FloatRect(const NSRect& rect)
+    : m_location(rect.origin)
+    , m_size(rect.size)
 {
 }
 
@@ -42,6 +56,5 @@ FloatRect::operator NSRect() const
 }
 
 #endif
-#endif // !PLATFORM(IOS_FAMILY)
 
 }
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006 Apple Inc.  All rights reserved.
+ * Copyright (C) 2003-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#include "config.h"
-#include "IntRect.h"
+#import "config.h"
+#import "IntRect.h"
+
+#if !PLATFORM(MAC)
+#import <UIKit/UIGeometry.h>
+#endif
 
 namespace WebCore {
 
-#if !PLATFORM(IOS_FAMILY)
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+id makeNSArrayElement(const IntRect& rect)
+{
+#if PLATFORM(MAC)
+    return [NSValue valueWithRect:rect];
+#else
+    return [NSValue valueWithCGRect:rect];
+#endif
+}
+
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
 
 IntRect::operator NSRect() const
 {
@@ -38,14 +50,13 @@ IntRect::operator NSRect() const
 
 IntRect enclosingIntRect(const NSRect& rect)
 {
-    int l = static_cast<int>(floorf(rect.origin.x));
-    int t = static_cast<int>(floorf(rect.origin.y));
-    int r = static_cast<int>(ceilf(NSMaxX(rect)));
-    int b = static_cast<int>(ceilf(NSMaxY(rect)));
-    return IntRect(l, t, r - l, b - t);
+    int left = clampTo<int>(std::floor(rect.origin.x));
+    int top = clampTo<int>(std::floor(rect.origin.y));
+    int right = clampTo<int>(std::ceil(NSMaxX(rect)));
+    int bottom = clampTo<int>(std::ceil(NSMaxY(rect)));
+    return { left, top, right - left, bottom - top };
 }
 
 #endif
-#endif
 
 }
index f46a716..418bd33 100644 (file)
@@ -165,7 +165,7 @@ static void freeData(void *, const void *data, size_t /* size */)
         if (_latchedPbuffer) {
 
             GCGLenum texture = _context->platformTexture();
-            gl::BindTexture(GraphicsContextGL::IOSurfaceTextureTarget, texture);
+            gl::BindTexture(WebCore::GraphicsContextGL::IOSurfaceTextureTarget, texture);
             if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) {
                 // FIXME: report error.
                 notImplemented();
@@ -224,7 +224,7 @@ static void freeData(void *, const void *data, size_t /* size */)
         EGL_WIDTH, size.width(),
         EGL_HEIGHT, size.height(),
         EGL_IOSURFACE_PLANE_ANGLE, 0,
-        EGL_TEXTURE_TARGET, GraphicsContextGL::EGLIOSurfaceTextureTarget,
+        EGL_TEXTURE_TARGET, WebCore::GraphicsContextGL::EGLIOSurfaceTextureTarget,
         EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, usingAlpha ? GL_BGRA_EXT : GL_RGB,
         EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
         EGL_TEXTURE_TYPE_ANGLE, GL_UNSIGNED_BYTE,
@@ -258,7 +258,7 @@ static void freeData(void *, const void *data, size_t /* size */)
 #elif USE(ANGLE)
     GCGLenum texture = _context->platformTexture();
 
-    gl::BindTexture(GraphicsContextGL::IOSurfaceTextureTarget, texture);
+    gl::BindTexture(WebCore::GraphicsContextGL::IOSurfaceTextureTarget, texture);
 
     if (_latchedPbuffer) {
         if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) {
index ce3f8db..4f08ca0 100644 (file)
@@ -117,7 +117,7 @@ static RetainPtr<NSDictionary> systemFontModificationAttributes(FontSelectionVal
     [traitsDictionary setObject:@YES forKey:static_cast<NSString *>(kCTFontUIFontDesignTrait)];
 
     if (italic)
-        [traitsDictionary setObject:[NSNumber numberWithInt:kCTFontItalicTrait] forKey:static_cast<NSString *>(kCTFontSymbolicTrait)];
+        [traitsDictionary setObject:@(kCTFontItalicTrait) forKey:static_cast<NSString *>(kCTFontSymbolicTrait)];
 
     return @{ static_cast<NSString *>(kCTFontTraitsAttribute) : traitsDictionary.get() };
 }
index c0e1f2d..baa2555 100644 (file)
 #import <UIKit/UIColor.h>
 #import <UIKit/UIImage.h>
 #import <UIKit/UIPasteboard.h>
-#import <pal/ios/UIKitSoftLink.h>
 #import <pal/spi/ios/UIKitSPI.h>
 #import <wtf/ListHashSet.h>
 #import <wtf/URL.h>
 #import <wtf/cocoa/NSURLExtras.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/StringHash.h>
 
+#import <pal/ios/UIKitSoftLink.h>
+
 #define PASTEBOARD_SUPPORTS_ITEM_PROVIDERS (PLATFORM(IOS_FAMILY) && !(PLATFORM(WATCHOS) || PLATFORM(APPLETV)))
 #define PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA (PASTEBOARD_SUPPORTS_ITEM_PROVIDERS && !PLATFORM(MACCATALYST))
 #define NSURL_SUPPORTS_TITLE (!PLATFORM(MACCATALYST))
@@ -74,8 +76,7 @@ PlatformPasteboard::PlatformPasteboard(const String&)
 
 void PlatformPasteboard::getTypes(Vector<String>& types)
 {
-    for (NSString *pasteboardType in [m_pasteboard pasteboardTypes])
-        types.append(pasteboardType);
+    types = makeVector<String>([m_pasteboard pasteboardTypes]);
 }
 
 RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& type)
@@ -587,10 +588,7 @@ static RetainPtr<WebItemProviderRegistrationInfoList> createItemProviderRegistra
             // events, we need an additional in-memory representation of the pasteboard types array that contains
             // all of the custom types. We use the teamData property, available on NSItemProvider on iOS, to store
             // this information, since the contents of teamData are immediately available prior to the drop.
-            NSMutableArray<NSString *> *typesAsNSArray = [NSMutableArray array];
-            for (auto& type : data.orderedTypes())
-                [typesAsNSArray addObject:type];
-            NSDictionary *teamDataDictionary = @{ @(originKeyForTeamData) : data.origin(), @(customTypesKeyForTeamData) : typesAsNSArray };
+            NSDictionary *teamDataDictionary = @{ @(originKeyForTeamData) : data.origin(), @(customTypesKeyForTeamData) : createNSArray(data.orderedTypes()).get() };
             if (NSData *teamData = [NSKeyedArchiver archivedDataWithRootObject:teamDataDictionary requiringSecureCoding:YES error:nullptr]) {
                 [representationsToRegister setTeamData:teamData];
                 [representationsToRegister addData:serializedSharedBuffer.get() forType:@(PasteboardCustomData::cocoaType())];
@@ -753,11 +751,7 @@ void PlatformPasteboard::updateSupportedTypeIdentifiers(const Vector<String>& ty
     if (![m_pasteboard respondsToSelector:@selector(updateSupportedTypeIdentifiers:)])
         return;
 
-    NSMutableArray *typesArray = [NSMutableArray arrayWithCapacity:types.size()];
-    for (const auto& type : types)
-        [typesArray addObject:(NSString *)type];
-
-    [m_pasteboard updateSupportedTypeIdentifiers:typesArray];
+    [m_pasteboard updateSupportedTypeIdentifiers:createNSArray(types).get()];
 }
 
 int64_t PlatformPasteboard::write(const PasteboardCustomData& data)
index 7193b65..b816308 100644 (file)
@@ -518,7 +518,7 @@ static UIPreferredPresentationStyle uiPreferredPresentationStyle(WebPreferredPre
 
 - (void)setItemProviders:(NSArray<__kindof NSItemProvider *> *)itemProviders
 {
-    itemProviders = itemProviders ?: [NSArray array];
+    itemProviders = itemProviders ?: @[ ];
     if (_itemProviders == itemProviders || [_itemProviders isEqualToArray:itemProviders])
         return;
 
index e335d75..247f92f 100644 (file)
@@ -284,15 +284,15 @@ static void _WAKCopyWrapper(const void *value, void *context)
 {
     CFArrayRef subviews = WKViewGetSubviews([self _viewRef]);
     if (!subviews)
-        return [NSArray array];
+        return @[ ];
     
     CFIndex count = CFArrayGetCount(subviews);
     if (count == 0)
-        return [NSArray array];
+        return @[ ];
     
     NSMutableArray *result = [NSMutableArray arrayWithCapacity:count];
     if (!result)
-        return [NSArray array];
+        return @[ ];
     
     CFArrayApplyFunction(subviews, CFRangeMake(0, count), _WAKCopyWrapper, (void*)result);
     
index c964f41..07627f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #import <wtf/HashCountedSet.h>
 #import <wtf/ListHashSet.h>
 #import <wtf/URL.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/StringHash.h>
 
 namespace WebCore {
@@ -57,10 +58,7 @@ PlatformPasteboard::PlatformPasteboard(const String& pasteboardName)
 
 void PlatformPasteboard::getTypes(Vector<String>& types)
 {
-    NSArray *pasteboardTypes = [m_pasteboard.get() types];
-
-    for (NSUInteger i = 0; i < [pasteboardTypes count]; i++)
-        types.append([pasteboardTypes objectAtIndex:i]);
+    types = makeVector<String>([m_pasteboard.get() types]);
 }
 
 RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& pasteboardType)
@@ -95,13 +93,12 @@ int PlatformPasteboard::numberOfFiles() const
 
 void PlatformPasteboard::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType) const
 {
-    NSArray* paths = [m_pasteboard.get() propertyListForType:pasteboardType];
+    id paths = [m_pasteboard.get() propertyListForType:pasteboardType];
     if ([paths isKindOfClass:[NSString class]]) {
         pathnames.append((NSString *)paths);
         return;
     }
-    for (NSUInteger i = 0; i < [paths count]; i++)
-        pathnames.append([paths objectAtIndex:i]);
+    pathnames = makeVector<String>(paths);
 }
 
 static bool pasteboardMayContainFilePaths(NSPasteboard *pasteboard)
@@ -317,24 +314,16 @@ int64_t PlatformPasteboard::copy(const String& fromPasteboard)
 
 int64_t PlatformPasteboard::addTypes(const Vector<String>& pasteboardTypes)
 {
-    RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] init]);
-    for (size_t i = 0; i < pasteboardTypes.size(); ++i)
-        [types.get() addObject:pasteboardTypes[i]];
-
-    return [m_pasteboard.get() addTypes:types.get() owner:nil];
+    return [m_pasteboard.get() addTypes:createNSArray(pasteboardTypes).get() owner:nil];
 }
 
 int64_t PlatformPasteboard::setTypes(const Vector<String>& pasteboardTypes)
 {
-    auto types = adoptNS([[NSMutableArray alloc] init]);
     for (auto& pasteboardType : pasteboardTypes) {
-        if (!canWritePasteboardType(pasteboardType)) {
-            [types removeAllObjects];
-            break;
-        }
-        [types addObject:pasteboardType];
+        if (!canWritePasteboardType(pasteboardType))
+            return [m_pasteboard declareTypes:@[] owner:nil];
     }
-    return [m_pasteboard declareTypes:types.get() owner:nil];
+    return [m_pasteboard declareTypes:createNSArray(pasteboardTypes).get() owner:nil];
 }
 
 int64_t PlatformPasteboard::setBufferForType(SharedBuffer* buffer, const String& pasteboardType)
index abf2bf1..cbc666e 100644 (file)
@@ -32,8 +32,4 @@ namespace WebCore {
 
 WEBCORE_EXPORT bool stringMatchesWildcardString(const String& stringToBeMatched, const String& wildcardString);
 
-#ifdef __OBJC__
-WEBCORE_EXPORT Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *);
-#endif // defined(__OBJC__)
-
 }
index f1f56b3..7cd1bd8 100644 (file)
@@ -59,15 +59,4 @@ bool stringMatchesWildcardString(const String& string, const String& wildcardStr
     return JSC::Yarr::RegularExpression(wildcardRegexPatternString(wildcardString), JSC::Yarr::TextCaseInsensitive).match(string) != -1;
 }
 
-Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *nsStringArray)
-{
-    Vector<String> stringVector;
-    stringVector.reserveInitialCapacity([nsStringArray count]);
-
-    for (NSString *nsString in nsStringArray)
-        stringVector.uncheckedAppend(nsString);
-
-    return stringVector;
-}
-
 }
index 38368ec..c75d20f 100644 (file)
@@ -31,7 +31,6 @@
 
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <wtf/Function.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
 #import <unicode/uchar.h>
index 23354f4..44ffdc0 100644 (file)
@@ -162,7 +162,7 @@ bool MediaRecorderPrivateWriter::setVideoInput(int width, int height)
     ASSERT(!m_videoInput);
     
     NSDictionary *compressionProperties = @{
-        AVVideoAverageBitRateKey : [NSNumber numberWithInt:width * height * 12],
+        AVVideoAverageBitRateKey : @(width * height * 12),
         AVVideoExpectedSourceFrameRateKey : @(30),
         AVVideoMaxKeyFrameIntervalKey : @(120),
         AVVideoProfileLevelKey : AVVideoProfileLevelH264MainAutoLevel
@@ -170,8 +170,8 @@ bool MediaRecorderPrivateWriter::setVideoInput(int width, int height)
 
     NSDictionary *videoSettings = @{
         AVVideoCodecKey: AVVideoCodecH264,
-        AVVideoWidthKey: [NSNumber numberWithInt:width],
-        AVVideoHeightKey: [NSNumber numberWithInt:height],
+        AVVideoWidthKey: @(width),
+        AVVideoHeightKey: @(height),
         AVVideoCompressionPropertiesKey: compressionProperties
     };
     
index 13edc35..f177e09 100644 (file)
@@ -442,7 +442,7 @@ bool AVVideoCaptureSource::setupCaptureSession()
     [session() addInput:videoIn.get()];
 
     m_videoOutput = adoptNS([PAL::allocAVCaptureVideoDataOutputInstance() init]);
-    auto settingsDictionary = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:avVideoCapturePixelBufferFormat()], kCVPixelBufferPixelFormatTypeKey, nil]);
+    auto settingsDictionary = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys: @(avVideoCapturePixelBufferFormat()), kCVPixelBufferPixelFormatTypeKey, nil]);
 
     [m_videoOutput setVideoSettings:settingsDictionary.get()];
     [m_videoOutput setAlwaysDiscardsLateVideoFrames:YES];
index f676a24..c97aebd 100644 (file)
@@ -175,7 +175,7 @@ Cookie::operator NSHTTPCookie * _Nullable () const
     }
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS_FAMILY)
-    [properties setObject:[NSNumber numberWithDouble:created / 1000.0 - NSTimeIntervalSince1970] forKey:@"Created"];
+    [properties setObject:@(created / 1000.0 - NSTimeIntervalSince1970) forKey:@"Created"];
 #endif
 
     auto* portString = portStringFromVector(ports);
index bd0fd67..c4bd5ef 100644 (file)
@@ -447,7 +447,7 @@ void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameS
     String cookieString = cookieStr.contains('=') ? cookieStr : cookieStr + "=";
 
     NSURL *cookieURL = url;
-    NSDictionary *headerFields = [NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"];
+    NSDictionary *headerFields = @{ @"Set-Cookie": cookieString };
 
 #if PLATFORM(MAC)
     NSArray *unfilteredCookies = [NSHTTPCookie _parsedCookiesWithResponseHeaderFields:headerFields forURL:cookieURL];
index d6eeefd..766ea3b 100644 (file)
@@ -192,7 +192,7 @@ void ResourceRequest::doUpdatePlatformRequest()
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS_FAMILY)
     [nsRequest _setProperty:siteForCookies(m_sameSiteDisposition, nsRequest.URL) forKey:@"_kCFHTTPCookiePolicyPropertySiteForCookies"];
-    [nsRequest _setProperty:[NSNumber numberWithBool:m_isTopSite] forKey:@"_kCFHTTPCookiePolicyPropertyIsTopLevelNavigation"];
+    [nsRequest _setProperty:m_isTopSite ? @YES : @NO forKey:@"_kCFHTTPCookiePolicyPropertyIsTopLevelNavigation"];
 #endif
 
     // Cannot just use setAllHTTPHeaderFields here, because it does not remove headers.
index e0e94da..0dcd44f 100644 (file)
@@ -1,3 +1,157 @@
+2020-04-08  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=210138
+
+        Reviewed by Alex Christensen.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm: Remove uneeded include.
+        * Platform/mac/StringUtilities.mm: Ditto.
+
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::replacedNSConcreteTask_launch): Use makeVector<String>.
+        (WebKit::replacedNSWorkspace_launchApplicationAtURL_options_configuration_error):
+        Ditto.
+
+        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::toSupportedNetworks): Deleted.
+        (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Use createNSArray.
+
+        * Shared/mac/PasteboardTypes.mm:
+        (WebKit::PasteboardTypes::forEditing): Use @[].
+        (WebKit::PasteboardTypes::forURL): Ditto.
+        (WebKit::PasteboardTypes::forImages): Ditto.
+        (WebKit::PasteboardTypes::forImagesWithArchive): Ditto.
+        (WebKit::PasteboardTypes::forSelection): Ditto.
+
+        * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
+        (-[WKContentRuleListStore getAvailableContentRuleListIdentifiers:]): Use createNSArray.
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _getActivePagesOriginsInWebProcessForTesting:completionHandler:]): Ditto.
+
+        * UIProcess/API/Cocoa/WKUserScript.mm:
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]):
+        (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:deferRunningUntilNotification:]):
+        Use makeVector<String>.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _setupPageConfiguration:]): Use makeVector<String>.
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration _corsDisablingPatterns]): Use createNSArray.
+        (-[WKWebViewConfiguration _setCORSDisablingPatterns:]): Use makeVector<String>.
+        * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+        (-[WKWebView _contentsOfUserInterfaceItem:]): Use @().
+        * UIProcess/API/Cocoa/_WKContentRuleListAction.mm:
+        (-[_WKContentRuleListAction notifications]): Use createNSArray.
+        * UIProcess/API/Cocoa/_WKCustomHeaderFields.mm:
+        (-[_WKCustomHeaderFields thirdPartyDomains]): Use createNSArray.
+        (-[_WKCustomHeaderFields setThirdPartyDomains:]): Use makeVector<String>.
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration cachePartitionedURLSchemes]): Use createNSArray.
+        (-[_WKProcessPoolConfiguration setCachePartitionedURLSchemes:]): Use makeVector<String>.
+        (-[_WKProcessPoolConfiguration alwaysRevalidatedURLSchemes]): Use createNSArray.
+        (-[_WKProcessPoolConfiguration setAlwaysRevalidatedURLSchemes:]): Use makeVector<String>.
+
+        * UIProcess/API/Cocoa/_WKUserContentWorldInternal.h:
+        (API::toStringVector): Deleted.
+
+        * UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
+        (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]):
+        (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]):
+        Use makeVector<String>.
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::accessibilityAttributeValue): Use @[].
+        (WebKit::WebViewImpl::performDragOperation): Use makeVector<String>.
+        (WebKit::WebViewImpl::namesOfPromisedFilesDroppedAtDestination): Use @[].
+        (WebKit::WebViewImpl::collectKeyboardLayoutCommandsForEvent): Use @[].
+
+        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+        (WebKit::PluginProcessProxy::launchProcess): Use createNSArray.
+        (WebKit::isJavaUpdaterURL): Use @[].
+        (WebKit::PluginProcessProxy::launchApplicationAtURL): Use @{} and createNSArray.
+        (WebKit::isSilverlightPreferencesURL): Use @[].
+
+        * UIProcess/WebAuthentication/Cocoa/HidService.mm:
+        (WebKit::HidService::HidService): Use @() and fixed an over-release mistake.
+        This code was doing adoptNS on the result of +[NSNumberWithInt:], which is incorrect.
+
+        * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
+        (WebKit::MockLocalConnection::getAttestation const): Use @[].
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView textStylingAtPosition:inDirection:]): Use @().
+        (-[WKContentView requestRectsToEvadeForSelectionCommandsWithCompletionHandler:]): Use createNSArray.
+        (-[WKContentView _itemsForBeginningOrAddingToSessionWithRegistrationLists:stagedDragSource:]):
+        Fixed a wasteful call to autorelease where we are adding an item to a dictionary. Calling get
+        is more efficient and still correct.
+
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel imagePickerController:didFinishPickingMediaWithInfo:]): Use @[].
+
+        * UIProcess/ios/forms/WKFormColorPicker.mm:
+        (-[WKColorMatrixView initWithFrame:colorMatrix:]): Removed uneeded RetainPtr
+        local variable.
+
+        * UIProcess/mac/CorrectionPanel.mm:
+        (WebKit::CorrectionPanel::show): Use createNSArray.
+
+        * UIProcess/mac/TextCheckerMac.mm:
+        (WebKit::TextChecker::updateSpellingUIWithGrammarString): Use createNSArray.
+        (WebKit::TextChecker::getGuessesForWord): Use makeVector<String>.
+
+        * UIProcess/mac/WKPrintingView.mm:
+        (-[WKPrintingView _adjustPrintingMarginsForHeaderAndFooter]): Use @().
+
+        * UIProcess/mac/WKTextFinderClient.mm:
+        (arrayFromRects): Deleted.
+        (-[WKTextFinderClient didFindStringMatchesWithRects:didWrapAround:]): Use createNSArray.
+
+        * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
+        (-[WKDataListSuggestionsController notifyAccessibilityClients:]): Use @{}
+        and fix a bug where this was creating a backwards dictionary. So this never
+        could have been working before, making me wonder how we test it.
+
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::searchTheWeb): Use @[].
+
+        * WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Removed toNSArray.
+        * WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm:
+        (WebKit::toNSArray): Deleted.
+
+        * WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
+        (-[WKDOMNode textRects]): Use createNSArray.
+        * WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
+        (-[WKDOMRange textRects]): Ditto.
+
+        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
+        (WebKit::InjectedBundle::setBundleParameter): Use @{}.
+
+        * WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:
+        (WebKit::makeRenderLayer): Use @[].
+
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::writeItemsToPasteboard): Use makeVector<String>.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::applicationDidEnterBackground): Use @().
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::suspendPainting): Use @{}.
+        (WebKit::TiledCoreAnimationDrawingArea::resumePainting): Use @{}.
+
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
+        Removed an unneeded include.
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm: Ditto.
+        (-[WKAccessibilityWebPageObject accessibilityActionNames]): Use @[].
+        (-[WKAccessibilityWebPageObject accessibilityChildren]): Use @[].
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::getActivePagesOriginsForTesting): Use makeVector<String>.
+
 2020-04-09  Megan Gardner  <megan_gardner@apple.com>
 
         Popovers are dismissed immediately when they try and bring up the keyboard.
index 43df52d..626feb5 100644 (file)
@@ -52,7 +52,6 @@
 #import <wtf/MainThread.h>
 #import <wtf/NakedRef.h>
 #import <wtf/NeverDestroyed.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/ProcessPrivilege.h>
 #import <wtf/SoftLinking.h>
 #import <wtf/URL.h>
index ecbb797..684fd88 100644 (file)
@@ -29,7 +29,6 @@
 #import "WKSharedAPICast.h"
 #import "WKStringCF.h"
 #import <JavaScriptCore/RegularExpression.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/SoftLinking.h>
 #import <wtf/text/StringBuilder.h>
 
index 13b9ada..2703b28 100644 (file)
@@ -56,6 +56,7 @@
 #import <sysexits.h>
 #import <wtf/HashSet.h>
 #import <wtf/NeverDestroyed.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 const CFStringRef kLSPlugInBundleIdentifierKey = CFSTR("LSPlugInBundleIdentifierKey");
 
@@ -256,12 +257,7 @@ static void replacedNSConcreteTask_launch(NSTask *self, SEL _cmd)
 {
     String launchPath = self.launchPath;
 
-    Vector<String> arguments;
-    arguments.reserveInitialCapacity(self.arguments.count);
-    for (NSString *argument in self.arguments)
-        arguments.uncheckedAppend(argument);
-
-    if (PluginProcess::singleton().launchProcess(launchPath, arguments))
+    if (PluginProcess::singleton().launchProcess(launchPath, makeVector<String>(self.arguments)))
         return;
 
     NSConcreteTask_launch(self, _cmd);
@@ -271,16 +267,8 @@ static NSRunningApplication *(*NSWorkspace_launchApplicationAtURL_options_config
 
 static NSRunningApplication *replacedNSWorkspace_launchApplicationAtURL_options_configuration_error(NSWorkspace *self, SEL _cmd, NSURL *url, NSWorkspaceLaunchOptions options, NSDictionary *configuration, NSError **error)
 {
-    Vector<String> arguments;
     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    if (NSArray *argumentsArray = [configuration objectForKey:NSWorkspaceLaunchConfigurationArguments]) {
-        if ([argumentsArray isKindOfClass:[NSArray array]]) {
-            for (NSString *argument in argumentsArray) {
-                if ([argument isKindOfClass:[NSString class]])
-                    arguments.append(argument);
-            }
-        }
-    }
+    auto arguments = makeVector<String>([configuration objectForKey:NSWorkspaceLaunchConfigurationArguments]);
     ALLOW_DEPRECATED_DECLARATIONS_END
 
     if (PluginProcess::singleton().launchApplicationAtURL(URL(url).string(), arguments)) {
index f2338b8..3130886 100644 (file)
 #import "WebPaymentCoordinatorProxy.h"
 #import <WebCore/PaymentAuthorizationStatus.h>
 #import <WebCore/PaymentHeaders.h>
-#import <pal/cocoa/PassKitSoftLink.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/RunLoop.h>
 #import <wtf/URL.h>
+#import <wtf/cocoa/VectorCocoa.h>
+
+#import <pal/cocoa/PassKitSoftLink.h>
 
 #if USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm>
@@ -131,14 +133,6 @@ static PKMerchantCapability toPKMerchantCapabilities(const WebCore::ApplePaySess
     return result;
 }
 
-static RetainPtr<NSArray> toSupportedNetworks(const Vector<String>& supportedNetworks)
-{
-    auto result = adoptNS([[NSMutableArray alloc] initWithCapacity:supportedNetworks.size()]);
-    for (auto& supportedNetwork : supportedNetworks)
-        [result addObject:supportedNetwork];
-    return result;
-}
-
 static PKShippingType toPKShippingType(WebCore::ApplePaySessionPaymentRequest::ShippingType shippingType)
 {
     switch (shippingType) {
@@ -212,7 +206,7 @@ RetainPtr<PKPaymentRequest> WebPaymentCoordinatorProxy::platformPaymentRequest(c
     [result setRequiredBillingContactFields:toPKContactFields(paymentRequest.requiredBillingContactFields()).get()];
     [result setRequiredShippingContactFields:toPKContactFields(paymentRequest.requiredShippingContactFields()).get()];
 
-    [result setSupportedNetworks:toSupportedNetworks(paymentRequest.supportedNetworks()).get()];
+    [result setSupportedNetworks:createNSArray(paymentRequest.supportedNetworks()).get()];
     [result setMerchantCapabilities:toPKMerchantCapabilities(paymentRequest.merchantCapabilities())];
 
     [result setShippingType:toPKShippingType(paymentRequest.shippingType())];
index 7013281..dfd4b60 100644 (file)
@@ -46,32 +46,32 @@ static inline NSArray *retain(NSArray *array)
     
 NSArray* PasteboardTypes::forEditing()
 {
-    static NSArray *types = retain([NSArray arrayWithObjects:WebArchivePboardType, (__bridge NSString *)kUTTypeWebArchive, WebCore::legacyHTMLPasteboardType(), WebCore::legacyFilenamesPasteboardType(), WebCore::legacyTIFFPasteboardType(), WebCore::legacyPDFPasteboardType(),
-        WebCore::legacyURLPasteboardType(), WebCore::legacyRTFDPasteboardType(), WebCore::legacyRTFPasteboardType(), WebCore::legacyStringPasteboardType(), WebCore::legacyColorPasteboardType(), (__bridge NSString *)kUTTypePNG, nil]);
+    static NSArray *types = retain(@[WebArchivePboardType, (__bridge NSString *)kUTTypeWebArchive, WebCore::legacyHTMLPasteboardType(), WebCore::legacyFilenamesPasteboardType(), WebCore::legacyTIFFPasteboardType(), WebCore::legacyPDFPasteboardType(),
+        WebCore::legacyURLPasteboardType(), WebCore::legacyRTFDPasteboardType(), WebCore::legacyRTFPasteboardType(), WebCore::legacyStringPasteboardType(), WebCore::legacyColorPasteboardType(), (__bridge NSString *)kUTTypePNG]);
     return types;
 }
 
 NSArray* PasteboardTypes::forURL()
 {
-    static NSArray *types = retain([NSArray arrayWithObjects:WebURLsWithTitlesPboardType, WebCore::legacyURLPasteboardType(), WebURLPboardType,  WebURLNamePboardType, WebCore::legacyStringPasteboardType(), WebCore::legacyFilenamesPasteboardType(), WebCore::legacyFilesPromisePasteboardType(), nil]);
+    static NSArray *types = retain(@[WebURLsWithTitlesPboardType, WebCore::legacyURLPasteboardType(), WebURLPboardType,  WebURLNamePboardType, WebCore::legacyStringPasteboardType(), WebCore::legacyFilenamesPasteboardType(), WebCore::legacyFilesPromisePasteboardType()]);
     return types;
 }
 
 NSArray* PasteboardTypes::forImages()
 {
-    static NSArray *types = retain([NSArray arrayWithObjects:WebCore::legacyTIFFPasteboardType(), WebURLsWithTitlesPboardType, WebCore::legacyURLPasteboardType(), WebURLPboardType, WebURLNamePboardType, WebCore::legacyStringPasteboardType(), nil]);
+    static NSArray *types = retain(@[WebCore::legacyTIFFPasteboardType(), WebURLsWithTitlesPboardType, WebCore::legacyURLPasteboardType(), WebURLPboardType, WebURLNamePboardType, WebCore::legacyStringPasteboardType()]);
     return types;
 }
 
 NSArray* PasteboardTypes::forImagesWithArchive()
 {
-    static NSArray *types = retain([NSArray arrayWithObjects:WebCore::legacyTIFFPasteboardType(), WebURLsWithTitlesPboardType, WebCore::legacyURLPasteboardType(), WebURLPboardType, WebURLNamePboardType, WebCore::legacyStringPasteboardType(), WebCore::legacyRTFDPasteboardType(), WebArchivePboardType, nil]);
+    static NSArray *types = retain(@[WebCore::legacyTIFFPasteboardType(), WebURLsWithTitlesPboardType, WebCore::legacyURLPasteboardType(), WebURLPboardType, WebURLNamePboardType, WebCore::legacyStringPasteboardType(), WebCore::legacyRTFDPasteboardType(), WebArchivePboardType]);
     return types;
 }
 
 NSArray* PasteboardTypes::forSelection()
 {
-    static NSArray *types = retain([NSArray arrayWithObjects:WebArchivePboardType, (__bridge NSString *)kUTTypeWebArchive, WebCore::legacyRTFDPasteboardType(), WebCore::legacyRTFPasteboardType(), WebCore::legacyStringPasteboardType(), nil]);
+    static NSArray *types = retain(@[WebArchivePboardType, (__bridge NSString *)kUTTypeWebArchive, WebCore::legacyRTFDPasteboardType(), WebCore::legacyRTFPasteboardType(), WebCore::legacyStringPasteboardType()]);
     return types;
 }
     
index 1d0083c..164f60e 100644 (file)
@@ -32,6 +32,7 @@
 #import "WKErrorInternal.h"
 #import <wtf/BlockPtr.h>
 #import <wtf/CompletionHandler.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 static WKErrorCode toWKErrorCode(const std::error_code& error)
 {
@@ -93,10 +94,7 @@ static WKErrorCode toWKErrorCode(const std::error_code& error)
 - (void)getAvailableContentRuleListIdentifiers:(void (^)(NSArray<NSString *>*))completionHandler
 {
     _contentRuleListStore->getAvailableContentRuleListIdentifiers([completionHandler = makeBlockPtr(completionHandler)](Vector<String> identifiers) {
-        NSMutableArray<NSString *> *nsIdentifiers = [NSMutableArray arrayWithCapacity:identifiers.size()];
-        for (const auto& identifier : identifiers)
-            [nsIdentifiers addObject:identifier];
-        completionHandler(nsIdentifiers);
+        completionHandler(createNSArray(identifiers).get());
     });
 }
 
index 0325845..f5eacee 100644 (file)
@@ -55,6 +55,7 @@
 #import <wtf/BlockPtr.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/WeakObjCPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if PLATFORM(IOS_FAMILY)
 #import <WebCore/WebCoreThreadSystemInterface.h>
@@ -610,10 +611,7 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
 - (void)_getActivePagesOriginsInWebProcessForTesting:(pid_t)pid completionHandler:(void(^)(NSArray<NSString *> *))completionHandler
 {
     _processPool->activePagesOriginsInWebProcessForTesting(pid, [completionHandler = makeBlockPtr(completionHandler)] (Vector<String>&& activePagesOrigins) {
-        NSMutableArray<NSString *> *array = [[[NSMutableArray alloc] initWithCapacity:activePagesOrigins.size()] autorelease];
-        for (auto& origin : activePagesOrigins)
-            [array addObject:origin];
-        completionHandler(array);
+        completionHandler(createNSArray(activePagesOrigins).get());
     });
 }
 
index 588a86b..8e10eff 100644 (file)
@@ -27,6 +27,7 @@
 #import "WKUserScriptInternal.h"
 
 #import "_WKUserContentWorldInternal.h"
+#import <wtf/cocoa/VectorCocoa.h>
 
 @implementation WKUserScript
 
@@ -84,7 +85,7 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     if (!(self = [super init]))
         return nil;
 
-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
 
     return self;
 }
@@ -94,7 +95,7 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     if (!(self = [super init]))
         return nil;
 
-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *userContentWorld->_contentWorld->_contentWorld);
 
     return self;
 }
@@ -110,7 +111,7 @@ ALLOW_DEPRECATED_DECLARATIONS_END
     if (!(self = [super init]))
         return nil;
 
-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), API::UserScript::generateUniqueURL(), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
 
     return self;
 }
@@ -120,7 +121,7 @@ ALLOW_DEPRECATED_DECLARATIONS_END
     if (!(self = [super init]))
         return nil;
 
-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
 
     return self;
 }
@@ -130,7 +131,7 @@ ALLOW_DEPRECATED_DECLARATIONS_END
     if (!(self = [super init]))
         return nil;
 
-    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, deferRunningUntilNotification ? WebCore::WaitForNotificationBeforeInjecting::Yes : WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
+    API::Object::constructInWrapper<API::UserScript>(self, WebCore::UserScript { WTF::String(source), URL(associatedURL), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), API::toWebCoreUserScriptInjectionTime(injectionTime), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, deferRunningUntilNotification ? WebCore::WaitForNotificationBeforeInjecting::Yes : WebCore::WaitForNotificationBeforeInjecting::No }, *contentWorld->_contentWorld);
 
     return self;
 }
index 5e1da5f..708b496 100644 (file)
 #import <wtf/Optional.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/UUID.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/spi/darwin/dyldSPI.h>
 #import <wtf/text/TextStream.h>
 
@@ -438,7 +439,7 @@ static void hardwareKeyboardAvailabilityChangedCallback(CFNotificationCenterRef,
             pageConfiguration->setPageGroup(WebKit::WebPageGroup::create(groupIdentifier).ptr());
     }
 
-    pageConfiguration->setAdditionalSupportedImageTypes(WebCore::webCoreStringVectorFromNSStringArray([_configuration _additionalSupportedImageTypes]));
+    pageConfiguration->setAdditionalSupportedImageTypes(makeVector<String>([_configuration _additionalSupportedImageTypes]));
 
     pageConfiguration->preferences()->setSuppressesIncrementalRendering(!![_configuration suppressesIncrementalRendering]);
 
index 7aa7d11..9bab8c8 100644 (file)
@@ -46,6 +46,7 @@
 #import <wtf/RetainPtr.h>
 #import <wtf/URLParser.h>
 #import <wtf/WeakObjCPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if PLATFORM(IOS_FAMILY)
 #import "UIKitSPI.h"
@@ -897,20 +898,12 @@ ALLOW_DEPRECATED_DECLARATIONS_END
 
 - (NSArray<NSString *> *)_corsDisablingPatterns
 {
-    auto& vector = _pageConfiguration->corsDisablingPatterns();
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:vector.size()];
-    for (auto& pattern : vector)
-        [array addObject:pattern];
-    return array;
+    return createNSArray(_pageConfiguration->corsDisablingPatterns()).autorelease();
 }
 
 - (void)_setCORSDisablingPatterns:(NSArray<NSString *> *)patterns
 {
-    Vector<String> vector;
-    vector.reserveInitialCapacity(patterns.count);
-    for (NSString *pattern in patterns)
-        vector.uncheckedAppend(pattern);
-    _pageConfiguration->setCORSDisablingPatterns(WTFMove(vector));
+    _pageConfiguration->setCORSDisablingPatterns(makeVector<String>(patterns));
 }
 
 - (void)_setLoadsFromNetwork:(BOOL)loads
index 33b81be..a715e23 100644 (file)
@@ -66,7 +66,7 @@
         auto* validationBubble = _page->validationBubble();
         String message = validationBubble ? validationBubble->message() : emptyString();
         double fontSize = validationBubble ? validationBubble->fontSize() : 0;
-        return @{ userInterfaceItem: @{ @"message": (NSString *)message, @"fontSize": [NSNumber numberWithDouble:fontSize] } };
+        return @{ userInterfaceItem: @{ @"message": (NSString *)message, @"fontSize": @(fontSize) } };
     }
 
 #if PLATFORM(IOS_FAMILY)
index 24d4678..27a135b 100644 (file)
@@ -26,6 +26,8 @@
 #import "config.h"
 #import "_WKContentRuleListActionInternal.h"
 
+#import <wtf/cocoa/VectorCocoa.h>
+
 @implementation _WKContentRuleListAction
 
 - (void)dealloc
 
 - (NSArray<NSString *> *)notifications
 {
-    const auto& vector = _action->notifications();
+    auto& vector = _action->notifications();
     if (vector.isEmpty())
         return nil;
-
-    NSMutableArray<NSString *> *array = [[[NSMutableArray alloc] initWithCapacity:vector.size()] autorelease];
-    for (const auto& notification : vector)
-        [array addObject:notification];
-    return array;
+    return createNSArray(vector).autorelease();
 }
 
 - (API::Object&)_apiObject
index ddef71f..50ee845 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "_WKCustomHeaderFieldsInternal.h"
 #import <wtf/BlockPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 @implementation _WKCustomHeaderFields
 
 
 - (NSArray<NSString *> *)thirdPartyDomains
 {
-    auto& domains = _fields->thirdPartyDomains();
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:domains.size()];
-    for (auto& domain : domains)
-        [array addObject:domain];
-    return array;
+    return createNSArray(_fields->thirdPartyDomains()).autorelease();
 }
 
 - (void)setThirdPartyDomains:(NSArray<NSString *> *)thirdPartyDomains
 {
-    Vector<String> domains;
-    domains.reserveInitialCapacity(thirdPartyDomains.count);
-    for (NSString *domain in thirdPartyDomains)
-        domains.uncheckedAppend(domain);
-    _fields->setThirdPartyDomains(WTFMove(domains));
+    _fields->setThirdPartyDomains(makeVector<String>(thirdPartyDomains));
 }
 
 - (API::Object&)_apiObject
index 18dae1c..ad365bc 100644 (file)
@@ -29,6 +29,7 @@
 #import "LegacyGlobalSettings.h"
 #import <objc/runtime.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 @implementation _WKProcessPoolConfiguration
 
 
 - (NSArray *)cachePartitionedURLSchemes
 {
-    auto schemes = _processPoolConfiguration->cachePartitionedURLSchemes();
-    if (schemes.isEmpty())
-        return @[];
-
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:schemes.size()];
-    for (const auto& scheme : schemes)
-        [array addObject:(NSString *)scheme];
-
-    return array;
+    return createNSArray(_processPoolConfiguration->cachePartitionedURLSchemes()).autorelease();
 }
 
 - (void)setCachePartitionedURLSchemes:(NSArray *)cachePartitionedURLSchemes
 {
-    Vector<String> schemes;
-    for (id urlScheme in cachePartitionedURLSchemes) {
-        if ([urlScheme isKindOfClass:[NSString class]])
-            schemes.append(String((NSString *)urlScheme));
-    }
-    
-    _processPoolConfiguration->setCachePartitionedURLSchemes(WTFMove(schemes));
+    _processPoolConfiguration->setCachePartitionedURLSchemes(makeVector<String>(cachePartitionedURLSchemes));
 }
 
 - (NSArray *)alwaysRevalidatedURLSchemes
 {
-    auto& schemes = _processPoolConfiguration->alwaysRevalidatedURLSchemes();
-    if (schemes.isEmpty())
-        return @[];
-
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:schemes.size()];
-    for (auto& scheme : schemes)
-        [array addObject:(NSString *)scheme];
-
-    return array;
+    return createNSArray(_processPoolConfiguration->alwaysRevalidatedURLSchemes()).autorelease();
 }
 
 - (void)setAlwaysRevalidatedURLSchemes:(NSArray *)alwaysRevalidatedURLSchemes
 {
-    Vector<String> schemes;
-    schemes.reserveInitialCapacity(alwaysRevalidatedURLSchemes.count);
-    for (id scheme in alwaysRevalidatedURLSchemes) {
-        if ([scheme isKindOfClass:[NSString class]])
-            schemes.append((NSString *)scheme);
-    }
-
-    _processPoolConfiguration->setAlwaysRevalidatedURLSchemes(WTFMove(schemes));
+    _processPoolConfiguration->setAlwaysRevalidatedURLSchemes(makeVector<String>(alwaysRevalidatedURLSchemes));
 }
 
 - (NSString *)sourceApplicationBundleIdentifier
index 7591bec..286d2b3 100644 (file)
 
 @class WKContentWorld;
 
-namespace API {
-
-inline Vector<WTF::String> toStringVector(NSArray *input)
-{
-    Vector<WTF::String> vector;
-
-    NSUInteger size = input.count;
-    if (!size)
-        return vector;
-
-    vector.reserveInitialCapacity(size);
-    for (id string : input) {
-        if ([string isKindOfClass:[NSString class]])
-            vector.uncheckedAppend(string);
-    }
-    return vector;
-}
-
-}
-
 @interface _WKUserContentWorld () <WKObject> {
 @package
     RetainPtr<WKContentWorld> _contentWorld;
index 6423bcb..46af8ad 100644 (file)
@@ -33,6 +33,7 @@
 #import "WebKit2Initialize.h"
 #import "WebPageProxy.h"
 #import "_WKUserContentWorldInternal.h"
+#import <wtf/cocoa/VectorCocoa.h>
 
 @implementation _WKUserStyleSheet
 
@@ -71,7 +72,7 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
     WebKit::InitializeWebKit2();
 
-    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
+    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
 
     return self;
 }
@@ -84,7 +85,7 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
     WebKit::InitializeWebKit2();
 
-    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), {  URL(), WTF::String([baseURL _web_originalDataAsWTFString]) }, API::toStringVector(legacyWhitelist), API::toStringVector(legacyBlacklist), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
+    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), {  URL(), WTF::String([baseURL _web_originalDataAsWTFString]) }, makeVector<String>(legacyWhitelist), makeVector<String>(legacyBlacklist), forMainFrameOnly ? WebCore::UserContentInjectedFrames::InjectInTopFrameOnly : WebCore::UserContentInjectedFrames::InjectInAllFrames, WebCore::UserStyleUserLevel }, *userContentWorld->_contentWorld->_contentWorld);
 
     return self;
 }
index 76dfffe..46af73b 100644 (file)
 #import <wtf/SetForScope.h>
 #import <wtf/SoftLinking.h>
 #import <wtf/cf/TypeCastsCF.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/StringConcatenate.h>
 
 #if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
@@ -3668,7 +3669,7 @@ id WebViewImpl::accessibilityAttributeValue(NSString *attribute, id parameter)
 
             if (!child)
                 return nil;
-        return [NSArray arrayWithObject:child];
+        return @[child];
     }
     if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
         return NSAccessibilityGroupRole;
@@ -4043,11 +4044,7 @@ bool WebViewImpl::performDragOperation(id <NSDraggingInfo> draggingInfo)
             return false;
         }
 
-        Vector<String> fileNames;
-
-        for (NSString *file in files)
-            fileNames.append(file);
-        m_page->createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
+        m_page->createSandboxExtensionsIfNeeded(makeVector<String>(files), sandboxExtensionHandle, sandboxExtensionForUpload);
     }
 
     String draggingPasteboardName = draggingInfo.draggingPasteboard.name;
@@ -4335,7 +4332,7 @@ NSArray *WebViewImpl::namesOfPromisedFilesDroppedAtDestination(NSURL *dropDestin
     if (!m_promisedURL.isEmpty())
         FileSystem::setMetadataURL(String(path), m_promisedURL);
 
-    return [NSArray arrayWithObject:[path lastPathComponent]];
+    return @[[path lastPathComponent]];
 }
 
 void WebViewImpl::requestDOMPasteAccess(const WebCore::IntRect&, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completion)
@@ -4749,7 +4746,7 @@ Vector<WebCore::KeypressCommand> WebViewImpl::collectKeyboardLayoutCommandsForEv
     if (NSTextInputContext *context = inputContext())
         [context handleEventByKeyboardLayout:event];
     else
-        [m_view interpretKeyEvents:[NSArray arrayWithObject:event]];
+        [m_view interpretKeyEvents:@[event]];
 
     m_collectedKeypressCommands = nullptr;
 
index a8a7b65..56f7ed2 100644 (file)
@@ -40,6 +40,7 @@
 #import <wtf/FileSystem.h>
 #import <wtf/ProcessPrivilege.h>
 #import <wtf/URL.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/CString.h>
 
 @interface WKPlaceholderModalWindow : NSWindow 
@@ -251,11 +252,7 @@ void PluginProcessProxy::launchProcess(const String& launchPath, const Vector<St
     if (!shouldLaunchProcess(m_pluginProcessAttributes, launchPath, arguments))
         return completionHandler(false);
 
-    RetainPtr<NSMutableArray> argumentsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:arguments.size()]);
-    for (size_t i = 0; i < arguments.size(); ++i)
-        [argumentsArray addObject:(NSString *)arguments[i]];
-
-    [NSTask launchedTaskWithLaunchPath:launchPath arguments:argumentsArray.get()];
+    [NSTask launchedTaskWithLaunchPath:launchPath arguments:createNSArray(arguments).get()];
     completionHandler(true);
 }
 
@@ -265,10 +262,10 @@ static bool isJavaUpdaterURL(const PluginProcessAttributes& pluginProcessAttribu
     if (![url isFileURL])
         return false;
 
-    NSArray *javaUpdaterAppNames = [NSArray arrayWithObjects:@"Java Updater.app", @"JavaUpdater.app", nil];
+    NSArray *javaUpdaterAppNames = @[@"Java Updater.app", @"JavaUpdater.app"];
 
     for (NSString *javaUpdaterAppName in javaUpdaterAppNames) {
-        NSString *javaUpdaterPath = [NSString pathWithComponents:[NSArray arrayWithObjects:(NSString *)pluginProcessAttributes.moduleInfo.path, @"Contents/Resources", javaUpdaterAppName, nil]];
+        NSString *javaUpdaterPath = [NSString pathWithComponents:@[(NSString *)pluginProcessAttributes.moduleInfo.path, @"Contents/Resources", javaUpdaterAppName]];
         if ([url.path isEqualToString:javaUpdaterPath])
             return YES;
     }
@@ -289,20 +286,16 @@ void PluginProcessProxy::launchApplicationAtURL(const String& urlString, const V
     if (!shouldLaunchApplicationAtURL(m_pluginProcessAttributes, urlString))
         return completionHandler(false);
 
-    RetainPtr<NSMutableArray> argumentsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:arguments.size()]);
-    for (size_t i = 0; i < arguments.size(); ++i)
-        [argumentsArray addObject:(NSString *)arguments[i]];
-
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    NSDictionary *configuration = [NSDictionary dictionaryWithObject:argumentsArray.get() forKey:NSWorkspaceLaunchConfigurationArguments];
+ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    auto configuration = @{ NSWorkspaceLaunchConfigurationArguments: createNSArray(arguments).get() };
     [[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL URLWithString:urlString] options:NSWorkspaceLaunchAsync configuration:configuration error:nullptr];
-    ALLOW_DEPRECATED_DECLARATIONS_END
+ALLOW_DEPRECATED_DECLARATIONS_END
     completionHandler(true);
 }
 
 static bool isSilverlightPreferencesURL(const PluginProcessAttributes& pluginProcessAttributes, const String& urlString)
 {
-    NSURL *silverlightPreferencesURL = [NSURL fileURLWithPathComponents:[NSArray arrayWithObjects:(NSString *)pluginProcessAttributes.moduleInfo.path, @"Contents/Resources/Silverlight Preferences.app", nil]];
+    NSURL *silverlightPreferencesURL = [NSURL fileURLWithPathComponents:@[(NSString *)pluginProcessAttributes.moduleInfo.path, @"Contents/Resources/Silverlight Preferences.app"]];
 
     return [[NSURL URLWithString:urlString] isEqual:silverlightPreferencesURL];
 }
index db0abb8..2b88c9f 100644 (file)
@@ -53,8 +53,8 @@ HidService::HidService(Observer& observer)
 {
     m_manager = adoptCF(IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone));
     NSDictionary *matchingDictionary = @{
-        @kIOHIDPrimaryUsagePageKey: adoptNS([NSNumber numberWithInt:kCtapHidUsagePage]).get(),
-        @kIOHIDPrimaryUsageKey: adoptNS([NSNumber numberWithInt:kCtapHidUsage]).get()
+        @kIOHIDPrimaryUsagePageKey: @(kCtapHidUsagePage),
+        @kIOHIDPrimaryUsageKey: @(kCtapHidUsage),
     };
     IOHIDManagerSetDeviceMatching(m_manager.get(), (__bridge CFDictionaryRef)matchingDictionary);
     IOHIDManagerRegisterDeviceMatchingCallback(m_manager.get(), deviceAddedCallback, this);
index fe493f9..5671255 100644 (file)
@@ -118,7 +118,7 @@ void MockLocalConnection::getAttestation(SecKeyRef, NSData *, NSData *, Attestat
 
         auto attestationCertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)adoptNS([[NSData alloc] initWithBase64EncodedString:configuration.local->userCertificateBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get()));
         auto attestationIssuingCACertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)adoptNS([[NSData alloc] initWithBase64EncodedString:configuration.local->intermediateCACertificateBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get()));
-        callback([NSArray arrayWithObjects: (__bridge id)attestationCertificate.get(), (__bridge id)attestationIssuingCACertificate.get(), nil], NULL);
+        callback(@[ (__bridge id)attestationCertificate.get(), (__bridge id)attestationIssuingCACertificate.get()], NULL);
     });
 }
 
index c7ee369..0eb08a9 100644 (file)
 #import <WebCore/VisibleSelection.h>
 #import <WebCore/WebEvent.h>
 #import <WebCore/WritingDirection.h>
-#import <WebKit/WebSelectionRect.h> // FIXME: WK2 should not include WebKit headers!
-#import <pal/ios/ManagedConfigurationSoftLink.h>
+#import <WebKit/WebSelectionRect.h> // FIXME: WebKit should not include WebKitLegacy headers!
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
 #import <pal/spi/cocoa/LaunchServicesSPI.h>
 #import <wtf/SetForScope.h>
 #import <wtf/WeakObjCPtr.h>
 #import <wtf/cocoa/NSURLExtras.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/TextStream.h>
 
 #if ENABLE(DRAG_SUPPORT)
 #import <WebCore/TextAlternativeWithRange.h>
 #endif
 
+#import <pal/ios/ManagedConfigurationSoftLink.h>
+
 #if HAVE(LINK_PREVIEW) && USE(UICONTEXTMENU)
 static NSString * const webkitShowLinkPreviewsPreferenceKey = @"WebKitShowLinkPreviews";
 #endif
@@ -3185,7 +3187,7 @@ WEBCORE_COMMAND_FOR_WEBVIEW(pasteAndMatchStyle);
         [result setObject:(id)font.get() forKey:NSFontAttributeName];
     
     if (typingAttributes & WebKit::AttributeUnderline)
-        [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
+        [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];
 
     return result;
 }
@@ -3984,10 +3986,7 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
         }
 
         strongSelf->_page->requestEvasionRectsAboveSelection([completion = WTFMove(completion)] (auto& rects) {
-            auto rectsAsValues = adoptNS([[NSMutableArray alloc] initWithCapacity:rects.size()]);
-            for (auto& floatRect : rects)
-                [rectsAsValues addObject:[NSValue valueWithCGRect:floatRect]];
-            completion(rectsAsValues.get());
+            completion(createNSArray(rects).get());
         });
     });
 }
@@ -7410,7 +7409,7 @@ static NSArray<NSItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop
     for (NSItemProvider *itemProvider in adjustedItemProviders) {
         auto item = adoptNS([[UIDragItem alloc] initWithItemProvider:itemProvider]);
         [item _setPrivateLocalContext:@(stagedDragSource.itemIdentifier)];
-        [dragItems addObject:item.autorelease()];
+        [dragItems addObject:item.get()];
     }
 
     return dragItems;
@@ -8440,7 +8439,6 @@ static Vector<WebCore::IntSize> sizesOfPlaceholderElementsToInsertWhenDroppingIt
                 @"isImage": [NSNumber numberWithBool:_positionInformation.isImage],
                 @"imageURL": _positionInformation.imageURL.isValid() ? WTF::userVisibleString(_positionInformation.imageURL) : @""
             } };
-
         NSString *url = [_previewItemController previewData][UIPreviewDataLink];
         return @{ userInterfaceItem: @{
             @"url": url,
index 2f92bb6..d8b3006 100644 (file)
@@ -666,12 +666,12 @@ static NSString *displayStringForDocumentsAtURLs(NSArray<NSURL *> *urls)
 
     [self _dismissDisplayAnimated:YES];
 
-    [self _processMediaInfoDictionaries:[NSArray arrayWithObject:info]
+    [self _processMediaInfoDictionaries:@[info]
         successBlock:^(NSArray *processedResults, NSString *displayString) {
             ASSERT([processedResults count] == 1);
             _WKFileUploadItem *result = [processedResults objectAtIndex:0];
             dispatch_async(dispatch_get_main_queue(), ^{
-                [self _chooseFiles:[NSArray arrayWithObject:result.fileURL] displayString:displayString iconImage:result.displayImage];
+                [self _chooseFiles:@[result.fileURL] displayString:displayString iconImage:result.displayImage];
             });
         }
         failureBlock:^{
index fe39f83..ce67842 100644 (file)
@@ -112,8 +112,7 @@ using namespace WebKit;
             [buttons addObject:button];
             [self addSubview:button];
         }
-        RetainPtr<NSArray> colorButtonsRow = buttons;
-        [colorButtons addObject:colorButtonsRow.get()];
+        [colorButtons addObject:buttons];
     }
     _colorButtons = colorButtons;
 
index fe4e846..723b326 100644 (file)
@@ -30,6 +30,7 @@
 
 #import "WebPageProxy.h"
 #import "WebViewImpl.h"
+#import <wtf/cocoa/VectorCocoa.h>
 
 static inline NSCorrectionIndicatorType correctionIndicatorType(WebCore::AlternativeTextType alternativeTextType)
 {
@@ -65,28 +66,25 @@ CorrectionPanel::~CorrectionPanel()
 void CorrectionPanel::show(NSView *view, WebViewImpl& webViewImpl, AlternativeTextType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
 {
     dismissInternal(ReasonForDismissingAlternativeTextIgnored, false);
-    
+
     if (!view)
         return;
 
     NSInteger spellCheckerDocumentTag = webViewImpl.spellCheckerDocumentTag();
 
-    NSString* replacedStringAsNSString = replacedString;
-    NSString* replacementStringAsNSString = replacementString;
+    NSString *replacedStringAsNSString = replacedString;
+    NSString *replacementStringAsNSString = replacementString;
+
     m_view = view;
     m_spellCheckerDocumentTag = spellCheckerDocumentTag;
     NSCorrectionIndicatorType indicatorType = correctionIndicatorType(type);
     
-    NSMutableArray* alternativeStrings = 0;
-    if (!alternativeReplacementStrings.isEmpty()) {
-        size_t size = alternativeReplacementStrings.size();
-        alternativeStrings = [NSMutableArray arrayWithCapacity:size];
-        for (size_t i = 0; i < size; ++i)
-            [alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]];
-    }
+    RetainPtr<NSArray> alternativeStrings;
+    if (!alternativeReplacementStrings.isEmpty())
+        alternativeStrings = createNSArray(alternativeReplacementStrings);
 
     NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
-    [spellChecker showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxOfReplacedString view:m_view.get() completionHandler:^(NSString* acceptedString) {
+    [spellChecker showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings.get() forStringInRect:boundingBoxOfReplacedString view:m_view.get() completionHandler:^(NSString* acceptedString) {
         handleAcceptedReplacement(webViewImpl, acceptedString, replacedStringAsNSString, replacementStringAsNSString, indicatorType);
     }];
 }
index d786f11..01619a5 100644 (file)
@@ -33,6 +33,7 @@
 #import <pal/spi/mac/NSSpellCheckerSPI.h>
 #import <wtf/NeverDestroyed.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/StringView.h>
 
 @interface NSSpellChecker (WebNSSpellCheckerDetails)
@@ -435,13 +436,10 @@ void TextChecker::updateSpellingUIWithMisspelledWord(SpellDocumentTag, const Str
 
 void TextChecker::updateSpellingUIWithGrammarString(SpellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
 {
-    auto corrections = adoptNS([[NSMutableArray alloc] init]);
-    for (auto& guess : grammarDetail.guesses)
-        [corrections addObject:guess];
     NSDictionary *detail = @{
         NSGrammarRange : [NSValue valueWithRange:grammarDetail.range],
         NSGrammarUserDescription : grammarDetail.userDescription,
-        NSGrammarCorrections : corrections.get(),
+        NSGrammarCorrections : createNSArray(grammarDetail.guesses).get(),
     };
     [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithGrammarString:badGrammarPhrase detail:detail];
 }
@@ -459,10 +457,7 @@ void TextChecker::getGuessesForWord(SpellDocumentTag spellDocumentTag, const Str
         [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:options inSpellDocumentWithTag:spellDocumentTag orthography:&orthography wordCount:0];
         language = [checker languageForWordRange:NSMakeRange(0, context.length()) inString:context orthography:orthography];
     }
-    NSArray* stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellDocumentTag];
-
-    for (NSString *guess in stringsArray)
-        guesses.append(guess);
+    guesses = makeVector<String>([checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellDocumentTag]);
 }
 
 void TextChecker::learnWord(SpellDocumentTag, const String& word)
index 01e4321..5904c42 100644 (file)
@@ -145,8 +145,8 @@ static BOOL isForcingPreviewUpdate;
         ASSERT(![infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey]);
         originalTopMargin = [info topMargin];
         originalBottomMargin = [info bottomMargin];
-        [infoDictionary setObject:[NSNumber numberWithDouble:originalTopMargin] forKey:WebKitOriginalTopPrintingMarginKey];
-        [infoDictionary setObject:[NSNumber numberWithDouble:originalBottomMargin] forKey:WebKitOriginalBottomPrintingMarginKey];
+        [infoDictionary setObject:@(originalTopMargin) forKey:WebKitOriginalTopPrintingMarginKey];
+        [infoDictionary setObject:@(originalBottomMargin) forKey:WebKitOriginalBottomPrintingMarginKey];
     } else {
         ASSERT([originalTopMarginNumber isKindOfClass:[NSNumber class]]);
         ASSERT([[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] isKindOfClass:[NSNumber class]]);
index 3968eda..36abdfd 100644 (file)
@@ -37,6 +37,7 @@
 #import <wtf/BlockPtr.h>
 #import <wtf/Deque.h>
 #import <wtf/NakedPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 // FIXME: Implement scrollFindMatchToVisible.
 // FIXME: The NSTextFinder overlay doesn't move with scrolling; we should have a mode where we manage the overlay.
@@ -270,31 +271,21 @@ private:
 
 #pragma mark - FindMatchesClient
 
-static RetainPtr<NSArray> arrayFromRects(const Vector<WebCore::IntRect>& matchRects)
-{
-    RetainPtr<NSMutableArray> nsMatchRects = adoptNS([[NSMutableArray alloc] initWithCapacity:matchRects.size()]);
-    for (auto& rect : matchRects)
-        [nsMatchRects addObject:[NSValue valueWithRect:rect]];
-    return nsMatchRects;
-}
-
 - (void)didFindStringMatchesWithRects:(const Vector<Vector<WebCore::IntRect>>&)rectsForMatches didWrapAround:(BOOL)didWrapAround
 {
     if (_findReplyCallbacks.isEmpty())
         return;
 
     auto replyCallback = _findReplyCallbacks.takeFirst();
-    unsigned matchCount = rectsForMatches.size();
-    RetainPtr<NSMutableArray> matchObjects = adoptNS([[NSMutableArray alloc] initWithCapacity:matchCount]);
+    auto matchCount = rectsForMatches.size();
+    auto matchObjects = adoptNS([[NSMutableArray alloc] initWithCapacity:matchCount]);
     for (unsigned i = 0; i < matchCount; i++) {
         RetainPtr<NSArray> nsMatchRects;
-
         if (_usePlatformFindUI)
-            nsMatchRects = arrayFromRects(rectsForMatches[i]);
+            nsMatchRects = createNSArray(rectsForMatches[i]);
         else
             nsMatchRects = @[];
-        RetainPtr<WKTextFinderMatch> match = adoptNS([[WKTextFinderMatch alloc] initWithClient:self view:_view index:i rects:nsMatchRects.get()]);
-        [matchObjects addObject:match.get()];
+        [matchObjects addObject:adoptNS([[WKTextFinderMatch alloc] initWithClient:self view:_view index:i rects:nsMatchRects.get()]).get()];
     }
 
     replyCallback(matchObjects.get(), didWrapAround);
index 3bd941c..7d20244 100644 (file)
@@ -379,10 +379,10 @@ static BOOL shouldShowDividersBetweenCells(const Vector<WebCore::DataListSuggest
 
 - (void)notifyAccessibilityClients:(NSString *)info
 {
-    NSDictionary<NSAccessibilityNotificationUserInfoKey, id> *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
-        NSAccessibilityPriorityKey, @(NSAccessibilityPriorityHigh),
-        NSAccessibilityAnnouncementKey, info, nil];
-    NSAccessibilityPostNotificationWithUserInfo(NSApp, NSAccessibilityAnnouncementRequestedNotification, userInfo);
+    NSAccessibilityPostNotificationWithUserInfo(NSApp, NSAccessibilityAnnouncementRequestedNotification, @{
+        NSAccessibilityPriorityKey: @(NSAccessibilityPriorityHigh),
+        NSAccessibilityAnnouncementKey: info,
+    });
 }
 
 - (void)moveSelectionByDirection:(const String&)direction
index d2d90e3..834307c 100644 (file)
@@ -160,7 +160,7 @@ void WebPageProxy::searchWithSpotlight(const String& string)
 void WebPageProxy::searchTheWeb(const String& string)
 {
     NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
-    [pasteboard declareTypes:[NSArray arrayWithObject:legacyStringPasteboardType()] owner:nil];
+    [pasteboard declareTypes:@[legacyStringPasteboardType()] owner:nil];
     [pasteboard setString:string forType:legacyStringPasteboardType()];
     
     NSPerformService(@"Search With %WebSearchProvider@", pasteboard);
index 151b9bc..7a3de83 100644 (file)
@@ -109,8 +109,4 @@ WKDOMText *toWKDOMText(WebCore::Text*);
 WebCore::Range* toWebCoreRange(WKDOMRange *);
 WKDOMRange *toWKDOMRange(WebCore::Range*);
 
-// -- Helpers --
-
-NSArray *toNSArray(const Vector<WebCore::IntRect>&);
-
 } // namespace WebKit
index f41e94c..63cdd2b 100644 (file)
@@ -161,13 +161,4 @@ static WKDOMType toWKDOMType(WebCoreType impl, DOMCache<WebCoreType, WKDOMType>&
     return [wrapper autorelease];
 }
 
-NSArray *toNSArray(const Vector<WebCore::IntRect>& rects)
-{
-    size_t size = rects.size();
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:size];
-    for (size_t i = 0; i < size; ++i)
-        [array addObject:[NSValue valueWithRect:rects[i]]];
-    return array;
-}
-
 } // namespace WebKit
index f9c571d..cd8061e 100644 (file)
@@ -30,6 +30,7 @@
 #import "WKBundleAPICast.h"
 #import "WKDOMInternals.h"
 #import <WebCore/Document.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 @implementation WKDOMNode
 
         return nil;
     Vector<WebCore::IntRect> rects;
     _impl->textRects(rects);
-    return WebKit::toNSArray(rects);
+    return createNSArray(rects).autorelease();
 }
 
 @end
 
 - (WKBundleNodeHandleRef)_copyBundleNodeHandleRef
 {
-    auto nodeHandle = WebKit::InjectedBundleNodeHandle::getOrCreate(_impl.get());
-    return toAPI(nodeHandle.leakRef());
+    return toAPI(WebKit::InjectedBundleNodeHandle::getOrCreate(_impl.get()).leakRef());
 }
 
 @end
index 22be462..ac6ffb1 100644 (file)
@@ -31,6 +31,7 @@
 #import "WKDOMInternals.h"
 #import <WebCore/Document.h>
 #import <WebCore/VisibleUnits.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 @implementation WKDOMRange
 
     _impl->ownerDocument().updateLayoutIgnorePendingStylesheets();
     Vector<WebCore::IntRect> rects;
     _impl->absoluteTextRects(rects);
-    return WebKit::toNSArray(rects);
+    return createNSArray(rects).autorelease();
 }
 
 - (WKDOMRange *)rangeByExpandingToWordBoundaryByCharacters:(NSUInteger)characters inDirection:(WKDOMRangeDirection)direction
index 0e894fc..a6da919 100644 (file)
@@ -255,7 +255,7 @@ void InjectedBundle::setBundleParameter(const String& key, const IPC::DataRefere
     }
 
     if (!m_bundleParameters && parameter)
-        m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:[NSDictionary dictionary]]);
+        m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:@{ }]);
 
     [m_bundleParameters setParameter:parameter forKey:key];
 }
index 5661ef9..3513b03 100644 (file)
@@ -43,7 +43,7 @@ static void makeRenderLayer(CALayer *pluginLayer, uint32_t layerHostingContextID
     CALayer *renderLayer = [CALayer _web_renderLayerWithContextID:layerHostingContextID];
     [renderLayer setFrame:[pluginLayer bounds]];
     [renderLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
-    [pluginLayer setSublayers:[NSArray arrayWithObject:renderLayer]];
+    [pluginLayer setSublayers:@[renderLayer]];
 }
 
 PlatformLayer* PluginProxy::pluginLayer()
index 45d6d7a..aed301a 100644 (file)
@@ -94,6 +94,7 @@
 #import <wtf/UUID.h>
 #import <wtf/WTFSemaphore.h>
 #import <wtf/WorkQueue.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/TextStream.h>
 
 #if HAVE(INCREMENTAL_PDF_APIS)
@@ -2405,10 +2406,7 @@ void PDFPlugin::openWithNativeApplication()
 
 void PDFPlugin::writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types)
 {
-    Vector<String> pasteboardTypes;
-
-    for (NSString *type in types)
-        pasteboardTypes.append(type);
+    auto pasteboardTypes = makeVector<String>(types);
 
     int64_t newChangeCount;
     auto& webProcess = WebProcess::singleton();
index 70e5285..427d442 100644 (file)
@@ -3710,7 +3710,7 @@ void WebPage::applicationWillResignActive()
 
 void WebPage::applicationDidEnterBackground(bool isSuspendedUnderLock)
 {
-    [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidEnterBackgroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": [NSNumber numberWithBool:isSuspendedUnderLock]}];
+    [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidEnterBackgroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": @(isSuspendedUnderLock)}];
 
     m_isSuspendedUnderLock = isSuspendedUnderLock;
     freezeLayerTree(LayerTreeFreezeReason::BackgroundApplication);
index 9c0887e..028a88c 100644 (file)
@@ -526,7 +526,7 @@ void TiledCoreAnimationDrawingArea::suspendPainting()
 
     // This is a signal to media frameworks; it does not actively pause anything.
     [m_hostingLayer setValue:@YES forKey:@"NSCAViewRenderPaused"];
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidPauseNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:m_hostingLayer.get() forKey:@"layer"]];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidPauseNotification" object:nil userInfo:@{ @"layer": m_hostingLayer.get() }];
 }
 
 void TiledCoreAnimationDrawingArea::resumePainting()
@@ -539,7 +539,7 @@ void TiledCoreAnimationDrawingArea::resumePainting()
     m_isPaintingSuspended = false;
 
     [m_hostingLayer setValue:@NO forKey:@"NSCAViewRenderPaused"];
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:m_hostingLayer.get() forKey:@"layer"]];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:@{ @"layer": m_hostingLayer.get() }];
 }
 
 void TiledCoreAnimationDrawingArea::setViewExposedRect(Optional<FloatRect> viewExposedRect)
index 08fe7fd..a1d6e30 100644 (file)
@@ -41,7 +41,6 @@
 #import <WebCore/Page.h>
 #import <WebCore/ScrollView.h>
 #import <WebCore/Scrollbar.h>
-#import <wtf/ObjCRuntimeExtras.h>
 
 @implementation WKAccessibilityWebPageObjectBase
 
index f0ceca2..a09ff61 100644 (file)
@@ -47,7 +47,6 @@
 #import <WebCore/Scrollbar.h>
 #import <WebCore/WebAccessibilityObjectWrapperMac.h>
 #import <pal/spi/cocoa/NSAccessibilitySPI.h>
-#import <wtf/ObjCRuntimeExtras.h>
 
 namespace ax = WebCore::Accessibility;
 
@@ -142,16 +141,16 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
 - (NSArray *)accessibilityActionNames
 ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 {
-    return [NSArray array];
+    return @[];
 }
 
 - (NSArray *)accessibilityChildren
 {
     id wrapper = [self accessibilityRootObjectWrapper];
     if (!wrapper)
-        return [NSArray array];
+        return @[];
     
-    return [NSArray arrayWithObject:wrapper];
+    return @[wrapper];
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
index 204d45a..4b45847 100644 (file)
@@ -88,6 +88,7 @@
 #import <wtf/ProcessPrivilege.h>
 #import <wtf/cocoa/NSURLExtras.h>
 #import <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if ENABLE(REMOTE_INSPECTOR)
 #include <JavaScriptCore/RemoteInspector.h>
@@ -664,12 +665,7 @@ void WebProcess::updateActivePages(const String& overrideDisplayName)
 void WebProcess::getActivePagesOriginsForTesting(CompletionHandler<void(Vector<String>&&)>&& completionHandler)
 {
 #if PLATFORM(MAC)
-    auto activeOriginsAsNSStrings = activePagesOrigins(m_pageMap);
-    Vector<String> activeOrigins;
-    activeOrigins.reserveInitialCapacity([activeOriginsAsNSStrings count]);
-    for (NSString* activeOrigin in activeOriginsAsNSStrings.get())
-        activeOrigins.uncheckedAppend(activeOrigin);
-    completionHandler(WTFMove(activeOrigins));
+    completionHandler(makeVector<String>(activePagesOrigins(m_pageMap).get()));
 #else
     completionHandler({ });
 #endif
index 83a0d95..fa21b96 100644 (file)
@@ -1,3 +1,23 @@
+2020-04-08  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=210138
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebChromeClientIOS.mm:
+        (WebChromeClientIOS::runOpenPanel): Use createNSArray.
+
+        * WebCoreSupport/WebVisiblePosition.mm:
+        (-[WebVisiblePosition enclosingRangeWithDictationPhraseAlternatives:]):
+        Use createNSArray.
+
+        * WebCoreSupport/WebVisiblePositionInternal.h:
+        Added #if so that this correctly doesn't compile anything on Mac.
+
+        * WebView/WebPDFViewIOS.mm:
+        (+[WebPDFView supportedMIMETypes]): Use @[].
+
 2020-04-04  Darin Adler  <darin@apple.com>
 
         Stop using live ranges in DocumentMarkerController
index 33e5ef5..87543b0 100644 (file)
@@ -63,6 +63,7 @@
 #import <WebCore/WebCoreThreadMessage.h>
 #import <wtf/HashMap.h>
 #import <wtf/RefPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 NSString * const WebOpenPanelConfigurationAllowMultipleFilesKey = @"WebOpenPanelConfigurationAllowMultipleFilesKey";
 NSString * const WebOpenPanelConfigurationMediaCaptureTypeKey = @"WebOpenPanelConfigurationMediaCaptureTypeKey";
@@ -134,17 +135,13 @@ void WebChromeClientIOS::runOpenPanel(Frame&, FileChooser& chooser)
     BOOL allowMultipleFiles = settings.allowsMultipleFiles;
     WebOpenPanelResultListener *listener = [[WebOpenPanelResultListener alloc] initWithChooser:chooser];
 
-    NSMutableArray *mimeTypes = [NSMutableArray arrayWithCapacity:settings.acceptMIMETypes.size()];
-    for (auto& type : settings.acceptMIMETypes)
-        [mimeTypes addObject:type];
-
     WebMediaCaptureType captureType = WebMediaCaptureTypeNone;
 #if ENABLE(MEDIA_CAPTURE)
     captureType = webMediaCaptureType(settings.mediaCaptureType);
 #endif
     NSDictionary *configuration = @{
         WebOpenPanelConfigurationAllowMultipleFilesKey: @(allowMultipleFiles),
-        WebOpenPanelConfigurationMimeTypesKey: mimeTypes,
+        WebOpenPanelConfigurationMimeTypesKey: createNSArray(settings.acceptMIMETypes).get(),
         WebOpenPanelConfigurationMediaCaptureTypeKey: @(captureType)
     };
 
index 691f851..54325ad 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if PLATFORM(IOS_FAMILY)
-
-#import "WebVisiblePosition.h"
 #import "WebVisiblePositionInternal.h"
 
+#if PLATFORM(IOS_FAMILY)
+
+#import "DOMNodeInternal.h"
+#import "DOMRangeInternal.h"
 #import <WebCore/DocumentMarkerController.h>
 #import <WebCore/Editing.h>
 #import <WebCore/FrameSelection.h>
 #import <WebCore/TextFlags.h>
 #import <WebCore/TextGranularity.h>
 #import <WebCore/TextIterator.h>
-#import <WebCore/VisiblePosition.h>
 #import <WebCore/VisibleUnits.h>
-
-
-#import "DOMNodeInternal.h"
-#import "DOMRangeInternal.h"
+#import <wtf/cocoa/VectorCocoa.h>
 
 using namespace WebCore;
 
@@ -418,11 +415,7 @@ static inline SelectionDirection toSelectionDirection(WebTextAdjustmentDirection
     auto& document = node->document();
     for (auto marker : document.markers().markersFor(*node, DocumentMarker::DictationPhraseWithAlternatives)) {
         if (marker->startOffset() <= offset && marker->endOffset() >= offset) {
-            auto& markerAlternatives = WTF::get<Vector<String>>(marker->data());
-            auto array = [NSMutableArray arrayWithCapacity:markerAlternatives.size()];
-            for (auto& alternative : markerAlternatives)
-                [array addObject:alternative];
-            *alternatives = array;
+            *alternatives = createNSArray(WTF::get<Vector<String>>(marker->data())).autorelease();
             return kit(Range::create(document, node, marker->startOffset(), node, marker->endOffset()).ptr());
         }
     }
index d29f141..765c59d 100644 (file)
@@ -23,8 +23,9 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "WebVisiblePosition.h"
+#if PLATFORM(IOS_FAMILY)
 
+#import "WebVisiblePosition.h"
 #import <WebCore/VisiblePosition.h>
 
 @interface WebVisiblePosition (Internal)
@@ -33,3 +34,5 @@
 - (WebCore::VisiblePosition)_visiblePosition;
 
 @end
+
+#endif
index f982bd1..be5d647 100644 (file)
@@ -75,10 +75,10 @@ static CGColorRef createCGColorWithDeviceWhite(CGFloat white, CGFloat alpha)
 
 + (NSArray *)supportedMIMETypes
 {
-    return [NSArray arrayWithObjects:
+    return @[
         @"text/pdf",
         @"application/pdf",
-        nil];
+    ];
 }
 
 + (CGColorRef)shadowColor
index 604b159..74ded96 100644 (file)
@@ -1,3 +1,157 @@
+2020-04-08  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=210138
+
+        Reviewed by Alex Christensen.
+
+        * DOM/DOM.mm:
+        (kit): Deleted overload that takes Vector<IntRect>.
+        (-[DOMNode textRects]): Use createNSArray.
+        (-[DOMRange textRects]): Ditto.
+
+        * DOM/ExceptionHandlers.mm:
+        (raiseDOMErrorException): Use @().
+
+        * History/WebBackForwardList.mm:
+        (-[WebBackForwardList dictionaryRepresentation]): Use @{}.
+
+        * History/WebHistory.mm:
+        (+[WebHistoryPrivate initialize]): Use @{}.
+        (-[WebHistory _sendNotification:entries:]): Use @{}.
+
+        * History/WebHistoryItem.mm:
+        (-[WebHistoryItem initFromDictionaryRepresentation:]): Use makeVector<String>.
+        (-[WebHistoryItem dictionaryRepresentation:]): Use createNSArray and @().
+
+        * History/WebURLsWithTitles.m:
+        (+[WebURLsWithTitles arrayWithIFURLsWithTitlesPboardType]): Use @[].
+        (+[WebURLsWithTitles writeURLs:andTitles:toPasteboard:]): Use @[].
+
+        * Misc/WebCache.mm:
+        (+[WebCache statistics]): Use @[], @{}, and @().
+        * Misc/WebCoreStatistics.mm:
+        (+[WebCoreStatistics memoryStatistics]): Ditto.
+
+        * Misc/WebKitErrors.m:
+        (-[NSError _webkit_initWithDomain:code:URL:]): Use @().
+        (+[NSError _registerWebKitErrors]): Use @().
+        (-[NSError _initWithPluginErrorCode:contentURL:pluginPageURL:pluginName:MIMEType:]): Use @().
+
+        * Misc/WebKitNSStringExtras.mm:
+        (-[NSString _web_drawAtPoint:font:textColor:]): Use @{}.
+        (-[NSString _web_widthWithFont:]): Use @{}.
+
+        * Misc/WebNSFileManagerExtras.mm: Removed unneeded include.
+
+        * Misc/WebNSPasteboardExtras.mm:
+        (+[NSPasteboard _web_dragTypesForURL]): Use @[].
+        (-[NSPasteboard _web_writeURL:andTitle:types:]): Use @[].
+        (+[NSPasteboard _web_setFindPasteboardString:withOwner:]): Use @[].
+
+        * Misc/WebNSURLExtras.mm: Removed unneeded include.
+
+        * Plugins/Hosted/NetscapePluginHostManager.mm:
+        (WebKit::NetscapePluginHostManager::spawnPluginHost): Use @{}.
+
+        * Plugins/Hosted/NetscapePluginHostProxy.mm:
+        (WKPCIdentifierInfo): Use @().
+
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::addValueToArray): Use @().
+
+        * Plugins/Hosted/WebHostedNetscapePluginView.mm: Removed unneeded include.
+        * Plugins/WebBasePluginPackage.mm: Ditto.
+
+        * Plugins/WebPluginContainerCheck.mm:
+        (-[WebPluginContainerCheck _actionInformationWithURL:]): Use @{}.
+
+        * Plugins/WebPluginDatabase.mm:
+        (+[WebPluginDatabase _defaultPlugInPaths]): Use @[].
+
+        * Storage/WebDatabaseManager.mm:
+        (-[WebDatabaseManager databasesWithOrigin:]): Use createNSArray.
+
+        * WebCoreSupport/CorrectionPanel.mm:
+        (CorrectionPanel::show): Use createNSArray.
+
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::addMessageToConsole): Use @().
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (attributesForAttributedStringConversion): Use @().
+        (WebEditorClient::getGuessesForWord): Use makeVector<String>.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::actionDictionary const): Use @().
+        (kit): Deleted overload that takes Vector<String>.
+        (pluginView): Use @{}.
+        (WebFrameLoaderClient::createPlugin): Use createNSArray, @{}, and @().
+        (WebFrameLoaderClient::createJavaAppletWidget): Use createNSArray.
+
+        * WebCoreSupport/WebOpenPanelResultListener.mm:
+        (-[WebOpenPanelResultListener chooseFilenames:]): Use makeVector<String>.
+        (-[WebOpenPanelResultListener chooseFilename:displayString:iconImage:]): Use @[].
+        (-[WebOpenPanelResultListener chooseFilenames:displayString:iconImage:]): Use makeVector<String>.
+
+        * WebCoreSupport/WebSelectionServiceController.mm:
+        (WebSelectionServiceController::handleSelectionServiceClick):
+        Comment out an unused argument.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _rectsForRange:]): Use createNSArrray.
+        (-[WebFrame _computePageRectsWithPrintScaleFactor:pageSize:]): Use createNSArray and @[].
+        (-[WebFrame childFrames]): Use @[].
+
+        * WebView/WebHTMLView.mm:
+        (+[WebHTMLView _selectionPasteboardTypes]): Use @[].
+        (-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]): Use @[].
+        (-[WebHTMLView knowsPageRange:]): Use @[].
+        (-[WebHTMLView accessibilityAttributeValue:]): Use @[].
+        (-[WebHTMLView copyFont:]): Use @[].
+        (-[WebHTMLView _interpretKeyEvent:savingCommands:]): Use @[].
+        (-[WebHTMLView selectionTextRects]): Use createNSArray.
+        (-[WebHTMLView rectsForTextMatches]): Use createNSArray and @[].
+
+        * WebView/WebPDFRepresentation.mm: Removed unneeded include.
+        (+[WebPDFRepresentation postScriptMIMETypes]): Use @[].
+        (+[WebPDFRepresentation supportedMIMETypes]): Use @[].
+
+        * WebView/WebPDFView.mm:
+        (-[WebPDFView elementAtPoint:]): Use @{} and @().
+        (-[WebPDFView viewState]): Use @().
+        (-[WebPDFView selectionTextRects]): Use @[].
+        (-[WebPDFView pasteboardTypesForSelection]): Use @[].
+        (-[WebPDFView _menuItemsFromPDFKitForEvent:]): Use @().
+        (-[WebPDFView _openWithFinder:]): Use @{} and @().
+
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]): Use @().
+        (-[WebPreferences _setUnsignedIntValue:forKey:]): Use @().
+        (+[WebPreferences _setInitialDefaultTextEncodingToSystemEncoding]): Use @().
+        (-[WebPreferences setStorageBlockingPolicy:]): Use @{} and @().
+
+        * WebView/WebScriptDebugger.mm:
+        (WebScriptDebugger::sourceParsed): Use @().
+
+        * WebView/WebTextCompletionController.mm:
+        (-[WebTextCompletionController _placePopupWindow:]): Use @{}.
+
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]): Use makeVector<String>.
+        (-[WebView _contentsOfUserInterfaceItem:]): Use @().
+        (toStringVector): Deleted.
+        (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:injectedFrames:]):
+        Use makeVector<String>.
+        (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:injectedFrames:]):
+        Use makeVector<String>.
+        (-[WebView _elementAtWindowPoint:]): Use @{}.
+        (-[WebView pasteboardTypesForSelection]): Use @[].
+        (-[WebView pasteboardTypesForElement:]): Use @[].
+        (-[WebView rectsForTextMatches]): Use @[].
+        (-[WebView _searchWithGoogleFromMenu:]): Use @[].
+        (-[WebView _setFontWhitelist:]): Use makeVector<String>.
+
 2020-04-08  Daniel Bates  <dabates@apple.com>
 
         Track editable elements on screen
index 8b7ba5c..9e12896 100644 (file)
 #import <WebCore/RenderImage.h>
 #import <WebCore/RenderView.h>
 #import <WebCore/ScriptController.h>
+#import <WebCore/SimpleRange.h>
 #import <WebCore/TextIndicator.h>
 #import <WebCore/Touch.h>
 #import <WebCore/WebScriptObjectPrivate.h>
 #import <wtf/HashMap.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if PLATFORM(IOS_FAMILY)
 #import <WebCore/WAKAppKitStubs.h>
@@ -179,15 +181,6 @@ static Class elementClass(const QualifiedName& tag, Class defaultClass)
     return objcClass;
 }
 
-static NSArray *kit(const Vector<IntRect>& rects)
-{
-    size_t size = rects.size();
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:size];
-    for (size_t i = 0; i < size; ++i)
-        [array addObject:[NSValue valueWithRect:rects[i]]];
-    return array;
-}
-
 #if PLATFORM(IOS_FAMILY)
 
 static WKQuad wkQuadFromFloatQuad(const FloatQuad& inQuad)
@@ -514,7 +507,7 @@ id <DOMEventTarget> kit(EventTarget* target)
         return nil;
     Vector<WebCore::IntRect> rects;
     node.textRects(rects);
-    return kit(rects);
+    return createNSArray(rects).autorelease();
 }
 
 @end
@@ -631,12 +624,11 @@ id <DOMEventTarget> kit(EventTarget* target)
 
 - (NSArray *)textRects
 {
-    // FIXME: The call to updateLayoutIgnorePendingStylesheets should be moved into WebCore::Range.
     auto& range = *core(self);
     Vector<WebCore::IntRect> rects;
     range.ownerDocument().updateLayoutIgnorePendingStylesheets();
     range.absoluteTextRects(rects);
-    return kit(rects);
+    return createNSArray(rects).autorelease();
 }
 
 - (NSArray *)lineBoxRects
index b5030d0..c8be551 100644 (file)
@@ -48,7 +48,7 @@ static NO_RETURN void raiseDOMErrorException(WebCore::ExceptionCode ec)
     else
         reason = [[NSString alloc] initWithFormat:@"*** %@ %d", DOMException, description.legacyCode];
 
-    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:description.legacyCode], DOMException, nil];
+    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:@(description.legacyCode), DOMException, nil];
 
     NSException *exception = [NSException exceptionWithName:DOMException reason:reason userInfo:userInfo];
 
index 18f013a..8b994ed 100644 (file)
@@ -158,21 +158,21 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
 - (NSDictionary *)dictionaryRepresentation
 {
     BackForwardList *coreBFList = core(self);
-    
+
     auto& historyItems = coreBFList->entries();
     unsigned size = historyItems.size();
     NSMutableArray *entriesArray = [[NSMutableArray alloc] initWithCapacity:size];
     for (unsigned i = 0; i < size; ++i)
         [entriesArray addObject:[kit(const_cast<WebCore::HistoryItem*>(historyItems[i].ptr())) dictionaryRepresentationIncludingChildren:NO]];
-    
-    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
-        entriesArray, WebBackForwardListDictionaryEntriesKey,
-        [NSNumber numberWithUnsignedInt:coreBFList->current()], WebBackForwardListDictionaryCurrentKey,
-        [NSNumber numberWithInt:coreBFList->capacity()], WebBackForwardListDictionaryCapacityKey,
-        nil];
-        
+
+    NSDictionary *dictionary = @{
+        WebBackForwardListDictionaryEntriesKey: entriesArray,
+        WebBackForwardListDictionaryCurrentKey: @(coreBFList->current()),
+        WebBackForwardListDictionaryCapacityKey: @(coreBFList->capacity()),
+    };
+
     [entriesArray release];
-    
+
     return dictionary;
 }
 
index b8bc147..f27470d 100644 (file)
@@ -119,11 +119,10 @@ private:
 
 + (void)initialize
 {
-    [[NSUserDefaults standardUserDefaults] registerDefaults:
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            @"1000", @"WebKitHistoryItemLimit",
-            @"7", @"WebKitHistoryAgeInDaysLimit",
-            nil]];    
+    [[NSUserDefaults standardUserDefaults] registerDefaults:@{
+        @"WebKitHistoryItemLimit": @"1000",
+        @"WebKitHistoryAgeInDaysLimit": @"7",
+    }];
 }
 
 - (id)init
@@ -727,12 +726,11 @@ ALLOW_DEPRECATED_DECLARATIONS_END
 
 - (void)_sendNotification:(NSString *)name entries:(NSArray *)entries
 {
-    NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:entries, WebHistoryItemsKey, nil];
+    NSDictionary *userInfo = @{ WebHistoryItemsKey: entries };
 #if PLATFORM(IOS_FAMILY)
     WebThreadPostNotification(name, self, userInfo);
 #else    
-    [[NSNotificationCenter defaultCenter]
-        postNotificationName:name object:self userInfo:userInfo];
+    [[NSNotificationCenter defaultCenter] postNotificationName:name object:self userInfo:userInfo];
 #endif
 }
 
index a8d3bc2..dfacb37 100644 (file)
@@ -54,6 +54,7 @@
 #import <wtf/RunLoop.h>
 #import <wtf/StdLibExtras.h>
 #import <wtf/URL.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/WTFString.h>
 
 #if PLATFORM(IOS_FAMILY)
@@ -346,19 +347,8 @@ WebHistoryItem *kit(HistoryItem* item)
     if ([dict _webkit_boolForKey:lastVisitWasFailureKey])
         core(_private)->setLastVisitWasFailure(true);
     
-    if (NSArray *redirectURLs = [dict _webkit_arrayForKey:redirectURLsKey]) {
-        auto redirectURLsVector = makeUnique<Vector<String>>();
-        redirectURLsVector->reserveInitialCapacity([redirectURLs count]);
-
-        for (id redirectURL in redirectURLs) {
-            if (![redirectURL isKindOfClass:[NSString class]])
-                continue;
-
-            redirectURLsVector->uncheckedAppend((NSString *)redirectURL);
-        }
-
-        _private->_redirectURLs = WTFMove(redirectURLsVector);
-    }
+    if (NSArray *redirectURLs = [dict _webkit_arrayForKey:redirectURLsKey])
+        _private->_redirectURLs = makeUnique<Vector<String>>(makeVector<String>(redirectURLs));
 
     NSArray *childDicts = [dict objectForKey:childrenKey];
     if (childDicts) {
@@ -436,16 +426,9 @@ WebHistoryItem *kit(HistoryItem* item)
     }
     if (coreItem->lastVisitWasFailure())
         [dict setObject:@YES forKey:lastVisitWasFailureKey];
-    if (Vector<String>* redirectURLs = _private->_redirectURLs.get()) {
-        size_t size = redirectURLs->size();
-        ASSERT(size);
-        NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:size];
-        for (size_t i = 0; i < size; ++i)
-            [result addObject:(NSString *)redirectURLs->at(i)];
-        [dict setObject:result forKey:redirectURLsKey];
-        [result release];
-    }
-    
+    if (auto redirectURLs = _private->_redirectURLs.get())
+        [dict setObject:createNSArray(*redirectURLs).get() forKey:redirectURLsKey];
+
 #if PLATFORM(IOS_FAMILY)
     if (includesChildren && coreItem->children().size()) {
 #else
@@ -468,8 +451,8 @@ WebHistoryItem *kit(HistoryItem* item)
         [dict setObject:viewportArguments forKey:@"WebViewportArguments"];
 
     IntPoint scrollPosition = core(_private)->scrollPosition();
-    [dict setObject:[NSNumber numberWithInt:scrollPosition.x()] forKey:scrollPointXKey];
-    [dict setObject:[NSNumber numberWithInt:scrollPosition.y()] forKey:scrollPointYKey];
+    [dict setObject:@(scrollPosition.x()) forKey:scrollPointXKey];
+    [dict setObject:@(scrollPosition.y()) forKey:scrollPointYKey];
 #endif
 
     return dict;
index 17b98b8..c1fbd3e 100644 (file)
@@ -41,7 +41,7 @@
     static NSArray *cannedArray = nil;
 
     if (cannedArray == nil) {
-        cannedArray = [[NSArray arrayWithObject:WebURLsWithTitlesPboardType] retain];
+        cannedArray = [@[WebURLsWithTitlesPboardType] retain];
     }
 
     return cannedArray;
@@ -73,7 +73,7 @@
         [titlesOrEmptyStrings addObject:(titles == nil) ? @"" : [[titles objectAtIndex:index] _webkit_stringByTrimmingWhitespace]];
     }
 
-    [pasteboard setPropertyList:[NSArray arrayWithObjects:URLStrings, titlesOrEmptyStrings, nil]
+    [pasteboard setPropertyList:@[URLStrings, titlesOrEmptyStrings]
                         forType:WebURLsWithTitlesPboardType];
 }
 
index 5137e41..1513f4e 100644 (file)
@@ -71,50 +71,49 @@ class DefaultStorageSessionProvider : public WebCore::StorageSessionProvider {
 
 + (NSArray *)statistics
 {
-    WebCore::MemoryCache::Statistics s = WebCore::MemoryCache::singleton().getStatistics();
-
-    return [NSArray arrayWithObjects:
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.count], @"Images",
-            [NSNumber numberWithInt:s.cssStyleSheets.count], @"CSS",
+    auto s = WebCore::MemoryCache::singleton().getStatistics();
+    return @[
+        @{
+            @"Images": @(s.images.count),
+            @"CSS": @(s.cssStyleSheets.count),
 #if ENABLE(XSLT)
-            [NSNumber numberWithInt:s.xslStyleSheets.count], @"XSL",
+            @"XSL": @(s.xslStyleSheets.count),
 #else
-            [NSNumber numberWithInt:0], @"XSL",
+            @"XSL": @(0),
 #endif
-            [NSNumber numberWithInt:s.scripts.count], @"JavaScript",
-            nil],
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.size], @"Images",
-            [NSNumber numberWithInt:s.cssStyleSheets.size] ,@"CSS",
+            @"JavaScript": @(s.scripts.count),
+        },
+        @{
+            @"Images": @(s.images.size),
+            @"CSS": @(s.cssStyleSheets.size),
 #if ENABLE(XSLT)
-            [NSNumber numberWithInt:s.xslStyleSheets.size], @"XSL",
+            @"XSL": @(s.xslStyleSheets.size),
 #else
-            [NSNumber numberWithInt:0], @"XSL",
+            @"XSL": @(0),
 #endif
-            [NSNumber numberWithInt:s.scripts.size], @"JavaScript",
-            nil],
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.liveSize], @"Images",
-            [NSNumber numberWithInt:s.cssStyleSheets.liveSize] ,@"CSS",
+            @"JavaScript": @(s.scripts.size),
+        },
+        @{
+            @"Images": @(s.images.liveSize),
+            @"CSS": @(s.cssStyleSheets.liveSize),
 #if ENABLE(XSLT)
-            [NSNumber numberWithInt:s.xslStyleSheets.liveSize], @"XSL",
+            @"XSL": @(s.xslStyleSheets.liveSize),
 #else
-            [NSNumber numberWithInt:0], @"XSL",
+            @"XSL": @(0),
 #endif
-            [NSNumber numberWithInt:s.scripts.liveSize], @"JavaScript",
-            nil],
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.decodedSize], @"Images",
-            [NSNumber numberWithInt:s.cssStyleSheets.decodedSize] ,@"CSS",
+            @"JavaScript": @(s.scripts.liveSize),
+        },
+        @{
+            @"Images": @(s.images.decodedSize),
+            @"CSS": @(s.cssStyleSheets.decodedSize),
 #if ENABLE(XSLT)
-            [NSNumber numberWithInt:s.xslStyleSheets.decodedSize], @"XSL",
+            @"XSL": @(s.xslStyleSheets.decodedSize),
 #else
-            [NSNumber numberWithInt:0], @"XSL",
+            @"XSL": @(0),
 #endif
-            [NSNumber numberWithInt:s.scripts.decodedSize], @"JavaScript",
-            nil],
-        nil];
+            @"JavaScript": @(s.scripts.decodedSize),
+        },
+    ];
 }
 
 + (void)empty
index 4666653..4c4fec7 100644 (file)
@@ -199,22 +199,20 @@ using namespace WebCore;
 
 + (NSDictionary *)memoryStatistics
 {
-    WTF::FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();
-    
+    auto fastMallocStatistics = WTF::fastMallocStatistics();
     JSLockHolder lock(commonVM());
     size_t heapSize = commonVM().heap.size();
     size_t heapFree = commonVM().heap.capacity() - heapSize;
-    GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
-    
-    return [NSDictionary dictionaryWithObjectsAndKeys:
-                [NSNumber numberWithInt:fastMallocStatistics.reservedVMBytes], @"FastMallocReservedVMBytes",
-                [NSNumber numberWithInt:fastMallocStatistics.committedVMBytes], @"FastMallocCommittedVMBytes",
-                [NSNumber numberWithInt:fastMallocStatistics.freeListBytes], @"FastMallocFreeListBytes",
-                [NSNumber numberWithInt:heapSize], @"JavaScriptHeapSize",
-                [NSNumber numberWithInt:heapFree], @"JavaScriptFreeSize",
-                [NSNumber numberWithUnsignedInt:(unsigned int)globalMemoryStats.stackBytes], @"JavaScriptStackSize",
-                [NSNumber numberWithUnsignedInt:(unsigned int)globalMemoryStats.JITBytes], @"JavaScriptJITSize",
-            nil];
+    auto globalMemoryStats = globalMemoryStatistics();
+    return @{
+        @"FastMallocReservedVMBytes": @(fastMallocStatistics.reservedVMBytes),
+        @"FastMallocCommittedVMBytes": @(fastMallocStatistics.committedVMBytes),
+        @"FastMallocFreeListBytes": @(fastMallocStatistics.freeListBytes),
+        @"JavaScriptHeapSize": @(heapSize),
+        @"JavaScriptFreeSize": @(heapFree),
+        @"JavaScriptStackSize": @(globalMemoryStats.stackBytes),
+        @"JavaScriptJITSize": @(globalMemoryStats.JITBytes),
+    };
 }
 
 + (void)returnFreeMemoryToSystem
index c527837..6ac7533 100644 (file)
@@ -70,14 +70,13 @@ static NSMutableDictionary *descriptions = nil;
 - (instancetype)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL
 {
     // Insert a localized string here for those folks not savvy to our category methods.
-    NSDictionary *descriptionsDict = [descriptions objectForKey:domain];
-    NSString *localizedDescription = descriptionsDict ? [descriptionsDict objectForKey:[NSNumber numberWithInt:code]] : nil;
-    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+    NSString *localizedDescription = [[descriptions objectForKey:domain] objectForKey:@(code)];
+    NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
         URL, @"NSErrorFailingURLKey",
         [URL absoluteString], NSURLErrorFailingURLStringErrorKey,
         localizedDescription, NSLocalizedDescriptionKey,
         nil];
-    return [self initWithDomain:domain code:code userInfo:dict];
+    return [self initWithDomain:domain code:code userInfo:userInfo];
 }
 
 @end
@@ -91,21 +90,21 @@ static NSMutableDictionary *descriptions = nil;
         @autoreleasepool {
             NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
                 // Policy errors
-                WebKitErrorDescriptionCannotShowMIMEType,                   [NSNumber numberWithInt: WebKitErrorCannotShowMIMEType],
-                WebKitErrorDescriptionCannotShowURL,                        [NSNumber numberWithInt: WebKitErrorCannotShowURL],
-                WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange,   [NSNumber numberWithInt: WebKitErrorFrameLoadInterruptedByPolicyChange],
-                WebKitErrorDescriptionCannotUseRestrictedPort,              [NSNumber numberWithInt: WebKitErrorCannotUseRestrictedPort],
-                WebKitErrorDescriptionFrameLoadBlockedByContentFilter,      [NSNumber numberWithInt: WebKitErrorFrameLoadBlockedByContentFilter],
+                WebKitErrorDescriptionCannotShowMIMEType,                   @(WebKitErrorCannotShowMIMEType),
+                WebKitErrorDescriptionCannotShowURL,                        @(WebKitErrorCannotShowURL),
+                WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange,   @(WebKitErrorFrameLoadInterruptedByPolicyChange),
+                WebKitErrorDescriptionCannotUseRestrictedPort,              @(WebKitErrorCannotUseRestrictedPort),
+                WebKitErrorDescriptionFrameLoadBlockedByContentFilter,      @(WebKitErrorFrameLoadBlockedByContentFilter),
 
                 // Plug-in and java errors
-                WebKitErrorDescriptionCannotFindPlugin,                     [NSNumber numberWithInt: WebKitErrorCannotFindPlugIn],
-                WebKitErrorDescriptionCannotLoadPlugin,                     [NSNumber numberWithInt: WebKitErrorCannotLoadPlugIn],
-                WebKitErrorDescriptionJavaUnavailable,                      [NSNumber numberWithInt: WebKitErrorJavaUnavailable],
-                WebKitErrorDescriptionPlugInCancelledConnection,            [NSNumber numberWithInt: WebKitErrorPlugInCancelledConnection],
-                WebKitErrorDescriptionPlugInWillHandleLoad,                 [NSNumber numberWithInt: WebKitErrorPlugInWillHandleLoad],
+                WebKitErrorDescriptionCannotFindPlugin,                     @(WebKitErrorCannotFindPlugIn),
+                WebKitErrorDescriptionCannotLoadPlugin,                     @(WebKitErrorCannotLoadPlugIn),
+                WebKitErrorDescriptionJavaUnavailable,                      @(WebKitErrorJavaUnavailable),
+                WebKitErrorDescriptionPlugInCancelledConnection,            @(WebKitErrorPlugInCancelledConnection),
+                WebKitErrorDescriptionPlugInWillHandleLoad,                 @(WebKitErrorPlugInWillHandleLoad),
 
                 // Geolocation errors
-                WebKitErrorDescriptionGeolocationLocationUnknown,           [NSNumber numberWithInt: WebKitErrorGeolocationLocationUnknown],
+                WebKitErrorDescriptionGeolocationLocationUnknown,           @(WebKitErrorGeolocationLocationUnknown),
                 nil];
 
             [NSError _webkit_addErrorsWithCodesAndDescriptions:dict inDomain:WebKitErrorDomain];
@@ -139,7 +138,7 @@ static NSMutableDictionary *descriptions = nil;
     
     NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
     NSDictionary *descriptionsForWebKitErrorDomain = [descriptions objectForKey:WebKitErrorDomain];
-    NSString *localizedDescription = [descriptionsForWebKitErrorDomain objectForKey:[NSNumber numberWithInt:code]];
+    NSString *localizedDescription = [descriptionsForWebKitErrorDomain objectForKey:@(code)];
     if (localizedDescription)
         [userInfo setObject:localizedDescription forKey:NSLocalizedDescriptionKey];
     if (contentURL) {
index 6b0e896..7392f10 100644 (file)
@@ -99,7 +99,7 @@ static bool canUseFastRenderer(const UniChar* buffer, unsigned length)
         else
             point.y += [font descender];
 
-        [self drawAtPoint:point withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, textColor, NSForegroundColorAttributeName, nil]];
+        [self drawAtPoint:point withAttributes:@{ NSFontAttributeName: font, NSForegroundColorAttributeName: textColor }];
     }
 }
 
@@ -115,7 +115,7 @@ static bool canUseFastRenderer(const UniChar* buffer, unsigned length)
         return webCoreFont.width(run);
     }
 
-    return [self sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]].width;
+    return [self sizeWithAttributes:@{ NSFontAttributeName: font }].width;
 }
 
 #endif // PLATFORM(MAC)
index c5413e8..bbffade 100644 (file)
@@ -34,7 +34,6 @@
 #import <sys/stat.h>
 #import <wtf/Assertions.h>
 #import <wtf/FileSystem.h>
-#import <wtf/ObjCRuntimeExtras.h>
 
 @implementation NSFileManager (WebNSFileManagerExtras)
 
index bbb62cb..e1c5eeb 100644 (file)
@@ -106,7 +106,7 @@ static NSArray *_writableTypesForImageWithArchive (void)
 
 + (NSArray *)_web_dragTypesForURL
 {
-    return [NSArray arrayWithObjects:
+    return @[
         WebURLsWithTitlesPboardType,
         legacyURLPasteboardType(),
         WebURLPboardType,
@@ -114,7 +114,7 @@ static NSArray *_writableTypesForImageWithArchive (void)
         legacyStringPasteboardType(),
         legacyFilenamesPasteboardType(),
         legacyFilesPromisePasteboardType(),
-        nil];
+    ];
 }
 
 - (NSURL *)_web_bestURL
@@ -177,7 +177,7 @@ static NSArray *_writableTypesForImageWithArchive (void)
     if ([types containsObject:legacyStringPasteboardType()])
         [self setString:[URL _web_userVisibleString] forType:legacyStringPasteboardType()];
     if ([types containsObject:WebURLsWithTitlesPboardType])
-        [WebURLsWithTitles writeURLs:[NSArray arrayWithObject:URL] andTitles:[NSArray arrayWithObject:title] toPasteboard:self];
+        [WebURLsWithTitles writeURLs:@[URL] andTitles:@[title] toPasteboard:self];
 }
 
 + (int)_web_setFindPasteboardString:(NSString *)string withOwner:(id)owner
@@ -185,7 +185,7 @@ static NSArray *_writableTypesForImageWithArchive (void)
     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     NSPasteboard *findPasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
     ALLOW_DEPRECATED_DECLARATIONS_END
-    [findPasteboard declareTypes:[NSArray arrayWithObject:legacyStringPasteboardType()] owner:owner];
+    [findPasteboard declareTypes:@[legacyStringPasteboardType()] owner:owner];
     [findPasteboard setString:string forType:legacyStringPasteboardType()];
     return [findPasteboard changeCount];
 }
index c0e7fa9..7e9892f 100644 (file)
@@ -39,7 +39,6 @@
 #import <unicode/uchar.h>
 #import <unicode/uscript.h>
 #import <wtf/Assertions.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/URL.h>
 #import <wtf/cocoa/NSURLExtras.h>
 
index a04bc55..9561d22 100644 (file)
@@ -141,17 +141,14 @@ bool NetscapePluginHostManager::spawnPluginHost(const String& pluginPath, cpu_ty
     NSString *pluginHostAppPath = [[NSBundle bundleForClass:[WebNetscapePluginPackage class]] pathForAuxiliaryExecutable:pluginHostAppName];
     NSString *pluginHostAppExecutablePath = [[NSBundle bundleWithPath:pluginHostAppPath] executablePath];
 
-    NSDictionary *launchProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
-                                      pluginHostAppExecutablePath, @"pluginHostPath",
-                                      [NSNumber numberWithInt:pluginArchitecture], @"cpuType",
-                                      preferredBundleLocalizationName(), @"localization",
-                                      nil];
-
+    NSDictionary *launchProperties = @{
+        @"pluginHostPath": pluginHostAppExecutablePath,
+        @"cpuType": @(pluginArchitecture),
+        @"localization": preferredBundleLocalizationName(),
+    };
     NSData *data = [NSPropertyListSerialization dataWithPropertyList:launchProperties format:NSPropertyListBinaryFormat_v1_0 options:0 error:nullptr];
     ASSERT(data);
 
-    [launchProperties release];
-
     kern_return_t kr = _WKPASpawnPluginHost(m_pluginVendorPort, reinterpret_cast<uint8_t*>(const_cast<void*>([data bytes])), [data length], &pluginHostPort);
 
     if (kr == MACH_SEND_INVALID_DEST) {
index 3b29666..c64774d 100644 (file)
@@ -947,7 +947,7 @@ kern_return_t WKPCIdentifierInfo(mach_port_t clientPort, uint64_t serverIdentifi
         const char* str = identifier->string();
         info = [NSData dataWithBytesNoCopy:(void*)str length:strlen(str) freeWhenDone:NO];
     } else 
-        info = [NSNumber numberWithInt:identifier->number()];
+        info = @(identifier->number());
 
     NSData *data = [NSPropertyListSerialization dataWithPropertyList:info format:NSPropertyListBinaryFormat_v1_0 options:0 error:nullptr];
     ASSERT(data);
index dc62d55..a6145e0 100644 (file)
@@ -1322,28 +1322,28 @@ void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, JSGloba
     JSLockHolder lock(vm);
 
     if (value.isString()) {
-        [array addObject:[NSNumber numberWithInt:StringValueType]];
+        [array addObject:@(StringValueType)];
         [array addObject:asString(value)->value(lexicalGlobalObject)];
     } else if (value.isNumber()) {
-        [array addObject:[NSNumber numberWithInt:DoubleValueType]];
-        [array addObject:[NSNumber numberWithDouble:value.toNumber(lexicalGlobalObject)]];
+        [array addObject:@(DoubleValueType)];
+        [array addObject:@(value.toNumber(lexicalGlobalObject))];
     } else if (value.isBoolean()) {
-        [array addObject:[NSNumber numberWithInt:BoolValueType]];
+        [array addObject:@(BoolValueType)];
         [array addObject:[NSNumber numberWithBool:value.toBoolean(lexicalGlobalObject)]];
     } else if (value.isNull())
-        [array addObject:[NSNumber numberWithInt:NullValueType]];
+        [array addObject:@(NullValueType)];
     else if (value.isObject()) {
         JSObject* object = asObject(value);
         uint64_t objectID;
         if (getObjectID(this, object, objectID)) {
-            [array addObject:[NSNumber numberWithInt:NPObjectValueType]];
-            [array addObject:[NSNumber numberWithInt:objectID]];
+            [array addObject:@(NPObjectValueType)];
+            [array addObject:@(objectID)];
         } else {
-            [array addObject:[NSNumber numberWithInt:JSObjectValueType]];
-            [array addObject:[NSNumber numberWithInt:m_localObjects.idForObject(vm, object)]];
+            [array addObject:@(JSObjectValueType)];
+            [array addObject:@(m_localObjects.idForObject(vm, object))];
         }
     } else
-        [array addObject:[NSNumber numberWithInt:VoidValueType]];
+        [array addObject:@(VoidValueType)];
 }
 
 void NetscapePluginInstanceProxy::marshalValue(JSGlobalObject* lexicalGlobalObject, JSValue value, data_t& resultData, mach_msg_type_number_t& resultLength)
index 63801e1..0ac176c 100644 (file)
@@ -51,7 +51,6 @@
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <wtf/Assertions.h>
 #import <wtf/MainThread.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/RunLoop.h>
 
 using namespace WebCore;
index 71e4365..f6a7477 100644 (file)
@@ -40,7 +40,6 @@
 #import <mach-o/loader.h>
 #import <wtf/Assertions.h>
 #import <wtf/MainThread.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/RunLoop.h>
 #import <wtf/Vector.h>
 #import <wtf/text/CString.h>
index 291393b..740888f 100644 (file)
 
 - (NSDictionary *)_actionInformationWithURL:(NSURL *)URL
 {
-    return [NSDictionary dictionaryWithObjectsAndKeys:
-               [NSNumber numberWithInt:WebNavigationTypePlugInRequest], WebActionNavigationTypeKey,
-               [NSNumber numberWithInt:0], WebActionModifierFlagsKey,
-               URL, WebActionOriginalURLKey,
-               nil];
+    return @{
+        WebActionNavigationTypeKey: @(WebNavigationTypePlugInRequest),
+        WebActionModifierFlagsKey: @(0),
+        WebActionOriginalURLKey: URL,
+    };
 }
 
 - (void)_askPolicyDelegate
index 49de45d..093e697 100644 (file)
@@ -390,11 +390,11 @@ static NSArray *additionalWebPlugInPaths;
     // For example, if there is a QuickTime.plugin in the users's home directory
     // that is used instead of the /Library/Internet Plug-ins version.
     // The purpose is to allow non-admin users to update their plug-ins.
-    return [NSArray arrayWithObjects:
+    return @[
         [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Internet Plug-Ins"],
         @"/Library/Internet Plug-Ins",
         [[NSBundle mainBundle] builtInPlugInsPath],
-        nil];
+    ];
 #else
     // iOS plug-ins are all located in /System/Library/Internet Plug-Ins
 #if !PLATFORM(IOS_FAMILY_SIMULATOR)
@@ -406,7 +406,7 @@ static NSArray *additionalWebPlugInPaths;
     NSString* platformRootDir = [NSString stringWithUTF8String:WebKitPlatformSystemRootDirectory()];
     NSString *systemDir = [platformRootDir stringByAppendingPathComponent:@"System/Library"];
 #endif
-    return [NSArray arrayWithObject:[systemDir stringByAppendingPathComponent:@"Internet Plug-Ins"]];
+    return @[[systemDir stringByAppendingPathComponent:@"Internet Plug-Ins"]];
 #endif
 }
 
index 73e2331..e7275c7 100644 (file)
 #import "WebDatabaseManagerClient.h"
 #import "WebPlatformStrategies.h"
 #import "WebSecurityOriginInternal.h"
-
 #import <WebCore/DatabaseManager.h>
 #import <WebCore/DatabaseTracker.h>
 #import <WebCore/SecurityOrigin.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if ENABLE(INDEXED_DATABASE)
 #import "WebDatabaseProvider.h"
@@ -106,11 +106,7 @@ static NSString *databasesDirectoryPath();
 {
     if (!origin)
         return nil;
-    Vector<String> nameVector = DatabaseTracker::singleton().databaseNames([origin _core]->data());
-    NSMutableArray *names = [[NSMutableArray alloc] initWithCapacity:nameVector.size()];
-    for (auto& name : nameVector)
-        [names addObject:(NSString *)name];
-    return [names autorelease];
+    return createNSArray(DatabaseTracker::singleton().databaseNames([origin _core]->data())).autorelease();
 }
 
 - (NSDictionary *)detailsForDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin
index 895c4b2..08d64a2 100644 (file)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #import "CorrectionPanel.h"
 
 #import "WebViewInternal.h"
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if USE(AUTOCORRECTION_PANEL)
+
 using namespace WebCore;
 
 static inline NSCorrectionIndicatorType correctionIndicatorType(AlternativeTextType alternativeTextType)
@@ -69,15 +72,11 @@ void CorrectionPanel::show(WebView* view, AlternativeTextType type, const FloatR
     m_view = view;
     NSCorrectionIndicatorType indicatorType = correctionIndicatorType(type);
     
-    NSMutableArray* alternativeStrings = 0;
-    if (!alternativeReplacementStrings.isEmpty()) {
-        size_t size = alternativeReplacementStrings.size();
-        alternativeStrings = [NSMutableArray arrayWithCapacity:size];
-        for (size_t i = 0; i < size; ++i)
-            [alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]];
-    }
+    RetainPtr<NSArray> alternativeStrings;
+    if (!alternativeReplacementStrings.isEmpty())
+        alternativeStrings = createNSArray(alternativeReplacementStrings);
 
-    [[NSSpellChecker sharedSpellChecker] showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:[view _convertRectFromRootView:boundingBoxOfReplacedString] view:m_view.get() completionHandler:^(NSString* acceptedString) {
+    [[NSSpellChecker sharedSpellChecker] showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings.get() forStringInRect:[view _convertRectFromRootView:boundingBoxOfReplacedString] view:m_view.get() completionHandler:^(NSString* acceptedString) {
         handleAcceptedReplacement(acceptedString, replacedStringAsNSString, replacementStringAsNSString, indicatorType);
     }];
 }
index 66f1b41..6d68df7 100644 (file)
@@ -460,8 +460,8 @@ void WebChromeClient::addMessageToConsole(MessageSource source, MessageLevel lev
     NSString *messageSource = stringForMessageSource(source);
     NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
         (NSString *)message, @"message",
-        [NSNumber numberWithUnsignedInt:lineNumber], @"lineNumber",
-        [NSNumber numberWithUnsignedInt:columnNumber], @"columnNumber",
+        @(lineNumber), @"lineNumber",
+        @(columnNumber), @"columnNumber",
         (NSString *)sourceURL, @"sourceURL",
         messageSource, @"MessageSource",
         stringForMessageLevel(level), @"MessageLevel",
index 9ad46c6..8a753c5 100644 (file)
@@ -83,6 +83,7 @@
 #import <wtf/MainThread.h>
 #import <wtf/RefPtr.h>
 #import <wtf/RunLoop.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/WTFString.h>
 
 #if PLATFORM(IOS_FAMILY)
@@ -457,7 +458,7 @@ static NSDictionary *attributesForAttributedStringConversion()
     static NSString * const NSExcludedElementsDocumentAttribute = @"ExcludedElements";
 #endif
 
-    NSDictionary *dictionary = [NSDictionary dictionaryWithObject:excludedElements forKey:NSExcludedElementsDocumentAttribute];
+    NSDictionary *dictionary = @{ NSExcludedElementsDocumentAttribute: excludedElements };
 
     [excludedElements release];
 
@@ -1079,15 +1080,9 @@ void WebEditorClient::getGuessesForWord(const String& word, const String& contex
         [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:options inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:&orthography wordCount:0];
         language = [checker languageForWordRange:NSMakeRange(0, context.length()) inString:context orthography:orthography];
     }
-    NSArray* stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellCheckerDocumentTag()];
-    unsigned count = [stringsArray count];
-
-    if (count > 0) {
-        NSEnumerator *enumerator = [stringsArray objectEnumerator];
-        NSString *string;
-        while ((string = [enumerator nextObject]) != nil)
-            guesses.append(string);
-    }
+    NSArray *stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellCheckerDocumentTag()];
+    if (stringsArray.count)
+        guesses = makeVector<String>(stringsArray);
 }
 
 #endif // !PLATFORM(IOS_FAMILY)
index b05c3f9..b6a0263 100644 (file)
 #import <wtf/NakedPtr.h>
 #import <wtf/Ref.h>
 #import <wtf/RunLoop.h>
+#import <wtf/cocoa/VectorCocoa.h>
 #import <wtf/text/WTFString.h>
 
 #if USE(APPLE_INTERNAL_SDK)
@@ -1572,8 +1573,8 @@ NSDictionary *WebFrameLoaderClient::actionDictionary(const WebCore::NavigationAc
     NSURL *originalURL = action.url();
 
     NSMutableDictionary *result = [NSMutableDictionary dictionaryWithObjectsAndKeys:
-        [NSNumber numberWithInt:static_cast<int>(action.type())], WebActionNavigationTypeKey,
-        [NSNumber numberWithInt:modifierFlags], WebActionModifierFlagsKey,
+        @(static_cast<int>(action.type())), WebActionNavigationTypeKey,
+        @(modifierFlags), WebActionModifierFlagsKey,
         originalURL, WebActionOriginalURLKey,
         nil];
 
@@ -1585,9 +1586,9 @@ NSDictionary *WebFrameLoaderClient::actionDictionary(const WebCore::NavigationAc
         [element release];
 
         if (mouseEventData->isTrusted)
-            [result setObject:[NSNumber numberWithInt:mouseEventData->button] forKey:WebActionButtonKey];
+            [result setObject:@(mouseEventData->button) forKey:WebActionButtonKey];
         else
-            [result setObject:[NSNumber numberWithInt:WebCore::NoButton] forKey:WebActionButtonKey];
+            [result setObject:@(WebCore::NoButton) forKey:WebActionButtonKey];
     }
 
     if (formState)
@@ -1694,15 +1695,6 @@ WebCore::ObjectContentType WebFrameLoaderClient::objectContentType(const URL& ur
     return WebCore::ObjectContentType::None;
 }
 
-static NSMutableArray* kit(const Vector<String>& vector)
-{
-    unsigned len = vector.size();
-    NSMutableArray* array = [NSMutableArray arrayWithCapacity:len];
-    for (unsigned x = 0; x < len; x++)
-        [array addObject:vector[x]];
-    return array;
-}
-
 static String parameterValue(const Vector<String>& paramNames, const Vector<String>& paramValues, const char* name)
 {
     size_t size = paramNames.size();
@@ -1720,37 +1712,39 @@ static NSView *pluginView(WebFrame *frame, WebPluginPackage *pluginPackage,
 {
     WebHTMLView *docView = (WebHTMLView *)[[frame frameView] documentView];
     ASSERT([docView isKindOfClass:[WebHTMLView class]]);
-        
+
     WebPluginController *pluginController = [docView _pluginController];
-    
+
     // Store attributes in a dictionary so they can be passed to WebPlugins.
     NSMutableDictionary *attributes = [[NSMutableDictionary alloc] initWithObjects:attributeValues forKeys:attributeNames];
-    
+
     [pluginPackage load];
     Class viewFactory = [pluginPackage viewFactory];
     
     NSView *view = nil;
     NSDictionary *arguments = nil;
-    
-    if ([viewFactory respondsToSelector:@selector(plugInViewWithArguments:)]) {
-        arguments = [NSDictionary dictionaryWithObjectsAndKeys:
-            baseURL, WebPlugInBaseURLKey,
-            attributes, WebPlugInAttributesKey,
-            pluginController, WebPlugInContainerKey,
-            [NSNumber numberWithInt:loadManually ? WebPlugInModeFull : WebPlugInModeEmbed], WebPlugInModeKey,
-            [NSNumber numberWithBool:!loadManually], WebPlugInShouldLoadMainResourceKey,
-            element, WebPlugInContainingElementKey,
-            nil];
-        LOG(Plugins, "arguments:\n%@", arguments);
+
 IGNORE_WARNINGS_BEGIN("undeclared-selector")
-    } else if ([viewFactory respondsToSelector:@selector(pluginViewWithArguments:)]) {
+    auto oldSelector = @selector(pluginViewWithArguments:);
 IGNORE_WARNINGS_END
-        arguments = [NSDictionary dictionaryWithObjectsAndKeys:
-            baseURL, WebPluginBaseURLKey,
-            attributes, WebPluginAttributesKey,
-            pluginController, WebPluginContainerKey,
-            element, WebPlugInContainingElementKey,
-            nil];
+
+    if ([viewFactory respondsToSelector:@selector(plugInViewWithArguments:)]) {
+        arguments = @{
+            WebPlugInBaseURLKey: baseURL,
+            WebPlugInAttributesKey: attributes,
+            WebPlugInContainerKey: pluginController,
+            WebPlugInModeKey: @(loadManually ? WebPlugInModeFull : WebPlugInModeEmbed),
+            WebPlugInShouldLoadMainResourceKey: [NSNumber numberWithBool:!loadManually],
+            WebPlugInContainingElementKey: element,
+        };
+        LOG(Plugins, "arguments:\n%@", arguments);
+    } else if ([viewFactory respondsToSelector:oldSelector]) {
+        arguments = @{
+            WebPluginBaseURLKey: baseURL,
+            WebPluginAttributesKey: attributes,
+            WebPluginContainerKey: pluginController,
+            WebPlugInContainingElementKey: element,
+        };
         LOG(Plugins, "arguments:\n%@", arguments);
     }
 
@@ -1919,15 +1913,15 @@ RefPtr<WebCore::Widget> WebFrameLoaderClient::createPlugin(const WebCore::IntSiz
     auto* document = core(m_webFrame.get())->document();
     NSURL *baseURL = document->baseURL();
     NSURL *pluginURL = url;
-    NSMutableArray *attributeKeys = kit(paramNames);
+    auto attributeKeys = createNSArray(paramNames);
 
-#if !PLATFORM(IOS_FAMILY)
+#if PLATFORM(MAC)
     SEL selector = @selector(webView:plugInViewWithArguments:);
     if ([[webView UIDelegate] respondsToSelector:selector]) {
-        NSMutableDictionary *attributes = [[NSMutableDictionary alloc] initWithObjects:kit(paramValues) forKeys:attributeKeys];
+        NSDictionary *attributes = @{ attributeKeys.get(): createNSArray(paramValues).get() };
         NSDictionary *arguments = [[NSDictionary alloc] initWithObjectsAndKeys:
             attributes, WebPlugInAttributesKey,
-            [NSNumber numberWithInt:loadManually ? WebPlugInModeFull : WebPlugInModeEmbed], WebPlugInModeKey,
+            @(loadManually ? WebPlugInModeFull : WebPlugInModeEmbed), WebPlugInModeKey,
             [NSNumber numberWithBool:!loadManually], WebPlugInShouldLoadMainResourceKey,
             kit(&element), WebPlugInContainingElementKey,
             // FIXME: We should be passing base URL, see <https://bugs.webkit.org/show_bug.cgi?id=35215>.
@@ -1936,11 +1930,10 @@ RefPtr<WebCore::Widget> WebFrameLoaderClient::createPlugin(const WebCore::IntSiz
 
         NSView *view = CallUIDelegate(webView, selector, arguments);
 
-        [attributes release];
         [arguments release];
 
         if (view)
-            return adoptRef(new PluginWidget(view));
+            return adoptRef(*new PluginWidget(view));
     }
 #endif
 
@@ -1953,7 +1946,7 @@ RefPtr<WebCore::Widget> WebFrameLoaderClient::createPlugin(const WebCore::IntSiz
         MIMEType = mimeType;
         pluginPackage = [webView _pluginForMIMEType:mimeType];
     }
-    
+
     NSString *extension = [[pluginURL path] pathExtension];
 
 #if PLATFORM(IOS_FAMILY)
@@ -1979,7 +1972,7 @@ RefPtr<WebCore::Widget> WebFrameLoaderClient::createPlugin(const WebCore::IntSiz
                 downcast<WebCore::RenderEmbeddedObject>(*element.renderer()).setPluginUnavailabilityReason(WebCore::RenderEmbeddedObject::InsecurePluginVersion);
         } else {
             if ([pluginPackage isKindOfClass:[WebPluginPackage class]])
-                view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, attributeKeys, kit(paramValues), baseURL, kit(&element), loadManually);
+                view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, attributeKeys.get(), createNSArray(paramValues).get(), baseURL, kit(&element), loadManually);
 #if ENABLE(NETSCAPE_PLUGIN_API)
             else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) {
                 WebBaseNetscapePluginView *pluginView = [[[NETSCAPE_PLUGIN_VIEW alloc]
@@ -1988,8 +1981,8 @@ RefPtr<WebCore::Widget> WebFrameLoaderClient::createPlugin(const WebCore::IntSiz
                     URL:pluginURL
                     baseURL:baseURL
                     MIMEType:MIMEType
-                    attributeKeys:attributeKeys
-                    attributeValues:kit(paramValues)
+                    attributeKeys:attributeKeys.get()
+                    attributeValues:createNSArray(paramValues).get()
                     loadManually:loadManually
                     element:&element] autorelease];
 
@@ -2083,8 +2076,8 @@ RefPtr<WebCore::Widget> WebFrameLoaderClient::createJavaAppletWidget(const WebCo
                     URL:nil
                     baseURL:baseURL
                     MIMEType:MIMEType
-                    attributeKeys:kit(paramNames)
-                    attributeValues:kit(paramValues)
+                    attributeKeys:createNSArray(paramNames).get()
+                    attributeValues:createNSArray(paramValues).get()
                     loadManually:NO
                     element:&element] autorelease];
                 if (view)
index 55fb2bd..aaa4afb 100644 (file)
@@ -27,6 +27,7 @@
 
 #import <WebCore/FileChooser.h>
 #import <wtf/RefPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if PLATFORM(IOS_FAMILY)
 #import <WebCore/Icon.h>
@@ -64,11 +65,7 @@ using namespace WebCore;
     ASSERT(_chooser);
     if (!_chooser)
         return;
-    NSUInteger count = [filenames count];
-    Vector<String> names(count);
-    for (NSUInteger i = 0; i < count; i++)
-        names[i] = [filenames objectAtIndex:i];
-    _chooser->chooseFiles(names);
+    _chooser->chooseFiles(makeVector<String>(filenames));
     _chooser = nullptr;
 }
 
@@ -76,7 +73,7 @@ using namespace WebCore;
 
 - (void)chooseFilename:(NSString *)filename displayString:(NSString *)displayString iconImage:(CGImageRef)imageRef
 {
-    [self chooseFilenames:[NSArray arrayWithObject:filename] displayString:displayString iconImage:imageRef];
+    [self chooseFilenames:@[filename] displayString:displayString iconImage:imageRef];
 }
 
 - (void)chooseFilenames:(NSArray *)filenames displayString:(NSString *)displayString iconImage:(CGImageRef)imageRef
@@ -85,11 +82,7 @@ using namespace WebCore;
     if (!_chooser)
         return;
 
-    Vector<String> names;
-    names.reserveInitialCapacity([filenames count]);
-    for (NSString *filename in filenames)
-        names.uncheckedAppend(filename);
-    _chooser->chooseMediaFiles(names, displayString, Icon::createIconForImage(imageRef).get());
+    _chooser->chooseMediaFiles(makeVector<String>(filenames), displayString, Icon::createIconForImage(imageRef).get());
     _chooser = nullptr;
 }
 
index 9343757..93bed69 100644 (file)
@@ -40,7 +40,7 @@ WebSelectionServiceController::WebSelectionServiceController(WebView *webView)
 {
 }
 
-void WebSelectionServiceController::handleSelectionServiceClick(WebCore::FrameSelection& selection, const Vector<String>& telephoneNumbers, const WebCore::IntPoint& point)
+void WebSelectionServiceController::handleSelectionServiceClick(WebCore::FrameSelection& selection, const Vector<String>& /*telephoneNumbers*/, const WebCore::IntPoint& point)
 {
     Page* page = [m_webView page];
     if (!page)
index bd9a678..2abbd92 100644 (file)
 #import <WebCore/VisibleUnits.h>
 #import <WebCore/markup.h>
 #import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if PLATFORM(IOS_FAMILY)
 #import "WebMailDelegate.h"
@@ -1091,6 +1092,7 @@ static WebFrameLoadType toWebFrameLoadType(WebCore::FrameLoadType frameLoadType)
 }
 
 #if PLATFORM(IOS_FAMILY)
+
 - (BOOL)needsLayout
 {
     // Needed for Mail <rdar://problem/6228038>
@@ -1107,39 +1109,26 @@ static WebFrameLoadType toWebFrameLoadType(WebCore::FrameLoadType frameLoadType)
     return _private->coreFrame->loader().loadsSynchronously();
 }
 
-// FIXME: selection
-
 - (NSArray *)_rectsForRange:(DOMRange *)domRange
 {
     auto* range = core(domRange);
-    
+    if (!range)
+        return @[];
     Vector<WebCore::IntRect> intRects;
     range->absoluteTextRects(intRects, NO);
-    unsigned size = intRects.size();
-    
-    NSMutableArray *rectArray = [NSMutableArray arrayWithCapacity:size];
-    for (unsigned i = 0; i < size; i++) {
-        [rectArray addObject:[NSValue valueWithRect:(CGRect )intRects[i]]];
-    }
-    
-    return rectArray;
+    return createNSArray(intRects).autorelease();
 }
 
 - (DOMRange *)_selectionRangeForFirstPoint:(CGPoint)first secondPoint:(CGPoint)second
 {
-    WebCore::VisiblePosition firstPos = [self _visiblePositionForPoint:first];
-    WebCore::VisiblePosition secondPos = [self _visiblePositionForPoint:second];
-    WebCore::VisibleSelection selection(firstPos, secondPos);
-    DOMRange *range = kit(selection.toNormalizedRange().get());
-    return range;    
+    auto firstPosition = [self _visiblePositionForPoint:first];
+    auto secondPosition = [self _visiblePositionForPoint:second];
+    return kit(WebCore::VisibleSelection(firstPosition, secondPosition).toNormalizedRange().get());
 }
 
 - (DOMRange *)_selectionRangeForPoint:(CGPoint)point
 {
-    WebCore::VisiblePosition pos = [self _visiblePositionForPoint:point];
-    WebCore::VisibleSelection selection(pos);
-    DOMRange *range = kit(selection.toNormalizedRange().get());
-    return range;
+    return kit(WebCore::VisibleSelection([self _visiblePositionForPoint:point]).toNormalizedRange().get());
 }
 
 #endif // PLATFORM(IOS_FAMILY)
@@ -2271,21 +2260,21 @@ static WebFrameLoadType toWebFrameLoadType(WebCore::FrameLoadType frameLoadType)
 {
     if (printScaleFactor <= 0) {
         LOG_ERROR("printScaleFactor has bad value %.2f", printScaleFactor);
-        return [NSArray array];
+        return @[];
     }
 
     if (!_private->coreFrame)
-        return [NSArray array];
+        return @[];
     if (!_private->coreFrame->document())
-        return [NSArray array];
+        return @[];
     if (!_private->coreFrame->view())
-        return [NSArray array];
+        return @[];
     if (!_private->coreFrame->view()->documentView())
-        return [NSArray array];
+        return @[];
 
     auto* root = _private->coreFrame->document()->renderView();
     if (!root)
-        return [NSArray array];
+        return @[];
 
     const auto& documentRect = root->documentRect();
     float printWidth = root->style().isHorizontalWritingMode() ? static_cast<float>(documentRect.width()) / printScaleFactor : pageSize.width;
@@ -2293,13 +2282,7 @@ static WebFrameLoadType toWebFrameLoadType(WebCore::FrameLoadType frameLoadType)
 
     WebCore::PrintContext printContext(_private->coreFrame);
     printContext.computePageRectsWithPageSize(WebCore::FloatSize(printWidth, printHeight), true);
-    const Vector<WebCore::IntRect>& pageRects = printContext.pageRects();
-
-    size_t size = pageRects.size();
-    NSMutableArray *pages = [NSMutableArray arrayWithCapacity:size];
-    for (size_t i = 0; i < size; ++i)
-        [pages addObject:[NSValue valueWithRect:NSRect(pageRects[i])]];
-    return pages;
+    return createNSArray(printContext.pageRects()).autorelease();
 }
 
 #if PLATFORM(IOS_FAMILY)
@@ -2623,7 +2606,7 @@ static NSURL *createUniqueWebDataURL()
 {
     auto coreFrame = _private->coreFrame;
     if (!coreFrame)
-        return [NSArray array];
+        return @[];
     NSMutableArray *children = [NSMutableArray arrayWithCapacity:coreFrame->tree().childCount()];
     for (WebCore::Frame* child = coreFrame->tree().firstChild(); child; child = child->tree().nextSibling())
         [children addObject:kit(child)];
index 5ba2e78..c9155b1 100644 (file)
 #import <wtf/RunLoop.h>
 #import <wtf/SystemTracing.h>
 #import <wtf/WeakObjCPtr.h>
+#import <wtf/cocoa/VectorCocoa.h>
 
 #if PLATFORM(MAC)
 #import "WebNSEventExtras.h"
@@ -1995,7 +1996,7 @@ static bool mouseEventIsPartOfClickOrDrag(NSEvent *event)
 + (NSArray *)_selectionPasteboardTypes
 {
     // FIXME: We should put data for NSHTMLPboardType on the pasteboard but Microsoft Excel doesn't like our format of HTML (3640423).
-    return [NSArray arrayWithObjects:WebArchivePboardType, WebCore::legacyRTFDPasteboardType(), WebCore::legacyRTFPasteboardType(), WebCore::legacyStringPasteboardType(), nil];
+    return @[WebArchivePboardType, WebCore::legacyRTFDPasteboardType(), WebCore::legacyRTFPasteboardType(), WebCore::legacyStringPasteboardType()];
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
@@ -4404,7 +4405,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     if (draggingElementURL)
         [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingElementURL absoluteString] referrer:nil atPath:path];
     
-    return [NSArray arrayWithObject:[path lastPathComponent]];
+    return @[[path lastPathComponent]];
 }
 
 // MARK: NSDraggingSource
@@ -4881,7 +4882,7 @@ static RefPtr<WebCore::KeyboardEvent> currentKeyboardEvent(WebCore::Frame* coreF
     // a blank page (with correct-looking header and footer if that option is on), which matches
     // the behavior of IE and Camino at least.
     if ([newPageRects count] == 0)
-        newPageRects = [NSArray arrayWithObject:[NSValue valueWithRect:NSMakeRect(0, 0, 1, 1)]];
+        newPageRects = @[[NSValue valueWithRect:NSMakeRect(0, 0, 1, 1)]];
 
     _private->pageRects = newPageRects;
 
@@ -5019,7 +5020,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     if ([attributeName isEqualToString: NSAccessibilityChildrenAttribute]) {
         id accTree = [[self _frame] accessibilityRoot];
         if (accTree)
-            return [NSArray arrayWithObject:accTree];
+            return @[accTree];
         return nil;
     }
     return [super accessibilityAttributeValue:attributeName];
@@ -5292,7 +5293,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     NSPasteboard *fontPasteboard = [NSPasteboard pasteboardWithName:NSFontPboard];
     ALLOW_DEPRECATED_DECLARATIONS_END
-    [fontPasteboard declareTypes:[NSArray arrayWithObject:WebCore::legacyFontPasteboardType()] owner:nil];
+    [fontPasteboard declareTypes:@[WebCore::legacyFontPasteboardType()] owner:nil];
     [fontPasteboard setData:[self _selectionStartFontAttributesAsRTF] forType:WebCore::legacyFontPasteboardType()];
 }
 
@@ -6023,7 +6024,7 @@ static BOOL writingDirectionKeyBindingsEnabled()
         // execute the calls immediately. DOM events like keydown are tweaked to have keyCode of 229, and canceling them has no effect.
         // Unfortunately, there is no real difference between plain text input and IM processing - for example, AppKit queries hasMarkedText
         // when typing with U.S. keyboard, and inserts marked text for dead keys.
-        [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]];
+        [self interpretKeyEvents:@[macEvent]];
     } else {
         // Are there commands that could just cause text insertion if executed via Editor?
         // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore
@@ -6834,18 +6835,10 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     if (![self _hasSelection])
         return nil;
 
-    Vector<WebCore::FloatRect> list;
+    Vector<WebCore::FloatRect> rects;
     if (auto* coreFrame = core([self _frame]))
-        coreFrame->selection().getClippedVisibleTextRectangles(list);
-
-    size_t size = list.size();
-
-    NSMutableArray *result = [NSMutableArray arrayWithCapacity:size];
-
-    for (size_t i = 0; i < size; ++i)
-        [result addObject:[NSValue valueWithRect:list[i]]];
-
-    return result;
+        coreFrame->selection().getClippedVisibleTextRectangles(rects);
+    return createNSArray(rects).autorelease();
 }
 
 - (NSView *)selectionView
@@ -7131,17 +7124,12 @@ static CGImageRef selectionImage(WebCore::Frame* frame, bool forceBlackText)
 {
     auto* coreFrame = core([self _frame]);
     if (!coreFrame)
-        return [NSArray array];
+        return @[];
     auto* document = coreFrame->document();
     if (!document)
-        return [NSArray array];
+        return @[];
 
-    Vector<WebCore::FloatRect> rects = document->markers().renderedRectsForMarkers(WebCore::DocumentMarker::TextMatch);
-    unsigned count = rects.size();
-    NSMutableArray *result = [NSMutableArray arrayWithCapacity:count];
-    for (unsigned index = 0; index < count; ++index)
-        [result addObject:[NSValue valueWithRect:rects[index]]];    
-    return result;
+    return createNSArray(document->markers().renderedRectsForMarkers(WebCore::DocumentMarker::TextMatch)).autorelease();
 }
 
 - (BOOL)_findString:(NSString *)string options:(WebFindOptions)options
index e4d0642..ebca3b0 100644 (file)
 #import <JavaScriptCore/JSContextRef.h>
 #import <JavaScriptCore/OpaqueJSString.h>
 #import <wtf/Assertions.h>
-#import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/RetainPtr.h>
 
 @implementation WebPDFRepresentation
 
 + (NSArray *)postScriptMIMETypes
 {
-    return [NSArray arrayWithObjects:
+    return @[
         @"application/postscript",
-        nil];
+    ];
 }
 
 + (NSArray *)supportedMIMETypes
 {
     return [[[self class] postScriptMIMETypes] arrayByAddingObjectsFromArray:
-        [NSArray arrayWithObjects:
+        @[
             @"text/pdf",
             @"application/pdf",
-            nil]];
+        ]
+    ];
 }
 
 + (Class)PDFDocumentClass
index ec7befc..710c97b 100644 (file)
@@ -590,13 +590,10 @@ static BOOL _PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selec
 
 - (NSDictionary *)elementAtPoint:(NSPoint)point
 {
-    WebFrame *frame = [dataSource webFrame];
-    ASSERT(frame);
-    
-    return [NSDictionary dictionaryWithObjectsAndKeys:
-        frame, WebElementFrameKey, 
-        [NSNumber numberWithBool:[self _pointIsInSelection:point]], WebElementIsSelectedKey,
-        nil];
+    return @{
+        WebElementFrameKey: [dataSource webFrame],
+        WebElementIsSelectedKey: @([self _pointIsInSelection:point]),
+    };
 }
 
 - (NSDictionary *)elementAtPoint:(NSPoint)point allowShadowContent:(BOOL)allow