[Cocoa] Update more WebCore Objective-C code to be ARC compatible
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jul 2018 21:45:43 +0000 (21:45 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jul 2018 21:45:43 +0000 (21:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188140

Reviewed by Sam Weinig.

Source/WebCore:

This make sure we don't put any Objective-C objects into HashMap/Set
data structures, which doesn't work under ARC at this time. We could
fix that some day, but it's pretty simple to change code not to rely
on it, for now, and not as simple to support it in HashMap/Set.

* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(-[WebAccessibilityObjectWrapperBase updateObjectBackingStore]):
Use CFRetain/CFAutorelease instead of retain/autorelease.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(createAccessibilityRoleMap): Use CFStringRef in a HashMap rather than
NSString * for string constants.
(roleValueToNSString): Updated for above change.

* bridge/objc/WebScriptObject.mm:
(-[WebScriptObject stringRepresentation]): Updated since objectValue
is now CFTypeRef rather than NSObject *.

* bridge/objc/objc_instance.mm:
(ObjcInstance::create): Use CFTypeRef instead of id for the key types
in a HashMap.
(ObjcInstance::~ObjcInstance): Updated for the above change.
(ObjcInstance::invokeObjcMethod): Updated since objectValue is now
CFTypeRef.
(ObjcInstance::invokeDefaultMethod): Ditto.
(ObjcInstance::setValueOfUndefinedField): Ditto.
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcArray::setValueAt const): Ditto.

* bridge/objc/objc_utility.h: Use #pragma once. Use CFTypeRef instead
of NSObject * for objectValue, since it's in a union and ARC does not
support strong Objective-C object pointers in a union.

* bridge/objc/objc_utility.mm:
(JSC::Bindings::convertValueToObjcValue): Updated since objectValue is
now CFTypeRef.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_processElement): Use CFTypeRef rather than NSTextTable
for a HashMap.
(HTMLConverter::_exitElement): Ditto.

* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::attributesForAttributedStringConversion): Use CFRetain rather
than -[NSObject retain] in a workaround for an overrelease.

* editing/mac/DictionaryLookup.h: Removed code to make this usable from
non-Objective-C source files. Use tuples rather than out arguments
for the results of the various functions.

* editing/mac/DictionaryLookup.mm:
(WebCore::DictionaryLookup::rangeForSelection): Return a tuple rather
than using an out argument for options.
(WebCore::DictionaryLookup::rangeAtHitTestResult): Ditto.
(WebCore::DictionaryLookup::stringForPDFSelection): Ditto.
(WebCore::showPopupOrCreateAnimationController): Removed use of typedef
PlatformAnimationController.
(WebCore::DictionaryLookup::animationControllerForPopup): Ditto.

* html/HTMLMediaElement.h: Put the videoFullscreenLayer function inside
an __OBJC__ ifdef since we can't do the type conversion without the
full Objective-C type.

* page/mac/EventHandlerMac.mm:
(WebCore::selfRetainingNSScrollViewScrollWheel): Use CFRetain/CFRelease
instead of retain/release.
(WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):
Updated to use tuple return value from DictionaryLookup.

* page/scrolling/ScrollingStateNode.h: Replaced direct use of PlatformLayer*
in a union with use of a "typless" void* pointer and added helper functions
to convert in both directions.
* page/scrolling/cocoa/ScrollingStateNode.mm:
(WebCore::LayerRepresentation::retainPlatformLayer): Use CFRetain instead
of retain.
(WebCore::LayerRepresentation::releasePlatformLayer): Use CFRelease instead
of release.
(WebCore::LayerRepresentation::makePlatformLayerTyped): Added.
(WebCore::LayerRepresentation::makePlatformLayerTypeless): Ditto.
* page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp:
(WebCore::LayerRepresentation::retainPlatformLayer): Updated argument type.
(WebCore::LayerRepresentation::releasePlatformLayer): Ditto.
(WebCore::LayerRepresentation::makePlatformLayerTyped): Added.
(WebCore::LayerRepresentation::makePlatformLayerTypeless): Ditto.

* platform/gamepad/cocoa/GameControllerGamepadProvider.h: Use CFTypeRef
instad of GCController * for key type of HashMap.
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
(WebCore::GameControllerGamepadProvider::controllerDidConnect): Updated
for the above change.
(WebCore::GameControllerGamepadProvider::controllerDidDisconnect): Ditto.

* platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm:
Use SOFT_LINK_CONSTANT_MAY_FAIL instead of SOFT_LINK_POINTER_OPTIONAL for
strings, since SOFT_LINK_POINTER_OPTIONAL does not work for Objective-C
types under ARC.
(WebCore::AVTrackPrivateAVFObjCImpl::audioKind const): Added checks
for the constants.
(WebCore::AVTrackPrivateAVFObjCImpl::videoKind const): Ditto.
(WebCore::AVTrackPrivateAVFObjCImpl::label const): Ditto.

* platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h:
Use #pragma once and use CFTypeRef instead of AVMediaSelectionOption *
in the key to a HashMap.
* platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
(WebCore::MediaSelectionGroupAVFObjC::updateOptions): Updated for
the above change.

* platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
Use SOFT_LINK_CONSTANT_MAY_FAIL instead of SOFT_LINK_POINTER_OPTIONAL for
strings, since SOFT_LINK_POINTER_OPTIONAL does not work for Objective-C
types under ARC.
(WebCore::customSchemeURL): Removed unnecessary use of
NeverDestroyed<RetainPtr>. Can just use a straight pointer without calling
release, and that works with or without ARC.
(WebCore::imageDecoderAssetOptions): Ditto. Here, had to add a retain,
which we'll remove when we turn on ARC. Added canLoad checks, needed
because of SOFT_LINK_CONSTANT_MAY_FAIL.
(WebCore::ImageDecoderAVFObjC::firstEnabledTrack): Added canLoad check,
needed because of SOFT_LINK_CONSTANT_MAY_FAIL.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
Use CFTypeRef instead of AVAssetResourceLoadingRequest in HashMap.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
Updated for above.
(WebCore::MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest): Ditto.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
Use CFTypeRef instead of AVSampleBufferAudioRenderer in HashMap.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVolume): Updated for above.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setMuted): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableAudioSample): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeAudioRenderer): Ditto.

* platform/graphics/metal/GPUDrawableMetal.mm: Updated include; under ARC, it's
not safe to call a method on a class without seeing its interface.

* platform/mac/VideoFullscreenInterfaceMac.mm: Added an explicit
__unsafe_unretained for a delegate. Could consider moving to weak, but for now
this preserves the current behavior and compiles under ARC.

* platform/mac/WebCoreFullScreenPlaceholderView.h: Use strong for the contents,
weak for the target, and changed the action to be hard-coded instead of an
arbitrary selector. If we find we need the flexibility again later, we can do
it with a block, which is more ARC-friendly than calling an arbitrary selector.
* platform/mac/WebCoreFullScreenPlaceholderView.mm:
(-[WebCoreFullScreenPlaceholderView initWithFrame:]): Call function directly
instead of taking advantage of "using".
(-[WebCoreFullScreenPlaceholderView mouseDown:]): Call cancelOperation: on the
target rather than performing an arbitrary selector.

* platform/mac/WebCoreObjCExtras.mm:
(WebCoreObjCScheduleDeallocateOnMainThread): Use sel_registerName instead of
@selector, since @selector is not supported under ARC.

* platform/network/ResourceHandle.h: Use a return value rather than using an
inout argument in applySniffingPoliciesAndStoragePartitionIfNeeded.

* platform/network/cocoa/CookieStorageObserver.mm:
(WebCore::CookieStorageObserver::startObserving): Removed unnecessary
assertion of repondsToSelector since we are about to dispatch it immediately
after. Call the selector in the conventional way instead of using performSelector.

* platform/network/cocoa/WebCoreNSURLSession.h: Use #pragma once and use
CFTypeRef instead of an Objective-C type. Also use an explicit __unsafe_unretained
for the session in the data task.
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSession dealloc]): Updated for the above.
(-[WebCoreNSURLSession taskCompleted:]): Ditto.
(-[WebCoreNSURLSession invalidateAndCancel]): Ditto.
(-[WebCoreNSURLSession getTasksWithCompletionHandler:]): Ditto.
(-[WebCoreNSURLSession getAllTasksWithCompletionHandler:]): Ditto.
(-[WebCoreNSURLSession dataTaskWithRequest:]): Ditto.
(-[WebCoreNSURLSession dataTaskWithURL:]): Ditto.

* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::applySniffingPoliciesAndStoragePartitionIfNeeded):
Use a return value instead of an inout argument. Also use bridging casts.
(WebCore::ResourceHandle::createNSURLConnection): Updated for the change above.
Also use a bridging cast.
(WebCore::ResourceHandle::schedule): Use a bridging cast.
(WebCore::ResourceHandle::unschedule): Ditto.

* platform/network/mac/WebCoreURLResponse.mm:
(WebCore::adjustMIMETypeIfNecessary): Use a bridging cast.

* testing/Internals.cpp:
(WebCore::Internals::rangeForDictionaryLookupAtLocation): Moved the macOS
version of this function out of this file ...
* testing/Internals.mm:
(WebCore::Internals::rangeForDictionaryLookupAtLocation): ... to here.

Source/WebKit:

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController enterFullScreen:]): Removed the call to
setAction: since the full screen placeholder view now always uses the
cancelOperation: method.

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::lookupTextAtLocation): Updated to use the new
DictionaryLookup function that returns a tuple instead of using an out argument.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation): Ditto.
(WebKit::WebPage::performDictionaryLookupForSelection): Ditto.

Source/WebKitLegacy/mac:

* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _animationControllerForText]): Updated to use the
new DictionaryLookup function that returns a tuple instead of using an out argument.

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

46 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/bridge/objc/WebScriptObject.mm
Source/WebCore/bridge/objc/objc_instance.mm
Source/WebCore/bridge/objc/objc_runtime.mm
Source/WebCore/bridge/objc/objc_utility.h
Source/WebCore/bridge/objc/objc_utility.mm
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
Source/WebCore/editing/mac/DictionaryLookup.h
Source/WebCore/editing/mac/DictionaryLookup.mm
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/page/scrolling/ScrollingStateNode.h
Source/WebCore/page/scrolling/cocoa/ScrollingStateNode.mm
Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp
Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.h
Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm
Source/WebCore/platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm
Source/WebCore/platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/metal/GPUDrawableMetal.mm
Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm
Source/WebCore/platform/mac/WebCoreFullScreenPlaceholderView.h
Source/WebCore/platform/mac/WebCoreFullScreenPlaceholderView.mm
Source/WebCore/platform/mac/WebCoreObjCExtras.mm
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/platform/network/cocoa/CookieStorageObserver.mm
Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h
Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm
Source/WebCore/platform/network/mac/ResourceHandleMac.mm
Source/WebCore/platform/network/mac/WebCoreURLResponse.mm
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm

index f414009..bfef639 100644 (file)
@@ -1,3 +1,207 @@
+2018-07-28  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Update more WebCore Objective-C code to be ARC compatible
+        https://bugs.webkit.org/show_bug.cgi?id=188140
+
+        Reviewed by Sam Weinig.
+
+        This make sure we don't put any Objective-C objects into HashMap/Set
+        data structures, which doesn't work under ARC at this time. We could
+        fix that some day, but it's pretty simple to change code not to rely
+        on it, for now, and not as simple to support it in HashMap/Set.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (-[WebAccessibilityObjectWrapperBase updateObjectBackingStore]):
+        Use CFRetain/CFAutorelease instead of retain/autorelease.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (createAccessibilityRoleMap): Use CFStringRef in a HashMap rather than
+        NSString * for string constants.
+        (roleValueToNSString): Updated for above change.
+
+        * bridge/objc/WebScriptObject.mm:
+        (-[WebScriptObject stringRepresentation]): Updated since objectValue
+        is now CFTypeRef rather than NSObject *.
+
+        * bridge/objc/objc_instance.mm:
+        (ObjcInstance::create): Use CFTypeRef instead of id for the key types
+        in a HashMap.
+        (ObjcInstance::~ObjcInstance): Updated for the above change.
+        (ObjcInstance::invokeObjcMethod): Updated since objectValue is now
+        CFTypeRef.
+        (ObjcInstance::invokeDefaultMethod): Ditto.
+        (ObjcInstance::setValueOfUndefinedField): Ditto.
+        * bridge/objc/objc_runtime.mm:
+        (JSC::Bindings::ObjcArray::setValueAt const): Ditto.
+
+        * bridge/objc/objc_utility.h: Use #pragma once. Use CFTypeRef instead
+        of NSObject * for objectValue, since it's in a union and ARC does not
+        support strong Objective-C object pointers in a union.
+
+        * bridge/objc/objc_utility.mm:
+        (JSC::Bindings::convertValueToObjcValue): Updated since objectValue is
+        now CFTypeRef.
+
+        * editing/cocoa/HTMLConverter.mm:
+        (HTMLConverter::_processElement): Use CFTypeRef rather than NSTextTable
+        for a HashMap.
+        (HTMLConverter::_exitElement): Ditto.
+
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::attributesForAttributedStringConversion): Use CFRetain rather
+        than -[NSObject retain] in a workaround for an overrelease.
+
+        * editing/mac/DictionaryLookup.h: Removed code to make this usable from
+        non-Objective-C source files. Use tuples rather than out arguments
+        for the results of the various functions.
+
+        * editing/mac/DictionaryLookup.mm:
+        (WebCore::DictionaryLookup::rangeForSelection): Return a tuple rather
+        than using an out argument for options.
+        (WebCore::DictionaryLookup::rangeAtHitTestResult): Ditto.
+        (WebCore::DictionaryLookup::stringForPDFSelection): Ditto.
+        (WebCore::showPopupOrCreateAnimationController): Removed use of typedef
+        PlatformAnimationController.
+        (WebCore::DictionaryLookup::animationControllerForPopup): Ditto.
+
+        * html/HTMLMediaElement.h: Put the videoFullscreenLayer function inside
+        an __OBJC__ ifdef since we can't do the type conversion without the
+        full Objective-C type.
+
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::selfRetainingNSScrollViewScrollWheel): Use CFRetain/CFRelease
+        instead of retain/release.
+        (WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):
+        Updated to use tuple return value from DictionaryLookup.
+
+        * page/scrolling/ScrollingStateNode.h: Replaced direct use of PlatformLayer*
+        in a union with use of a "typless" void* pointer and added helper functions
+        to convert in both directions.
+        * page/scrolling/cocoa/ScrollingStateNode.mm:
+        (WebCore::LayerRepresentation::retainPlatformLayer): Use CFRetain instead
+        of retain.
+        (WebCore::LayerRepresentation::releasePlatformLayer): Use CFRelease instead
+        of release.
+        (WebCore::LayerRepresentation::makePlatformLayerTyped): Added.
+        (WebCore::LayerRepresentation::makePlatformLayerTypeless): Ditto.
+        * page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp:
+        (WebCore::LayerRepresentation::retainPlatformLayer): Updated argument type.
+        (WebCore::LayerRepresentation::releasePlatformLayer): Ditto.
+        (WebCore::LayerRepresentation::makePlatformLayerTyped): Added.
+        (WebCore::LayerRepresentation::makePlatformLayerTypeless): Ditto.
+
+        * platform/gamepad/cocoa/GameControllerGamepadProvider.h: Use CFTypeRef
+        instad of GCController * for key type of HashMap.
+        * platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
+        (WebCore::GameControllerGamepadProvider::controllerDidConnect): Updated
+        for the above change.
+        (WebCore::GameControllerGamepadProvider::controllerDidDisconnect): Ditto.
+
+        * platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm:
+        Use SOFT_LINK_CONSTANT_MAY_FAIL instead of SOFT_LINK_POINTER_OPTIONAL for
+        strings, since SOFT_LINK_POINTER_OPTIONAL does not work for Objective-C
+        types under ARC.
+        (WebCore::AVTrackPrivateAVFObjCImpl::audioKind const): Added checks
+        for the constants.
+        (WebCore::AVTrackPrivateAVFObjCImpl::videoKind const): Ditto.
+        (WebCore::AVTrackPrivateAVFObjCImpl::label const): Ditto.
+
+        * platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h:
+        Use #pragma once and use CFTypeRef instead of AVMediaSelectionOption *
+        in the key to a HashMap.
+        * platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
+        (WebCore::MediaSelectionGroupAVFObjC::updateOptions): Updated for
+        the above change.
+
+        * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
+        Use SOFT_LINK_CONSTANT_MAY_FAIL instead of SOFT_LINK_POINTER_OPTIONAL for
+        strings, since SOFT_LINK_POINTER_OPTIONAL does not work for Objective-C
+        types under ARC.
+        (WebCore::customSchemeURL): Removed unnecessary use of
+        NeverDestroyed<RetainPtr>. Can just use a straight pointer without calling
+        release, and that works with or without ARC.
+        (WebCore::imageDecoderAssetOptions): Ditto. Here, had to add a retain,
+        which we'll remove when we turn on ARC. Added canLoad checks, needed
+        because of SOFT_LINK_CONSTANT_MAY_FAIL.
+        (WebCore::ImageDecoderAVFObjC::firstEnabledTrack): Added canLoad check,
+        needed because of SOFT_LINK_CONSTANT_MAY_FAIL.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        Use CFTypeRef instead of AVAssetResourceLoadingRequest in HashMap.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
+        Updated for above.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest): Ditto.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        Use CFTypeRef instead of AVSampleBufferAudioRenderer in HashMap.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVolume): Updated for above.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setMuted): Ditto.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch): Ditto.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableAudioSample): Ditto.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer): Ditto.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeAudioRenderer): Ditto.
+
+        * platform/graphics/metal/GPUDrawableMetal.mm: Updated include; under ARC, it's
+        not safe to call a method on a class without seeing its interface.
+
+        * platform/mac/VideoFullscreenInterfaceMac.mm: Added an explicit
+        __unsafe_unretained for a delegate. Could consider moving to weak, but for now
+        this preserves the current behavior and compiles under ARC.
+
+        * platform/mac/WebCoreFullScreenPlaceholderView.h: Use strong for the contents,
+        weak for the target, and changed the action to be hard-coded instead of an
+        arbitrary selector. If we find we need the flexibility again later, we can do
+        it with a block, which is more ARC-friendly than calling an arbitrary selector.
+        * platform/mac/WebCoreFullScreenPlaceholderView.mm:
+        (-[WebCoreFullScreenPlaceholderView initWithFrame:]): Call function directly
+        instead of taking advantage of "using".
+        (-[WebCoreFullScreenPlaceholderView mouseDown:]): Call cancelOperation: on the
+        target rather than performing an arbitrary selector.
+
+        * platform/mac/WebCoreObjCExtras.mm:
+        (WebCoreObjCScheduleDeallocateOnMainThread): Use sel_registerName instead of
+        @selector, since @selector is not supported under ARC.
+
+        * platform/network/ResourceHandle.h: Use a return value rather than using an
+        inout argument in applySniffingPoliciesAndStoragePartitionIfNeeded.
+
+        * platform/network/cocoa/CookieStorageObserver.mm:
+        (WebCore::CookieStorageObserver::startObserving): Removed unnecessary
+        assertion of repondsToSelector since we are about to dispatch it immediately
+        after. Call the selector in the conventional way instead of using performSelector.
+
+        * platform/network/cocoa/WebCoreNSURLSession.h: Use #pragma once and use
+        CFTypeRef instead of an Objective-C type. Also use an explicit __unsafe_unretained
+        for the session in the data task.
+        * platform/network/cocoa/WebCoreNSURLSession.mm:
+        (-[WebCoreNSURLSession dealloc]): Updated for the above.
+        (-[WebCoreNSURLSession taskCompleted:]): Ditto.
+        (-[WebCoreNSURLSession invalidateAndCancel]): Ditto.
+        (-[WebCoreNSURLSession getTasksWithCompletionHandler:]): Ditto.
+        (-[WebCoreNSURLSession getAllTasksWithCompletionHandler:]): Ditto.
+        (-[WebCoreNSURLSession dataTaskWithRequest:]): Ditto.
+        (-[WebCoreNSURLSession dataTaskWithURL:]): Ditto.
+
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::applySniffingPoliciesAndStoragePartitionIfNeeded):
+        Use a return value instead of an inout argument. Also use bridging casts.
+        (WebCore::ResourceHandle::createNSURLConnection): Updated for the change above.
+        Also use a bridging cast.
+        (WebCore::ResourceHandle::schedule): Use a bridging cast.
+        (WebCore::ResourceHandle::unschedule): Ditto.
+
+        * platform/network/mac/WebCoreURLResponse.mm:
+        (WebCore::adjustMIMETypeIfNecessary): Use a bridging cast.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::rangeForDictionaryLookupAtLocation): Moved the macOS
+        version of this function out of this file ...
+        * testing/Internals.mm:
+        (WebCore::Internals::rangeForDictionaryLookupAtLocation): ... to here.
+
 2018-07-29  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Use static global variables instead of static NeverDestroyed inside function if possible
index d544d42..ae66acd 100644 (file)
@@ -283,8 +283,9 @@ NSArray *convertToNSArray(const AccessibilityObject::AccessibilityChildrenVector
 {
     // Calling updateBackingStore() can invalidate this element so self must be retained.
     // If it does become invalidated, m_object will be nil.
-    [[self retain] autorelease];
-    
+    CFRetain((__bridge CFTypeRef)self);
+    CFAutorelease((__bridge CFTypeRef)self);
+
     if (!m_object)
         return NO;
     
index 241141c..e3af278 100644 (file)
@@ -1844,15 +1844,14 @@ static void WebTransformCGPathToNSBezierPath(void* info, const CGPathElement *el
     return [NSValue valueWithPoint:NSMakePoint(cgPoint.x, cgPoint.y)];
 }
 
-typedef HashMap<int, NSString*> AccessibilityRoleMap;
+using AccessibilityRoleMap = HashMap<int, CFStringRef>;
 
-static const AccessibilityRoleMap& createAccessibilityRoleMap()
+static AccessibilityRoleMap createAccessibilityRoleMap()
 {
     struct RoleEntry {
         AccessibilityRole value;
         __unsafe_unretained NSString *string;
     };
-    
     static const RoleEntry roles[] = {
         { AccessibilityRole::Unknown, NSAccessibilityUnknownRole },
         { AccessibilityRole::Button, NSAccessibilityButtonRole },
@@ -1993,19 +1992,16 @@ static const AccessibilityRoleMap& createAccessibilityRoleMap()
         { AccessibilityRole::GraphicsSymbol, NSAccessibilityImageRole },
         { AccessibilityRole::Caption, NSAccessibilityGroupRole },
     };
-    AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;
-    
-    const unsigned numRoles = sizeof(roles) / sizeof(roles[0]);
-    for (unsigned i = 0; i < numRoles; ++i)
-        roleMap.set(static_cast<int>(roles[i].value), roles[i].string);
+    AccessibilityRoleMap roleMap;
+    for (auto& role : roles)
+        roleMap.add(static_cast<int>(role.value), (__bridge CFStringRef)role.string);
     return roleMap;
 }
 
-static NSStringroleValueToNSString(AccessibilityRole value)
+static NSString *roleValueToNSString(AccessibilityRole value)
 {
-    ASSERT(static_cast<int>(value));
-    static const AccessibilityRoleMap& roleMap = createAccessibilityRoleMap();
-    return roleMap.get(static_cast<int>(value));
+    static NeverDestroyed<AccessibilityRoleMap> roleMap = createAccessibilityRoleMap();
+    return (__bridge NSString *)roleMap.get().get(static_cast<int>(value));
 }
 
 - (NSString*)role
index 0b5f8a9..0397794 100644 (file)
@@ -498,11 +498,7 @@ static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* root
     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
     JSLockHolder lock(exec);
 
-    id result = convertValueToObjcValue(exec, [self _imp], ObjcObjectType).objectValue;
-
-    NSString *description = [result description];
-
-    return description;
+    return [(__bridge id)convertValueToObjcValue(exec, [self _imp], ObjcObjectType).objectValue description];
 }
 
 - (id)webScriptValueAtIndex:(unsigned)index
index fce743d..e8b78eb 100644 (file)
@@ -57,9 +57,9 @@ using namespace JSC;
 static NSString *s_exception;
 static JSGlobalObject* s_exceptionEnvironment; // No need to protect this value, since we just use it for a pointer comparison.
 
-static HashMap<id, ObjcInstance*>& wrapperCache()
+static HashMap<CFTypeRef, ObjcInstance*>& wrapperCache()
 {
-    static NeverDestroyed<HashMap<id, ObjcInstance*>> map;
+    static NeverDestroyed<HashMap<CFTypeRef, ObjcInstance*>> map;
     return map;
 }
 
@@ -106,7 +106,7 @@ ObjcInstance::ObjcInstance(id instance, RefPtr<RootObject>&& rootObject)
 
 RefPtr<ObjcInstance> ObjcInstance::create(id instance, RefPtr<RootObject>&& rootObject)
 {
-    auto result = wrapperCache().add(instance, nullptr);
+    auto result = wrapperCache().add((__bridge CFTypeRef)instance, nullptr);
     if (result.isNewEntry) {
         RefPtr<ObjcInstance> wrapper = adoptRef(new ObjcInstance(instance, WTFMove(rootObject)));
         result.iterator->value = wrapper.get();
@@ -121,7 +121,7 @@ ObjcInstance::~ObjcInstance()
     // Both -finalizeForWebScript and -dealloc/-finalize of _instance may require autorelease pools.
     @autoreleasepool {
         ASSERT(_instance);
-        wrapperCache().remove(_instance.get());
+        wrapperCache().remove((__bridge CFTypeRef)_instance.get());
 
         if ([_instance.get() respondsToSelector:@selector(finalizeForWebScript)])
             [_instance.get() performSelector:@selector(finalizeForWebScript)];
@@ -247,7 +247,7 @@ JSC::JSValue ObjcInstance::invokeObjcMethod(ExecState* exec, ObjcMethod* method)
         int count = exec->argumentCount();
         for (int i = 0; i < count; i++) {
             ObjcValue value = convertValueToObjcValue(exec, exec->uncheckedArgument(i), ObjcObjectType);
-            [objcArgs addObject:value.objectValue];
+            [objcArgs addObject:(__bridge id)value.objectValue];
         }
         [invocation setArgument:&objcArgs atIndex:3];
     } else {
@@ -361,7 +361,7 @@ JSC::JSValue ObjcInstance::invokeDefaultMethod(ExecState* exec)
     unsigned count = exec->argumentCount();
     for (unsigned i = 0; i < count; i++) {
         ObjcValue value = convertValueToObjcValue(exec, exec->uncheckedArgument(i), ObjcObjectType);
-        [objcArgs addObject:value.objectValue];
+        [objcArgs addObject:(__bridge id)value.objectValue];
     }
     [invocation setArgument:&objcArgs atIndex:2];
 
@@ -408,7 +408,7 @@ bool ObjcInstance::setValueOfUndefinedField(ExecState* exec, PropertyName proper
         ObjcValue objcValue = convertValueToObjcValue(exec, aValue, ObjcObjectType);
 
         @try {
-            [targetObject setValue:objcValue.objectValue forUndefinedKey:[NSString stringWithCString:name.ascii().data() encoding:NSASCIIStringEncoding]];
+            [targetObject setValue:(__bridge id)objcValue.objectValue forUndefinedKey:[NSString stringWithCString:name.ascii().data() encoding:NSASCIIStringEncoding]];
         } @catch(NSException* localException) {
             // Do nothing.  Class did not override valueForUndefinedKey:.
         }
index 51a2103..29c58c5 100644 (file)
@@ -180,7 +180,7 @@ bool ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue aValue)
     ObjcValue oValue = convertValueToObjcValue (exec, aValue, ObjcObjectType);
 
     @try {
-        [_array.get() insertObject:oValue.objectValue atIndex:index];
+        [_array.get() insertObject:(__bridge id)oValue.objectValue atIndex:index];
         return true;
     } @catch(NSException* localException) {
         throwException(exec, scope, createError(exec, "Objective-C exception."));
index ab046b5..add4d9e 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef KJS_BINDINGS_OBJC_UTILITY_H
-#define KJS_BINDINGS_OBJC_UTILITY_H
+#pragma once
 
 #include <CoreFoundation/CoreFoundation.h>
 
@@ -38,7 +37,7 @@ namespace JSC {
 namespace Bindings {
 
 typedef union {
-    ObjectStructPtr objectValue;
+    CFTypeRef objectValue;
     bool booleanValue;
     char charValue;
     short shortValue;
@@ -79,5 +78,3 @@ JSObject *throwError(ExecState*, ThrowScope&, NSString *message);
 
 } // namespace Bindings
 } // namespace JSC
-
-#endif
index 197043f..01cbf62 100644 (file)
@@ -101,8 +101,8 @@ ObjcValue convertValueToObjcValue(ExecState* exec, JSValue value, ObjcValueType
                 globalObject = originGlobalObject;
                 
             RootObject* rootObject = findRootObject(globalObject);
-            result.objectValue =  rootObject
-                ? [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:originRootObject rootObject:rootObject]
+            result.objectValue = rootObject
+                ? (__bridge CFTypeRef)[webScriptObjectClass() _convertValueToObjcValue:value originRootObject:originRootObject rootObject:rootObject]
                 : nil;
         }
         break;
index 527d992..a3dd69e 100644 (file)
@@ -369,7 +369,7 @@ private:
     DocumentLoader* m_dataSource;
     
     HashMap<RefPtr<Element>, RetainPtr<NSDictionary>> m_attributesForElements;
-    HashMap<RetainPtr<NSTextTable>, RefPtr<Element>> m_textTableFooters;
+    HashMap<RetainPtr<CFTypeRef>, RefPtr<Element>> m_textTableFooters;
     HashMap<RefPtr<Element>, RetainPtr<NSDictionary>> m_aggregatedAttributesForElements;
 
     NSMutableAttributedString *_attrStr;
@@ -1863,7 +1863,7 @@ BOOL HTMLConverter::_processElement(Element& element, NSInteger depth)
             _addTableCellForElement(nil);
         _addTableForElement(tableElement);
     } else if (displayValue == "table-footer-group" && [_textTables count] > 0) {
-        m_textTableFooters.add([_textTables lastObject], &element);
+        m_textTableFooters.add((__bridge CFTypeRef)[_textTables lastObject], &element);
         retval = NO;
     } else if (displayValue == "table-row" && [_textTables count] > 0) {
         PlatformColor *color = _colorForElement(element, CSSPropertyBackgroundColor);
@@ -2095,12 +2095,12 @@ void HTMLConverter::_exitElement(Element& element, NSInteger depth, NSUInteger s
     range = NSMakeRange(startIndex, [_attrStr length] - startIndex);
     if (displayValue == "table" && [_textTables count] > 0) {
         NSTextTable *key = [_textTables lastObject];
-        Element* footer = m_textTableFooters.get(key);
+        Element* footer = m_textTableFooters.get((__bridge CFTypeRef)key);
         while ([_textTables count] < [_textBlocks count] + 1)
             [_textBlocks removeLastObject];
         if (footer) {
             _traverseFooterNode(*footer, depth + 1);
-            m_textTableFooters.remove(key);
+            m_textTableFooters.remove((__bridge CFTypeRef)key);
         }
         [_textTables removeLastObject];
         [_textTableSpacings removeLastObject];
index 6f4b3fb..9728558 100644 (file)
@@ -110,11 +110,16 @@ static NSDictionary *attributesForAttributedStringConversion()
     static NSString * const NSExcludedElementsDocumentAttribute = @"ExcludedElements";
 #endif
 
+    NSURL *baseURL = URL::fakeURLWithRelativePart(emptyString());
+
+    // The output base URL needs +1 refcount to work around the fact that NSHTMLReader over-releases it.
+    CFRetain((__bridge CFTypeRef)baseURL);
+
     return @{
         NSExcludedElementsDocumentAttribute: excludedElements.get(),
         @"InterchangeNewline": @YES,
         @"CoalesceTabSpans": @YES,
-        @"OutputBaseURL": [(NSURL *)URL::fakeURLWithRelativePart(emptyString()) retain], // The value needs +1 refcount, as NSAttributedString over-releases it.
+        @"OutputBaseURL": baseURL,
         @"WebResourceHandler": [[WebArchiveResourceWebResourceHandler new] autorelease],
     };
 }
index d7ebe18..c461978 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#pragma once
-
 #if PLATFORM(MAC)
 
 #include "DictionaryPopupInfo.h"
+#include <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
 #include <wtf/Function.h>
 
-OBJC_CLASS NSString;
 OBJC_CLASS NSView;
 OBJC_CLASS PDFSelection;
 
-// This file is included in Internals.cpp, so we can't use ObjC outright.
-#if defined(__OBJC__)
-#include <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
-#define PlatformAnimationController id<NSImmediateActionAnimationController>
-#else
-#define PlatformAnimationController void*
-#endif
-
 namespace WebCore {
 
 class HitTestResult;
@@ -50,16 +40,16 @@ class VisibleSelection;
 
 class DictionaryLookup {
 public:
-    WEBCORE_EXPORT static RefPtr<Range> rangeForSelection(const VisibleSelection&, NSDictionary **options);
-    WEBCORE_EXPORT static RefPtr<Range> rangeAtHitTestResult(const HitTestResult&, NSDictionary **options);
-    WEBCORE_EXPORT static NSString *stringForPDFSelection(PDFSelection *, NSDictionary **options);
+    WEBCORE_EXPORT static std::tuple<RefPtr<Range>, NSDictionary *> rangeForSelection(const VisibleSelection&);
+    WEBCORE_EXPORT static std::tuple<RefPtr<Range>, NSDictionary *> rangeAtHitTestResult(const HitTestResult&);
+    WEBCORE_EXPORT static std::tuple<NSString *, NSDictionary *> stringForPDFSelection(PDFSelection *);
 
     // FIXME: Should move/unify dictionaryPopupInfoForRange here too.
 
     WEBCORE_EXPORT static void showPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr);
     WEBCORE_EXPORT static void hidePopup();
 
-    WEBCORE_EXPORT static PlatformAnimationController animationControllerForPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr);
+    WEBCORE_EXPORT static id <NSImmediateActionAnimationController> animationControllerForPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr);
 };
 
 } // namespace WebCore
index 93e74c8..55062fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -78,45 +78,44 @@ static bool selectionContainsPosition(const VisiblePosition& position, const Vis
     return selectedRange->contains(position);
 }
 
-RefPtr<Range> DictionaryLookup::rangeForSelection(const VisibleSelection& selection, NSDictionary **options)
+std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeForSelection(const VisibleSelection& selection)
 {
     auto selectedRange = selection.toNormalizedRange();
     if (!selectedRange)
-        return nullptr;
+        return { nullptr, nil };
 
     // Since we already have the range we want, we just need to grab the returned options.
-    if (options) {
-        auto selectionStart = selection.visibleStart();
-        auto selectionEnd = selection.visibleEnd();
+    auto selectionStart = selection.visibleStart();
+    auto selectionEnd = selection.visibleEnd();
 
-        // As context, we are going to use the surrounding paragraphs of text.
-        auto paragraphStart = startOfParagraph(selectionStart);
-        auto paragraphEnd = endOfParagraph(selectionEnd);
+    // As context, we are going to use the surrounding paragraphs of text.
+    auto paragraphStart = startOfParagraph(selectionStart);
+    auto paragraphEnd = endOfParagraph(selectionEnd);
 
-        int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
-        int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get());
-        NSRange rangeToPass = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
+    int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
+    int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get());
+    NSRange rangeToPass = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
 
-        tokenRange(plainText(makeRange(paragraphStart, paragraphEnd).get()), rangeToPass, options);
-    }
+    NSDictionary *options = nil;
+    tokenRange(plainText(makeRange(paragraphStart, paragraphEnd).get()), rangeToPass, &options);
 
-    return selectedRange;
+    return { selectedRange, options };
 }
 
-RefPtr<Range> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTestResult, NSDictionary **options)
+std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTestResult)
 {
     auto* node = hitTestResult.innerNonSharedNode();
     if (!node || !node->renderer())
-        return nullptr;
+        return { nullptr, nil };
 
     auto* frame = node->document().frame();
     if (!frame)
-        return nullptr;
+        return { nullptr, nil };
 
     // Don't do anything if there is no character at the point.
     auto framePoint = hitTestResult.roundedPointInInnerNodeFrame();
     if (!frame->rangeForPoint(framePoint))
-        return nullptr;
+        return { nullptr, nil };
 
     auto position = frame->visiblePositionForPoint(framePoint);
     if (position.isNull())
@@ -125,7 +124,7 @@ RefPtr<Range> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTes
     // If we hit the selection, use that instead of letting Lookup decide the range.
     auto selection = frame->page()->focusController().focusedOrMainFrame().selection().selection();
     if (selectionContainsPosition(position, selection))
-        return rangeForSelection(selection, options);
+        return rangeForSelection(selection);
 
     VisibleSelection selectionAccountingForLineRules { position };
     selectionAccountingForLineRules.expandUsingGranularity(WordGranularity);
@@ -134,17 +133,18 @@ RefPtr<Range> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTes
     // As context, we are going to use 250 characters of text before and after the point.
     auto fullCharacterRange = rangeExpandedAroundPositionByCharacters(position, 250);
     if (!fullCharacterRange)
-        return nullptr;
+        return { nullptr, nil };
 
     NSRange rangeToPass = NSMakeRange(TextIterator::rangeLength(makeRange(fullCharacterRange->startPosition(), position).get()), 0);
-    NSRange extractedRange = tokenRange(plainText(fullCharacterRange.get()), rangeToPass, options);
+    NSDictionary *options = nil;
+    NSRange extractedRange = tokenRange(plainText(fullCharacterRange.get()), rangeToPass, &options);
 
     // tokenRange sometimes returns {NSNotFound, 0} if it was unable to determine a good string.
     // FIXME (159063): We shouldn't need to check for zero length here.
     if (extractedRange.location == NSNotFound || extractedRange.length == 0)
-        return nullptr;
+        return { nullptr, nil };
 
-    return TextIterator::subrange(*fullCharacterRange, extractedRange.location, extractedRange.length);
+    return { TextIterator::subrange(*fullCharacterRange, extractedRange.location, extractedRange.length), options };
 }
 
 static void expandSelectionByCharacters(PDFSelection *selection, NSInteger numberOfCharactersToExpand, NSInteger& charactersAddedBeforeStart, NSInteger& charactersAddedAfterEnd)
@@ -162,13 +162,13 @@ static void expandSelectionByCharacters(PDFSelection *selection, NSInteger numbe
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-NSString *DictionaryLookup::stringForPDFSelection(PDFSelection *selection, NSDictionary **options)
+std::tuple<NSString *, NSDictionary *> DictionaryLookup::stringForPDFSelection(PDFSelection *selection)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     // Don't do anything if there is no character at the point.
     if (!selection || !selection.string.length)
-        return @"";
+        return { @"", nil };
 
     RetainPtr<PDFSelection> selectionForLookup = adoptNS([selection copy]);
 
@@ -181,11 +181,12 @@ NSString *DictionaryLookup::stringForPDFSelection(PDFSelection *selection, NSDic
     auto fullPlainTextString = [selectionForLookup string];
     auto rangeToPass = NSMakeRange(charactersAddedBeforeStart, 0);
 
-    auto extractedRange = tokenRange(fullPlainTextString, rangeToPass, options);
+    NSDictionary *options = nil;
+    auto extractedRange = tokenRange(fullPlainTextString, rangeToPass, &options);
 
     // This function sometimes returns {NSNotFound, 0} if it was unable to determine a good string.
     if (extractedRange.location == NSNotFound)
-        return selection.string;
+        return { selection.string, options };
 
     NSInteger lookupAddedBefore = rangeToPass.location - extractedRange.location;
     NSInteger lookupAddedAfter = (extractedRange.location + extractedRange.length) - (rangeToPass.location + originalLength);
@@ -194,14 +195,14 @@ NSString *DictionaryLookup::stringForPDFSelection(PDFSelection *selection, NSDic
     [selection extendSelectionAtEnd:lookupAddedAfter];
 
     ASSERT([selection.string isEqualToString:[fullPlainTextString substringWithRange:extractedRange]]);
-    return selection.string;
+    return { selection.string, options };
 
     END_BLOCK_OBJC_EXCEPTIONS;
 
-    return nil;
+    return { @"", nil };
 }
 
-static PlatformAnimationController showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback)
+static id <NSImmediateActionAnimationController> showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
@@ -262,7 +263,7 @@ void DictionaryLookup::hidePopup()
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-PlatformAnimationController DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback)
+id <NSImmediateActionAnimationController> DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback)
 {
     return showPopupOrCreateAnimationController(true, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback);
 }
@@ -270,4 +271,3 @@ PlatformAnimationController DictionaryLookup::animationControllerForPopup(const
 } // namespace WebCore
 
 #endif // PLATFORM(MAC)
-
index 7681909..a78ecfd 100644 (file)
@@ -177,7 +177,9 @@ public:
     void waitForPreparedForInlineThen(WTF::Function<void()>&& completionHandler = [] { });
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
+#ifdef __OBJC__
     PlatformLayer* videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
+#endif
     void setVideoFullscreenFrame(FloatRect);
     void setVideoFullscreenGravity(MediaPlayerEnums::VideoGravity);
     MediaPlayerEnums::VideoGravity videoFullscreenGravity() const { return m_videoFullscreenGravity; }
index 830c303..a26430c 100644 (file)
@@ -453,10 +453,10 @@ static void selfRetainingNSScrollViewScrollWheel(NSScrollView *self, SEL selecto
     bool shouldRetainSelf = isMainThread() && nsScrollViewScrollWheelShouldRetainSelf();
 
     if (shouldRetainSelf)
-        [self retain];
+        CFRetain((__bridge CFTypeRef)self);
     wtfCallIMP<void>(originalNSScrollViewScrollWheel, self, selector, event);
     if (shouldRetainSelf)
-        [self release];
+        CFRelease((__bridge CFTypeRef)self);
 }
 
 bool EventHandler::widgetDidHandleWheelEvent(const PlatformWheelEvent& wheelEvent, Widget& widget)
@@ -1113,10 +1113,12 @@ VisibleSelection EventHandler::selectClosestWordFromHitTestResultBasedOnLookup(c
     if (!m_frame.editor().behavior().shouldSelectBasedOnDictionaryLookup())
         return VisibleSelection();
 
-    if (auto range = DictionaryLookup::rangeAtHitTestResult(result, nullptr))
-        return VisibleSelection(*range);
+    RefPtr<Range> range;
+    std::tie(range, std::ignore) = DictionaryLookup::rangeAtHitTestResult(result);
+    if (!range)
+        return VisibleSelection();
 
-    return VisibleSelection();
+    return VisibleSelection(*range);
 }
 
 static IntSize autoscrollAdjustmentFactorForScreenBoundaries(const IntPoint& screenPoint, const FloatRect& screenRect)
index 6fbe638..455dc1a 100644 (file)
@@ -71,11 +71,11 @@ public:
     { }
 
     LayerRepresentation(PlatformLayer* platformLayer)
-        : m_platformLayer(platformLayer)
+        : m_typelessPlatformLayer(makePlatformLayerTypeless(platformLayer))
         , m_layerID(0)
         , m_representation(PlatformLayerRepresentation)
     {
-        retainPlatformLayer(platformLayer);
+        retainPlatformLayer(m_typelessPlatformLayer);
     }
 
     LayerRepresentation(GraphicsLayer::PlatformLayerID layerID)
@@ -86,18 +86,18 @@ public:
     }
 
     LayerRepresentation(const LayerRepresentation& other)
-        : m_platformLayer(other.m_platformLayer)
+        : m_typelessPlatformLayer(other.m_typelessPlatformLayer)
         , m_layerID(other.m_layerID)
         , m_representation(other.m_representation)
     {
         if (m_representation == PlatformLayerRepresentation)
-            retainPlatformLayer(m_platformLayer);
+            retainPlatformLayer(m_typelessPlatformLayer);
     }
 
     ~LayerRepresentation()
     {
         if (m_representation == PlatformLayerRepresentation)
-            releasePlatformLayer(m_platformLayer);
+            releasePlatformLayer(m_typelessPlatformLayer);
     }
 
     operator GraphicsLayer*() const
@@ -109,7 +109,7 @@ public:
     operator PlatformLayer*() const
     {
         ASSERT(m_representation == PlatformLayerRepresentation);
-        return m_platformLayer;
+        return makePlatformLayerTyped(m_typelessPlatformLayer);
     }
     
     GraphicsLayer::PlatformLayerID layerID() const
@@ -125,12 +125,12 @@ public:
 
     LayerRepresentation& operator=(const LayerRepresentation& other)
     {
-        m_platformLayer = other.m_platformLayer;
+        m_typelessPlatformLayer = other.m_typelessPlatformLayer;
         m_layerID = other.m_layerID;
         m_representation = other.m_representation;
 
         if (m_representation == PlatformLayerRepresentation)
-            retainPlatformLayer(m_platformLayer);
+            retainPlatformLayer(m_typelessPlatformLayer);
 
         return *this;
     }
@@ -146,7 +146,7 @@ public:
             return m_graphicsLayer == other.m_graphicsLayer
                 && m_layerID == other.m_layerID;
         case PlatformLayerRepresentation:
-            return m_platformLayer == other.m_platformLayer;
+            return m_typelessPlatformLayer == other.m_typelessPlatformLayer;
         case PlatformLayerIDRepresentation:
             return m_layerID == other.m_layerID;
         }
@@ -174,12 +174,14 @@ public:
     bool representsPlatformLayerID() const { return m_representation == PlatformLayerIDRepresentation; }
     
 private:
-    WEBCORE_EXPORT void retainPlatformLayer(PlatformLayer*);
-    WEBCORE_EXPORT void releasePlatformLayer(PlatformLayer*);
+    WEBCORE_EXPORT static void retainPlatformLayer(void* typelessPlatformLayer);
+    WEBCORE_EXPORT static void releasePlatformLayer(void* typelessPlatformLayer);
+    WEBCORE_EXPORT static PlatformLayer* makePlatformLayerTyped(void* typelessPlatformLayer);
+    WEBCORE_EXPORT static void* makePlatformLayerTypeless(PlatformLayer*);
 
     union {
         GraphicsLayer* m_graphicsLayer;
-        PlatformLayer *m_platformLayer;
+        void* m_typelessPlatformLayer;
     };
 
     GraphicsLayer::PlatformLayerID m_layerID;
index 131ba4c..374879f 100644 (file)
 #include "config.h"
 #include "ScrollingStateNode.h"
 
-#include "GraphicsLayer.h"
-#include "ScrollingStateTree.h"
+#include "PlatformLayer.h"
 
 #if ENABLE(ASYNC_SCROLLING)
 
 namespace WebCore {
 
-void LayerRepresentation::retainPlatformLayer(PlatformLayer* layer)
+void LayerRepresentation::retainPlatformLayer(void* typelessLayer)
 {
-    [layer retain];
+    if (typelessLayer)
+        CFRetain(typelessLayer);
 }
 
-void LayerRepresentation::releasePlatformLayer(PlatformLayer* layer)
+void LayerRepresentation::releasePlatformLayer(void* typelessLayer)
 {
-    [layer release];
+    if (typelessLayer)
+        CFRelease(typelessLayer);
+}
+
+CALayer *LayerRepresentation::makePlatformLayerTyped(void* typelessLayer)
+{
+    return (__bridge CALayer *)typelessLayer;
+}
+
+void* LayerRepresentation::makePlatformLayerTypeless(CALayer *layer)
+{
+    return (__bridge void*)layer;
 }
 
 } // namespace WebCore
index aeb6223..3d68ae6 100644 (file)
 
 namespace WebCore {
 
-void LayerRepresentation::retainPlatformLayer(PlatformLayer*)
+void LayerRepresentation::retainPlatformLayer(void*)
 {
     notImplemented();
 }
 
-void LayerRepresentation::releasePlatformLayer(PlatformLayer*)
+void LayerRepresentation::releasePlatformLayer(void*)
 {
     notImplemented();
 }
 
+PlatformLayer* LayerRepresentation::makePlatformLayerTyped(void* typelessLayer)
+{
+    return static_cast<PlatformLayer*>(typelessLayer);
+}
+
+void* LayerRepresentation::makePlatformLayerTypeless(PlatformLayer* layer)
+{
+    return layer;
+}
+
 } // namespace WebCore
 
 #endif // USE(COORDINATED_GRAPHICS)
index c725074..7db0150 100644 (file)
@@ -72,7 +72,7 @@ private:
 
     void makeInvisibileGamepadsVisible();
 
-    HashMap<GCController *, std::unique_ptr<GameControllerGamepad>> m_gamepadMap;
+    HashMap<CFTypeRef, std::unique_ptr<GameControllerGamepad>> m_gamepadMap;
     Vector<PlatformGamepad*> m_gamepadVector;
     HashSet<PlatformGamepad*> m_invisibleGamepads;
 
index 17109d2..e24b203 100644 (file)
@@ -67,7 +67,7 @@ void GameControllerGamepadProvider::controllerDidConnect(GCController *controlle
         m_gamepadVector.grow(index + 1);
 
     m_gamepadVector[index] = gamepad.get();
-    m_gamepadMap.set(controller, WTFMove(gamepad));
+    m_gamepadMap.set((__bridge CFTypeRef)controller, WTFMove(gamepad));
 
 
     if (visibility == ConnectionVisibility::Invisible) {
@@ -85,7 +85,7 @@ void GameControllerGamepadProvider::controllerDidDisconnect(GCController *contro
 {
     LOG(Gamepad, "GameControllerGamepadProvider controller %p removed", controller);
 
-    auto removedGamepad = m_gamepadMap.take(controller);
+    auto removedGamepad = m_gamepadMap.take((__bridge CFTypeRef)controller);
     ASSERT(removedGamepad);
 
     auto i = m_gamepadVector.find(removedGamepad.get());
index 2aafa1c..6e48fda 100644 (file)
@@ -51,12 +51,12 @@ SOFT_LINK_CLASS(AVFoundation, AVMediaSelectionGroup)
 SOFT_LINK_CLASS(AVFoundation, AVMediaSelectionOption)
 SOFT_LINK_CLASS(AVFoundation, AVMetadataItem)
 
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicIsMainProgramContent, NSString *)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicDescribesVideoForAccessibility, NSString *)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSString *)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMediaCharacteristicIsMainProgramContent, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMediaCharacteristicDescribesVideoForAccessibility, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
 
 #define AVMetadataItem getAVMetadataItemClass()
 
@@ -112,22 +112,22 @@ void AVTrackPrivateAVFObjCImpl::setEnabled(bool enabled)
 AudioTrackPrivate::Kind AVTrackPrivateAVFObjCImpl::audioKind() const
 {
     if (m_assetTrack) {
-        if ([m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
+        if (canLoadAVMediaCharacteristicIsAuxiliaryContent() && [m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
             return AudioTrackPrivate::Alternative;
-        if ([m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
+        if (canLoadAVMediaCharacteristicDescribesVideoForAccessibility() && [m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
             return AudioTrackPrivate::Description;
-        if ([m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
+        if (canLoadAVMediaCharacteristicIsMainProgramContent() && [m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
             return AudioTrackPrivate::Main;
         return AudioTrackPrivate::None;
     }
 
     if (m_mediaSelectionOption) {
         AVMediaSelectionOption *option = m_mediaSelectionOption->avMediaSelectionOption();
-        if ([option hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
+        if (canLoadAVMediaCharacteristicIsAuxiliaryContent() && [option hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
             return AudioTrackPrivate::Alternative;
-        if ([option hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
+        if (canLoadAVMediaCharacteristicDescribesVideoForAccessibility() && [option hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
             return AudioTrackPrivate::Description;
-        if ([option hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
+        if (canLoadAVMediaCharacteristicIsMainProgramContent() && [option hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
             return AudioTrackPrivate::Main;
         return AudioTrackPrivate::None;
     }
@@ -139,26 +139,26 @@ AudioTrackPrivate::Kind AVTrackPrivateAVFObjCImpl::audioKind() const
 VideoTrackPrivate::Kind AVTrackPrivateAVFObjCImpl::videoKind() const
 {
     if (m_assetTrack) {
-        if ([m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
+        if (canLoadAVMediaCharacteristicDescribesVideoForAccessibility() && [m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
             return VideoTrackPrivate::Sign;
-        if ([m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
+        if (canLoadAVMediaCharacteristicTranscribesSpokenDialogForAccessibility() && [m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
             return VideoTrackPrivate::Captions;
-        if ([m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
+        if (canLoadAVMediaCharacteristicIsAuxiliaryContent() && [m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
             return VideoTrackPrivate::Alternative;
-        if ([m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
+        if (canLoadAVMediaCharacteristicIsMainProgramContent() && [m_assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
             return VideoTrackPrivate::Main;
         return VideoTrackPrivate::None;
     }
 
     if (m_mediaSelectionOption) {
         AVMediaSelectionOption *option = m_mediaSelectionOption->avMediaSelectionOption();
-        if ([option hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
+        if (canLoadAVMediaCharacteristicDescribesVideoForAccessibility() && [option hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
             return VideoTrackPrivate::Sign;
-        if ([option hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
+        if (canLoadAVMediaCharacteristicTranscribesSpokenDialogForAccessibility() && [option hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
             return VideoTrackPrivate::Captions;
-        if ([option hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
+        if (canLoadAVMediaCharacteristicIsAuxiliaryContent() && [option hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
             return VideoTrackPrivate::Alternative;
-        if ([option hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
+        if (canLoadAVMediaCharacteristicIsMainProgramContent() && [option hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
             return VideoTrackPrivate::Main;
         return VideoTrackPrivate::None;
     }
@@ -189,6 +189,9 @@ AtomicString AVTrackPrivateAVFObjCImpl::id() const
 
 AtomicString AVTrackPrivateAVFObjCImpl::label() const
 {
+    if (!canLoadAVMetadataCommonKeyTitle() || !canLoadAVMetadataKeySpaceCommon())
+        return emptyAtom();
+
     NSArray *commonMetadata = nil;
     if (m_assetTrack)
         commonMetadata = [m_assetTrack commonMetadata];
index ae9e1a5..8d50266 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaSelectionGroupAVFObjC_h
-#define MediaSelectionGroupAVFObjC_h
+#pragma once
 
 #if ENABLE(VIDEO_TRACK)
 
@@ -76,7 +75,7 @@ public:
 
     void updateOptions(const Vector<String>& characteristics);
 
-    using OptionContainer = HashMap<AVMediaSelectionOption*, RefPtr<MediaSelectionOptionAVFObjC>>;
+    using OptionContainer = HashMap<CFTypeRef, RefPtr<MediaSelectionOptionAVFObjC>>;
     typename OptionContainer::ValuesIteratorRange options() { return m_options.values(); }
 
     AVMediaSelectionGroup *avMediaSelectionGroup() const { return m_mediaSelectionGroup.get(); }
@@ -97,5 +96,3 @@ private:
 }
 
 #endif // ENABLE(VIDEO_TRACK)
-
-#endif // MediaSelectionGroupAVFObjC_h
index a23d809..b2c1e96 100644 (file)
@@ -109,7 +109,7 @@ void MediaSelectionGroupAVFObjC::updateOptions(const Vector<String>& characteris
     RetainPtr<NSSet> newAVOptions = adoptNS([[NSSet alloc] initWithArray:[getAVMediaSelectionGroupClass() playableMediaSelectionOptionsFromArray:[m_mediaSelectionGroup options]]]);
     RetainPtr<NSMutableSet> oldAVOptions = adoptNS([[NSMutableSet alloc] initWithCapacity:m_options.size()]);
     for (auto& avOption : m_options.keys())
-        [oldAVOptions addObject:avOption];
+        [oldAVOptions addObject:(__bridge AVMediaSelectionOption *)avOption];
 
     RetainPtr<NSMutableSet> addedAVOptions = adoptNS([newAVOptions mutableCopy]);
     [addedAVOptions minusSet:oldAVOptions.get()];
@@ -121,7 +121,7 @@ void MediaSelectionGroupAVFObjC::updateOptions(const Vector<String>& characteris
         if (m_selectedOption && removedAVOption == m_selectedOption->avMediaSelectionOption())
             m_selectedOption = nullptr;
 
-        m_options.remove(removedAVOption);
+        m_options.remove((__bridge CFTypeRef)removedAVOption);
     }
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
@@ -131,7 +131,7 @@ void MediaSelectionGroupAVFObjC::updateOptions(const Vector<String>& characteris
         auto addedOption = MediaSelectionOptionAVFObjC::create(*this, addedAVOption);
         if (addedAVOption == selectedOption)
             m_selectedOption = addedOption.ptr();
-        m_options.set(addedAVOption, WTFMove(addedOption));
+        m_options.set((__bridge CFTypeRef)addedAVOption, WTFMove(addedOption));
     }
 
     if (!m_shouldSelectOptionAutomatically)
@@ -164,8 +164,8 @@ void MediaSelectionGroupAVFObjC::updateOptions(const Vector<String>& characteris
     if (m_selectedOption && m_selectedOption->avMediaSelectionOption() == preferredOption)
         return;
 
-    ASSERT(m_options.contains(preferredOption));
-    m_selectedOption = m_options.get(preferredOption);
+    ASSERT(m_options.contains((__bridge CFTypeRef)preferredOption));
+    m_selectedOption = m_options.get((__bridge CFTypeRef)preferredOption);
     m_selectionTimer.startOneShot(0_s);
 }
 
index 683c5c4..d6d1486 100644 (file)
@@ -64,9 +64,9 @@ SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
 SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVURLAsset)
 SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVAssetReader)
 SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVAssetReaderTrackOutput)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicVisual, NSString *)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetReferenceRestrictionsKey, NSString *)
-SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetUsesNoPersistentCacheKey, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMediaCharacteristicVisual, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVURLAssetReferenceRestrictionsKey, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVURLAssetUsesNoPersistentCacheKey, NSString *)
 #define AVMediaCharacteristicVisual getAVMediaCharacteristicVisual()
 #define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
 #define AVURLAssetUsesNoPersistentCacheKey getAVURLAssetUsesNoPersistentCacheKey()
@@ -224,24 +224,22 @@ namespace WebCore {
 
 static NSURL *customSchemeURL()
 {
-    static NeverDestroyed<RetainPtr<NSURL>> url;
-    if (!url.get())
-        url.get() = adoptNS([[NSURL alloc] initWithString:@"custom-imagedecoderavfobjc://resource"]);
-
-    return url.get().get();
+    static NSURL *url = [[NSURL alloc] initWithString:@"custom-imagedecoderavfobjc://resource"];
+    return url;
 }
 
 static NSDictionary *imageDecoderAssetOptions()
 {
-    static NeverDestroyed<RetainPtr<NSDictionary>> options;
-    if (!options.get()) {
-        options.get() = @{
+    static NSDictionary *options = [] {
+        // FIXME: Are these keys really optional?
+        if (!canLoadAVURLAssetReferenceRestrictionsKey() || !canLoadAVURLAssetUsesNoPersistentCacheKey())
+            return [@{ } retain];
+        return [@{
             AVURLAssetReferenceRestrictionsKey: @(AVAssetReferenceRestrictionForbidAll),
             AVURLAssetUsesNoPersistentCacheKey: @YES,
-        };
-    }
-
-    return options.get().get();
+        } retain];
+    }();
+    return options;
 }
 
 static ImageDecoderAVFObjC::RotationProperties transformToRotationProperties(AffineTransform inTransform)
@@ -364,6 +362,12 @@ bool ImageDecoderAVFObjC::canDecodeType(const String& mimeType)
 
 AVAssetTrack *ImageDecoderAVFObjC::firstEnabledTrack()
 {
+    // FIXME: Is AVMediaCharacteristicVisual truly optional?
+    if (!canLoadAVMediaCharacteristicVisual()) {
+        LOG(Images, "ImageDecoderAVFObjC::firstEnabledTrack(%p) - AVMediaCharacteristicVisual is not supported", this);
+        return nil;
+    }
+
     NSArray<AVAssetTrack *> *videoTracks = [m_asset tracksWithMediaCharacteristic:AVMediaCharacteristicVisual];
     NSUInteger firstEnabledIndex = [videoTracks indexOfObjectPassingTest:^(AVAssetTrack *track, NSUInteger, BOOL*) {
         return track.enabled;
index ab2f246..99be9fb 100644 (file)
@@ -357,7 +357,7 @@ private:
 
 #if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     friend class WebCoreAVFResourceLoader;
-    HashMap<RetainPtr<AVAssetResourceLoadingRequest>, RefPtr<WebCoreAVFResourceLoader>> m_resourceLoaderMap;
+    HashMap<RetainPtr<CFTypeRef>, RefPtr<WebCoreAVFResourceLoader>> m_resourceLoaderMap;
     RetainPtr<WebCoreAVFLoaderDelegate> m_loaderDelegate;
     HashMap<String, RetainPtr<AVAssetResourceLoadingRequest>> m_keyURIToRequestMap;
     HashMap<String, RetainPtr<AVAssetResourceLoadingRequest>> m_sessionIDToRequestMap;
index f907c7f..dc3deeb 100644 (file)
@@ -271,7 +271,7 @@ SOFT_LINK_CONSTANT(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSStri
 #if ENABLE(DATACUE_VALUE)
 
 SOFT_LINK_CONSTANT(AVFoundation, AVMetadataKeySpaceQuickTimeUserData, NSString *)
-SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMetadataKeySpaceISOUserData, NSString*)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVMetadataKeySpaceISOUserData, NSString *)
 SOFT_LINK_CONSTANT(AVFoundation, AVMetadataKeySpaceQuickTimeMetadata, NSString *)
 SOFT_LINK_CONSTANT(AVFoundation, AVMetadataKeySpaceiTunes, NSString *)
 SOFT_LINK_CONSTANT(AVFoundation, AVMetadataKeySpaceID3, NSString *)
@@ -288,7 +288,7 @@ SOFT_LINK_CONSTANT(AVFoundation, AVMetadataKeySpaceID3, NSString *)
 
 SOFT_LINK_CONSTANT(AVFoundation, AVURLAssetBoundNetworkInterfaceName, NSString *)
 SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVURLAssetClientBundleIdentifierKey, NSString *)
-SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVURLAssetHTTPCookiesKey, NSString*)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVURLAssetHTTPCookiesKey, NSString *)
 SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVURLAssetRequiresCustomURLLoadingKey, NSString *)
 
 #define AVURLAssetBoundNetworkInterfaceName getAVURLAssetBoundNetworkInterfaceName()
@@ -1816,7 +1816,7 @@ bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetR
 #endif
 
     RefPtr<WebCoreAVFResourceLoader> resourceLoader = WebCoreAVFResourceLoader::create(this, avRequest);
-    m_resourceLoaderMap.add(avRequest, resourceLoader);
+    m_resourceLoaderMap.add((__bridge CFTypeRef)avRequest, resourceLoader);
     resourceLoader->startLoading();
     return true;
 }
@@ -1825,7 +1825,7 @@ void MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest(AVAssetResource
 {
     String scheme = [[[avRequest request] URL] scheme];
 
-    WebCoreAVFResourceLoader* resourceLoader = m_resourceLoaderMap.get(avRequest);
+    WebCoreAVFResourceLoader* resourceLoader = m_resourceLoaderMap.get((__bridge CFTypeRef)avRequest);
 
     if (resourceLoader)
         resourceLoader->stopLoading();
@@ -1833,7 +1833,7 @@ void MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest(AVAssetResource
 
 void MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest(AVAssetResourceLoadingRequest *avRequest)
 {
-    m_resourceLoaderMap.remove(avRequest);
+    m_resourceLoaderMap.remove((__bridge CFTypeRef)avRequest);
 }
 #endif
 
index 1e55190..0444d9a 100644 (file)
@@ -270,7 +270,7 @@ private:
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunknown-pragmas"
 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
-    HashMap<RetainPtr<AVSampleBufferAudioRenderer>, AudioRendererProperties> m_sampleBufferAudioRendererMap;
+    HashMap<RetainPtr<CFTypeRef>, AudioRendererProperties> m_sampleBufferAudioRendererMap;
     RetainPtr<AVSampleBufferRenderSynchronizer> m_synchronizer;
 #pragma clang diagnostic pop
     RetainPtr<id> m_timeJumpedObserver;
index 25a0d86..d402eaa 100644 (file)
@@ -321,8 +321,8 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::paused() const
 
 void MediaPlayerPrivateMediaSourceAVFObjC::setVolume(float volume)
 {
-    for (auto pair : m_sampleBufferAudioRendererMap)
-        [pair.key setVolume:volume];
+    for (auto key : m_sampleBufferAudioRendererMap.keys())
+        [(__bridge AVSampleBufferAudioRenderer *)key.get() setVolume:volume];
 }
 
 bool MediaPlayerPrivateMediaSourceAVFObjC::supportsScanning() const
@@ -332,8 +332,8 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::supportsScanning() const
 
 void MediaPlayerPrivateMediaSourceAVFObjC::setMuted(bool muted)
 {
-    for (auto pair : m_sampleBufferAudioRendererMap)
-        [pair.key setMuted:muted];
+    for (auto key : m_sampleBufferAudioRendererMap.keys())
+        [(__bridge AVSampleBufferAudioRenderer *)key.get() setMuted:muted];
 }
 
 FloatSize MediaPlayerPrivateMediaSourceAVFObjC::naturalSize() const
@@ -477,8 +477,8 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setRateDouble(double rate)
 void MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch(bool preservesPitch)
 {
     NSString *algorithm = preservesPitch ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed;
-    for (auto pair : m_sampleBufferAudioRendererMap)
-        [pair.key setAudioTimePitchAlgorithm:algorithm];
+    for (auto key : m_sampleBufferAudioRendererMap.keys())
+        [(__bridge AVSampleBufferAudioRenderer *)key.get() setAudioTimePitchAlgorithm:algorithm];
 }
 
 MediaPlayer::NetworkState MediaPlayerPrivateMediaSourceAVFObjC::networkState() const
@@ -776,7 +776,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableVideoFrame(bool flag)
 void MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableAudioSample(AVSampleBufferAudioRenderer* renderer, bool flag)
 #pragma clang diagnostic pop
 {
-    auto iter = m_sampleBufferAudioRendererMap.find(renderer);
+    auto iter = m_sampleBufferAudioRendererMap.find((__bridge CFTypeRef)renderer);
     if (iter == m_sampleBufferAudioRendererMap.end())
         return;
 
@@ -1020,11 +1020,9 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setNetworkState(MediaPlayer::NetworkS
 void MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer(AVSampleBufferAudioRenderer* audioRenderer)
 #pragma clang diagnostic pop
 {
-    if (m_sampleBufferAudioRendererMap.contains(audioRenderer))
+    if (!m_sampleBufferAudioRendererMap.add((__bridge CFTypeRef)audioRenderer, AudioRendererProperties()).isNewEntry)
         return;
 
-    m_sampleBufferAudioRendererMap.add(audioRenderer, AudioRendererProperties());
-
     [audioRenderer setMuted:m_player->muted()];
     [audioRenderer setVolume:m_player->volume()];
     [audioRenderer setAudioTimePitchAlgorithm:(m_player->preservesPitch() ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed)];
@@ -1039,7 +1037,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer(AVSampleBufferAudioR
 void MediaPlayerPrivateMediaSourceAVFObjC::removeAudioRenderer(AVSampleBufferAudioRenderer* audioRenderer)
 #pragma clang diagnostic pop
 {
-    auto iter = m_sampleBufferAudioRendererMap.find(audioRenderer);
+    auto iter = m_sampleBufferAudioRendererMap.find((__bridge CFTypeRef)audioRenderer);
     if (iter == m_sampleBufferAudioRendererMap.end())
         return;
 
index 2b09ffd..fb3268c 100644 (file)
@@ -30,8 +30,7 @@
 
 #import "GPUDevice.h"
 #import "Logging.h"
-#import <Metal/Metal.h>
-#import <QuartzCore/QuartzCore.h>
+#import "WebGPULayer.h"
 
 namespace WebCore {
 
index 8a0d020..0ae6afe 100644 (file)
@@ -64,7 +64,7 @@ using WebCore::VideoFullscreenChangeObserver;
 using WebCore::PlaybackSessionModel;
 
 @interface WebVideoViewContainer : NSView {
-    id <WebVideoViewContainerDelegate> _videoViewContainerDelegate;
+    __unsafe_unretained id <WebVideoViewContainerDelegate> _videoViewContainerDelegate;
 }
 
 @property (nonatomic, assign) id <WebVideoViewContainerDelegate> videoViewContainerDelegate;
index 0a7ac53..e695af0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if !PLATFORM(IOS)
-
-#ifndef WebCoreFullScreenPlaceholderView_h
-#define WebCoreFullScreenPlaceholderView_h
+#if PLATFORM(MAC)
 
 #import <wtf/RetainPtr.h>
 
@@ -34,15 +31,11 @@ WEBCORE_EXPORT @interface WebCoreFullScreenPlaceholderView : NSView {
 @private
     RetainPtr<NSVisualEffectView> _effectView;
     RetainPtr<NSTextField> _exitWarning;
-    NSObject* _target;
-    SEL _action;
+    __weak NSResponder *_target;
 }
-@property(retain) id contents;
-@property(assign) NSObject* target;
-@property(assign) SEL action;
+@property (nullable, strong) id contents;
+@property (nullable, weak) NSResponder *target;
 - (void)setExitWarningVisible:(BOOL)visible;
 @end
 
-#endif // WebCoreFullScreenPlaceholderView_h
-
-#endif // !PLATFORM(IOS)
+#endif
index 760f58e..8561aa0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
-#if !PLATFORM(IOS)
-
 #include "WebCoreFullScreenPlaceholderView.h"
 
+#if PLATFORM(MAC)
+
 #include "LocalizedStrings.h"
 #include "WebCoreFullScreenWarningView.h"
 #include <wtf/text/WTFString.h>
 
-using WebCore::clickToExitFullScreenText;
-@interface CAFilter : NSObject
-+ (CAFilter *)filterWithType:(NSString *)type;
-@end
-
 @implementation WebCoreFullScreenPlaceholderView
+
 - (id)initWithFrame:(NSRect)frameRect
 {
     self = [super initWithFrame:frameRect];
@@ -73,7 +69,7 @@ using WebCore::clickToExitFullScreenText;
     _exitWarning.get().editable = NO;
     _exitWarning.get().font = [NSFont systemFontOfSize:27];
     _exitWarning.get().selectable = NO;
-    _exitWarning.get().stringValue = clickToExitFullScreenText();
+    _exitWarning.get().stringValue = WebCore::clickToExitFullScreenText();
     _exitWarning.get().textColor = [NSColor tertiaryLabelColor];
     [_exitWarning sizeToFit];
 
@@ -86,9 +82,9 @@ using WebCore::clickToExitFullScreenText;
 }
 
 @synthesize target = _target;
-@synthesize action = _action;
 
 @dynamic contents;
+
 - (void)setContents:(id)contents
 {
     [[self layer] setContents:contents];
@@ -104,13 +100,10 @@ using WebCore::clickToExitFullScreenText;
     [_effectView setHidden:!visible];
 }
 
-- (void)mouseDown:(NSEvent *)theEvent
+- (void)mouseDown:(NSEvent *)event
 {
-    UNUSED_PARAM(theEvent);
-
-    if (!_target || !_action)
-        return;
-    [_target performSelector:_action];
+    UNUSED_PARAM(event);
+    [_target cancelOperation:self];
 }
 
 @end
index c5d9f91..53f02d4 100644 (file)
@@ -43,9 +43,8 @@ bool WebCoreObjCScheduleDeallocateOnMainThread(Class cls, id object)
         return false;
 
     callOnMainThread([cls, object] {
-        Method method = class_getInstanceMethod(cls, @selector(dealloc));
-        IMP imp = method_getImplementation(method);
-        wtfCallIMP<void>(imp, object, @selector(dealloc));
+        auto deallocSelector = sel_registerName("dealloc");
+        wtfCallIMP<void>(method_getImplementation(class_getInstanceMethod(cls, deallocSelector)), object, deallocSelector);
     });
 
     return true;
index fce796c..1272862 100644 (file)
@@ -249,7 +249,7 @@ private:
 #endif
 
 #if PLATFORM(COCOA)
-    void applySniffingPoliciesAndStoragePartitionIfNeeded(NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
+    NSURLRequest *applySniffingPoliciesAndStoragePartitionIfNeeded(NSURLRequest *, bool shouldContentSniff, bool shouldContentEncodingSniff);
 #endif
 
 #if USE(CURL)
index bbc1beb..918171c 100644 (file)
 #import <wtf/MainThread.h>
 #import <wtf/ProcessPrivilege.h>
 
-@interface WebNSHTTPCookieStorageInternal : NSObject {
+@interface WebNSHTTPCookieStorageDummyForInternalAccess : NSObject {
 @public
-    id internal;
+    NSHTTPCookieStorageInternal *_internal;
 }
 @end
 
-@implementation WebNSHTTPCookieStorageInternal
+@implementation WebNSHTTPCookieStorageDummyForInternalAccess
+@end
+
+@interface NSHTTPCookieStorageInternal : NSObject
+- (void)registerForPostingNotificationsWithContext:(NSHTTPCookieStorage *)context;
 @end
 
 @interface WebCookieObserverAdapter : NSObject {
@@ -105,10 +109,8 @@ void CookieStorageObserver::startObserving(WTF::Function<void()>&& callback)
 
     if (!m_hasRegisteredInternalsForNotifications) {
         if (m_cookieStorage.get() != [NSHTTPCookieStorage sharedHTTPCookieStorage]) {
-            auto selector = NSSelectorFromString(@"registerForPostingNotificationsWithContext:");
-            id internalObject = (static_cast<WebNSHTTPCookieStorageInternal *>(m_cookieStorage.get()))->internal;
-            RELEASE_ASSERT([internalObject respondsToSelector:selector]);
-            [internalObject performSelector:selector withObject:m_cookieStorage.get()];
+            auto internalObject = (static_cast<WebNSHTTPCookieStorageDummyForInternalAccess *>(m_cookieStorage.get()))->_internal;
+            [internalObject registerForPostingNotificationsWithContext:m_cookieStorage.get()];
         }
 
         m_hasRegisteredInternalsForNotifications = true;
index f42ac03..56d8799 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef WebCoreNSURLSession_h
-#define WebCoreNSURLSession_h
+#pragma once
 
 #import "SecurityOrigin.h"
 #import <Foundation/NSURLSession.h>
@@ -62,7 +61,7 @@ WEBCORE_EXPORT @interface WebCoreNSURLSession : NSObject {
     RetainPtr<id<NSURLSessionDelegate>> _delegate;
     RetainPtr<NSOperationQueue> _queue;
     NSString *_sessionDescription;
-    HashSet<RetainPtr<WebCoreNSURLSessionDataTask>> _dataTasks;
+    HashSet<RetainPtr<CFTypeRef>> _dataTasks;
     HashSet<RefPtr<WebCore::SecurityOrigin>> _origins;
     Lock _dataTasksLock;
     BOOL _invalidated;
@@ -108,7 +107,7 @@ WEBCORE_EXPORT @interface WebCoreNSURLSession : NSObject {
 @end
 
 @interface WebCoreNSURLSessionDataTask : NSObject {
-    WebCoreNSURLSession *_session;
+    __unsafe_unretained WebCoreNSURLSession *_session;
     RefPtr<WebCore::PlatformMediaResource> _resource;
     RetainPtr<NSURLResponse> _response;
     NSUInteger _taskIdentifier;
@@ -142,5 +141,3 @@ WEBCORE_EXPORT @interface WebCoreNSURLSession : NSObject {
 @end
 
 NS_ASSUME_NONNULL_END
-
-#endif
index de921f1..83a05da 100644 (file)
@@ -93,7 +93,7 @@ NS_ASSUME_NONNULL_END
     {
         Locker<Lock> locker(_dataTasksLock);
         for (auto& task : _dataTasks)
-            task.get().session = nil;
+            ((__bridge WebCoreNSURLSessionDataTask *)task.get()).session = nil;
     }
 
     callOnMainThread([loader = WTFMove(_loader)] {
@@ -116,8 +116,8 @@ NS_ASSUME_NONNULL_END
     {
         Locker<Lock> locker(_dataTasksLock);
 
-        ASSERT(_dataTasks.contains(task));
-        _dataTasks.remove(task);
+        ASSERT(_dataTasks.contains((__bridge CFTypeRef)task));
+        _dataTasks.remove((__bridge CFTypeRef)task);
         if (!_dataTasks.isEmpty() || !_invalidated)
             return;
     }
@@ -218,14 +218,14 @@ NS_ASSUME_NONNULL_END
 
 - (void)invalidateAndCancel
 {
-    Vector<RetainPtr<WebCoreNSURLSessionDataTask>> tasksCopy;
+    Vector<RetainPtr<CFTypeRef>> tasksCopy;
     {
         Locker<Lock> locker(_dataTasksLock);
         tasksCopy = copyToVector(_dataTasks);
     }
 
     for (auto& task : tasksCopy)
-        [task cancel];
+        [(__bridge WebCoreNSURLSessionDataTask *)task.get() cancel];
 
     [self finishTasksAndInvalidate];
 }
@@ -253,7 +253,7 @@ NS_ASSUME_NONNULL_END
         Locker<Lock> locker(_dataTasksLock);
         array = [NSMutableArray arrayWithCapacity:_dataTasks.size()];
         for (auto& task : _dataTasks)
-            [array addObject:task.get()];
+            [array addObject:(__bridge WebCoreNSURLSessionDataTask *)task.get()];
     }
     [self addDelegateOperation:^{
         completionHandler(array, nil, nil);
@@ -267,7 +267,7 @@ NS_ASSUME_NONNULL_END
         Locker<Lock> locker(_dataTasksLock);
         array = [NSMutableArray arrayWithCapacity:_dataTasks.size()];
         for (auto& task : _dataTasks)
-            [array addObject:task.get()];
+            [array addObject:(__bridge WebCoreNSURLSessionDataTask *)task.get()];
     }
     [self addDelegateOperation:^{
         completionHandler(array);
@@ -282,7 +282,7 @@ NS_ASSUME_NONNULL_END
     WebCoreNSURLSessionDataTask *task = [[WebCoreNSURLSessionDataTask alloc] initWithSession:self identifier:_nextTaskIdentifier++ request:request];
     {
         Locker<Lock> locker(_dataTasksLock);
-        _dataTasks.add(task);
+        _dataTasks.add((__bridge CFTypeRef)task);
     }
     return (NSURLSessionDataTask *)[task autorelease];
 }
@@ -295,7 +295,7 @@ NS_ASSUME_NONNULL_END
     WebCoreNSURLSessionDataTask *task = [[WebCoreNSURLSessionDataTask alloc] initWithSession:self identifier:_nextTaskIdentifier++ URL:url];
     {
         Locker<Lock> locker(_dataTasksLock);
-        _dataTasks.add(task);
+        _dataTasks.add((__bridge CFTypeRef)task);
     }
     return (NSURLSessionDataTask *)[task autorelease];
 }
index 8bac741..1b73407 100644 (file)
@@ -100,47 +100,51 @@ ResourceHandle::~ResourceHandle()
 }
 
 #if PLATFORM(IOS)
+
 static bool synchronousWillSendRequestEnabled()
 {
     static bool disabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitDisableSynchronousWillSendRequestPreferenceKey"] || IOSApplication::isIBooks();
     return !disabled;
 }
+
 #endif
 
 #if PLATFORM(COCOA)
-void ResourceHandle::applySniffingPoliciesAndStoragePartitionIfNeeded(NSURLRequest*& nsRequest, bool shouldContentSniff, bool shouldContentEncodingSniff)
+
+NSURLRequest *ResourceHandle::applySniffingPoliciesAndStoragePartitionIfNeeded(NSURLRequest *request, bool shouldContentSniff, bool shouldContentEncodingSniff)
 {
 #if !PLATFORM(MAC)
     UNUSED_PARAM(shouldContentEncodingSniff);
 #elif __MAC_OS_X_VERSION_MIN_REQUIRED < 101302
     shouldContentEncodingSniff = true;
 #endif
+
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     String storagePartition = d->m_context->storageSession().cookieStoragePartition(firstRequest(), std::nullopt, std::nullopt);
 #else
     String storagePartition;
 #endif
     if (shouldContentSniff && shouldContentEncodingSniff && storagePartition.isEmpty())
-        return;
+        return request;
 
-    auto mutableRequest = adoptNS([nsRequest mutableCopy]);
+    auto mutableRequest = adoptNS([request mutableCopy]);
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101302
     if (!shouldContentEncodingSniff)
-        [mutableRequest _setProperty:@(YES) forKey:(NSString *)kCFURLRequestContentDecoderSkipURLCheck];
+        [mutableRequest _setProperty:@(YES) forKey:(__bridge NSString *)kCFURLRequestContentDecoderSkipURLCheck];
 #endif
 
     if (!shouldContentSniff)
-        [mutableRequest _setProperty:@(NO) forKey:(NSString *)_kCFURLConnectionPropertyShouldSniff];
+        [mutableRequest _setProperty:@(NO) forKey:(__bridge NSString *)_kCFURLConnectionPropertyShouldSniff];
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     if (!storagePartition.isEmpty())
         [mutableRequest _setProperty:storagePartition forKey:@"__STORAGE_PARTITION_IDENTIFIER"];
 #endif
 
-    nsRequest = mutableRequest.autorelease();
-
+    return mutableRequest.autorelease();
 }
+
 #endif
 
 #if !PLATFORM(IOS)
@@ -180,7 +184,7 @@ void ResourceHandle::createNSURLConnection(id delegate, bool shouldUseCredential
     }
 
     NSURLRequest *nsRequest = firstRequest().nsURLRequest(HTTPBodyUpdatePolicy::UpdateHTTPBody);
-    applySniffingPoliciesAndStoragePartitionIfNeeded(nsRequest, shouldContentSniff, shouldContentEncodingSniff);
+    nsRequest = applySniffingPoliciesAndStoragePartitionIfNeeded(nsRequest, shouldContentSniff, shouldContentEncodingSniff);
 
     if (d->m_storageSession)
         nsRequest = [copyRequestWithStorageSession(d->m_storageSession.get(), nsRequest) autorelease];
@@ -211,7 +215,7 @@ void ResourceHandle::createNSURLConnection(id delegate, bool shouldUseCredential
 
     RetainPtr<CFDataRef> sourceApplicationAuditData = d->m_context->sourceApplicationAuditData();
     if (sourceApplicationAuditData)
-        [streamProperties setObject:(NSData *)sourceApplicationAuditData.get() forKey:@"kCFStreamPropertySourceApplication"];
+        [streamProperties setObject:(__bridge NSData *)sourceApplicationAuditData.get() forKey:@"kCFStreamPropertySourceApplication"];
 
 #if PLATFORM(IOS)
     NSMutableDictionary *propertyDictionary = [NSMutableDictionary dictionaryWithDictionary:connectionProperties];
@@ -309,13 +313,13 @@ void ResourceHandle::schedule(SchedulePair& pair)
     NSRunLoop *runLoop = pair.nsRunLoop();
     if (!runLoop)
         return;
-    [d->m_connection.get() scheduleInRunLoop:runLoop forMode:(NSString *)pair.mode()];
+    [d->m_connection.get() scheduleInRunLoop:runLoop forMode:(__bridge NSString *)pair.mode()];
 }
 
 void ResourceHandle::unschedule(SchedulePair& pair)
 {
     if (NSRunLoop *runLoop = pair.nsRunLoop())
-        [d->m_connection.get() unscheduleFromRunLoop:runLoop forMode:(NSString *)pair.mode()];
+        [d->m_connection.get() unscheduleFromRunLoop:runLoop forMode:(__bridge NSString *)pair.mode()];
 }
 
 id ResourceHandle::makeDelegate(bool shouldUseCredentialStorage, MessageQueue<Function<void()>>* queue)
index f265465..1dc6df7 100644 (file)
@@ -294,7 +294,7 @@ void adjustMIMETypeIfNecessary(CFURLResponseRef cfResponse, bool isMainResourceL
 
     if (!result) {
         auto url = CFURLResponseGetURL(cfResponse);
-        if ([(NSURL *)url isFileURL]) {
+        if ([(__bridge NSURL *)url isFileURL]) {
             RetainPtr<CFStringRef> extension = adoptCF(CFURLCopyPathExtension(url));
             if (extension) {
                 // <rdar://problem/7007389> CoreTypes UTI map is missing 100+ file extensions that GateKeeper knew about
index 03ae9fc..a3e96ed 100644 (file)
 #include "MockMediaPlayerMediaSource.h"
 #endif
 
-#if PLATFORM(MAC)
-#include "DictionaryLookup.h"
-#endif
-
 #if ENABLE(CONTENT_FILTERING)
 #include "MockContentFilterSettings.h"
 #endif
@@ -1858,23 +1854,12 @@ RefPtr<Range> Internals::rangeOfStringNearLocation(const Range& searchRange, con
     return findClosestPlainText(searchRange, text, { }, targetOffset);
 }
 
-ExceptionOr<RefPtr<Range>> Internals::rangeForDictionaryLookupAtLocation(int x, int y)
+#if !PLATFORM(MAC)
+ExceptionOr<RefPtr<Range>> Internals::rangeForDictionaryLookupAtLocation(int, int)
 {
-#if PLATFORM(MAC)
-    auto* document = contextDocument();
-    if (!document || !document->frame())
-        return Exception { InvalidAccessError };
-
-    document->updateLayoutIgnorePendingStylesheets();
-
-    HitTestResult result = document->frame()->mainFrame().eventHandler().hitTestResultAtPoint(IntPoint(x, y));
-    return DictionaryLookup::rangeAtHitTestResult(result, nullptr);
-#else
-    UNUSED_PARAM(x);
-    UNUSED_PARAM(y);
     return Exception { InvalidAccessError };
-#endif
 }
+#endif
 
 ExceptionOr<void> Internals::setDelegatesScrolling(bool enabled)
 {
index dde70b3..6fcdcbe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "Internals.h"
+#import "config.h"
+#import "Internals.h"
 
-#include "DOMURL.h"
-#include "WebCoreNSURLExtras.h"
-#include <wtf/SoftLinking.h>
+#import "DOMURL.h"
+#import "DictionaryLookup.h"
+#import "Document.h"
+#import "EventHandler.h"
+#import "HitTestResult.h"
+#import "Range.h"
+#import "WebCoreNSURLExtras.h"
+#import <wtf/SoftLinking.h>
 
 #if PLATFORM(IOS)
 SOFT_LINK_FRAMEWORK(UIKit)
@@ -42,7 +47,6 @@ String Internals::userVisibleString(const DOMURL& url)
     return WebCore::userVisibleString(url.href());
 }
 
-#if PLATFORM(COCOA)
 bool Internals::userPrefersReducedMotion() const
 {
 #if PLATFORM(IOS)
@@ -51,6 +55,23 @@ bool Internals::userPrefersReducedMotion() const
     return [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceMotion];
 #endif
 }
+
+#if PLATFORM(MAC)
+
+ExceptionOr<RefPtr<Range>> Internals::rangeForDictionaryLookupAtLocation(int x, int y)
+{
+    auto* document = contextDocument();
+    if (!document || !document->frame())
+        return Exception { InvalidAccessError };
+
+    document->updateLayoutIgnorePendingStylesheets();
+
+    HitTestResult result = document->frame()->mainFrame().eventHandler().hitTestResultAtPoint(IntPoint(x, y));
+    RefPtr<Range> range;
+    std::tie(range, std::ignore) = DictionaryLookup::rangeAtHitTestResult(result);
+    return WTFMove(range);
+}
+
 #endif
 
 }
index fcb37d1..082aa34 100644 (file)
@@ -1,3 +1,22 @@
+2018-07-28  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Update more WebCore Objective-C code to be ARC compatible
+        https://bugs.webkit.org/show_bug.cgi?id=188140
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController enterFullScreen:]): Removed the call to
+        setAction: since the full screen placeholder view now always uses the
+        cancelOperation: method.
+
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::lookupTextAtLocation): Updated to use the new
+        DictionaryLookup function that returns a tuple instead of using an out argument.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performDictionaryLookupAtLocation): Ditto.
+        (WebKit::WebPage::performDictionaryLookupForSelection): Ditto.
+
 2018-07-27  Chris Dumez  <cdumez@apple.com>
 
         Fix thread-safety issues related to RealtimeMediaSource::audioSamplesAvailable()
index 66b072f..47251d8 100644 (file)
@@ -288,10 +288,8 @@ static RetainPtr<CGImageRef> createImageWithCopiedData(CGImageRef sourceImage)
     _page->setSuppressVisibilityUpdates(true);
 
     // Swap the webView placeholder into place.
-    if (!_webViewPlaceholder) {
+    if (!_webViewPlaceholder)
         _webViewPlaceholder = adoptNS([[WebCoreFullScreenPlaceholderView alloc] initWithFrame:[_webView frame]]);
-        [_webViewPlaceholder setAction:@selector(cancelOperation:)];
-    }
     [_webViewPlaceholder setTarget:nil];
     [_webViewPlaceholder setContents:(__bridge id)webViewContents.get()];
     self.savedConstraints = _webView.superview.constraints;
index 5cc5424..9f0d948 100644 (file)
@@ -2088,8 +2088,9 @@ std::tuple<String, PDFSelection *, NSDictionary *> PDFPlugin::lookupTextAtLocati
         return { selection.string, selection, nil };
     }
 
-    NSDictionary *options = nil;
-    NSString *lookupText = DictionaryLookup::stringForPDFSelection(selection, &options);
+    NSString *lookupText;
+    NSDictionary *options;
+    std::tie(lookupText, options) = DictionaryLookup::stringForPDFSelection(selection);
     if (!lookupText.length)
         return { emptyString(), selection, nil };
 
index 8e2b50a..76279f8 100644 (file)
@@ -399,8 +399,9 @@ void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
 
     // Find the frame the point is over.
     HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(roundedIntPoint(floatPoint)));
-    NSDictionary *options = nil;
-    auto range = DictionaryLookup::rangeAtHitTestResult(result, &options);
+    RefPtr<Range> range;
+    NSDictionary *options;
+    std::tie(range, options) = DictionaryLookup::rangeAtHitTestResult(result);
     if (!range)
         return;
 
@@ -413,8 +414,10 @@ void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
 
 void WebPage::performDictionaryLookupForSelection(Frame& frame, const VisibleSelection& selection, TextIndicatorPresentationTransition presentationTransition)
 {
-    NSDictionary *options = nil;
-    if (auto selectedRange = DictionaryLookup::rangeForSelection(selection, &options))
+    RefPtr<Range> selectedRange;
+    NSDictionary *options;
+    std::tie(selectedRange, options) = DictionaryLookup::rangeForSelection(selection);
+    if (selectedRange)
         performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition);
 }
 
@@ -1052,9 +1055,7 @@ std::tuple<RefPtr<WebCore::Range>, NSDictionary *> WebPage::lookupTextAtLocation
 
     auto point = roundedIntPoint(locationInViewCoordinates);
     auto result = mainFrame.eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(point));
-    NSDictionary *options = nil;
-    auto range = DictionaryLookup::rangeAtHitTestResult(result, &options);
-    return { WTFMove(range), WTFMove(options) };
+    return DictionaryLookup::rangeAtHitTestResult(result);
 }
 
 void WebPage::immediateActionDidUpdate()
index 0e33756..04c985d 100644 (file)
@@ -1,3 +1,14 @@
+2018-07-28  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Update more WebCore Objective-C code to be ARC compatible
+        https://bugs.webkit.org/show_bug.cgi?id=188140
+
+        Reviewed by Sam Weinig.
+
+        * WebView/WebImmediateActionController.mm:
+        (-[WebImmediateActionController _animationControllerForText]): Updated to use the
+        new DictionaryLookup function that returns a tuple instead of using an out argument.
+
 2018-07-26  Andy VanWagoner  <andy@vanwagoner.family>
 
         [INTL] Remove INTL sub-feature compile flags
index a868575..926d4e4 100644 (file)
@@ -565,8 +565,9 @@ static IntRect elementBoundingBoxInWindowCoordinatesFromNode(Node* node)
     if (!frame)
         return nil;
 
-    NSDictionary *options = nil;
-    auto dictionaryRange = DictionaryLookup::rangeAtHitTestResult(_hitTestResult, &options);
+    RefPtr<Range> dictionaryRange;
+    NSDictionary *options;
+    std::tie(dictionaryRange, options) = DictionaryLookup::rangeAtHitTestResult(_hitTestResult);
     if (!dictionaryRange)
         return nil;