[Cocoa] Some -respondsToSelector: checks are unnecessary
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Feb 2017 22:01:24 +0000 (22:01 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Feb 2017 22:01:24 +0000 (22:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168183

Reviewed by Tim Horton.

Source/WebCore:

* English.lproj/Localizable.strings: Removed a string that’s no longer needed after the
  change to WebKit2/Platform/mac/MenuUtilities.mm.

* editing/mac/DictionaryLookup.mm:
(WebCore::showPopupOrCreateAnimationController): Removed check whether
  LULookupDefinitionModule responds to +showDefinitionForTerm:relativeToRect:ofView:options:.

* platform/cocoa/NetworkExtensionContentFilter.mm:
(WebCore::NetworkExtensionContentFilter::initialize): Changed to use
  -[NEFilterSource setSourceAppIdentifier:], without checking, instead of
  -setSourceAppBundleID:, which does not exist.

* platform/cocoa/ScrollController.mm:
(systemUptime): Deleted.
(WebCore::ScrollController::snapRubberBand): Use -[NSProcessInfo systemUptime] directly.

* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
(WebCore::MediaPlaybackTargetPickerMac::showPlaybackTargetPicker): Remove unnecessary check.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenMode): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck): Replaced
  -respondsToSelector: check with -isKindOfClass: check corresponding to the above cast.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep): Removed unnecessary
  check.

* platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm:
(WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer): Removed unnecessary checks.

* platform/graphics/mac/WebGLLayer.mm:
(-[WebGLLayer initWithGraphicsContext3D:]): Ditto.

* platform/mac/PlatformEventFactoryMac.mm:
(WebCore::typeForEvent): Removed check whether NSMenu responds to +menuTypeForEvent: and
  all code to handle that case that it doesn’t.

* platform/mac/WebVideoFullscreenController.mm:
(-[WebVideoFullscreenController applicationDidResignActive:]): Removed check whether
  NSWindow responds to -isOnActiveSpace.
(-[WebVideoFullscreenController updateMenuAndDockForFullscreen]): Removed check whether
  NSApplication responds to -setPresentationOptions:

* platform/mac/WebVideoFullscreenInterfaceMac.mm:
(-[WebVideoFullscreenInterfaceMacObjC updateIsPlaying:newPlaybackRate:]): Removed
  unnecessary -respondsToSelector: check.
(-[WebVideoFullscreenInterfaceMacObjC setVideoDimensions:]): Ditto.
(-[WebVideoFullscreenInterfaceMacObjC setUpPIPForVideoView:withFrame:inWindow:]): Ditto.

* platform/spi/cf/CFNetworkSPI.h: Moved declarations of
  -[NSURLCache _initWithMemoryCapacity:diskCapacity:relativePath:] and
  -[NSURLCache _CFURLCache] to the !USE(APPLE_INTERNAL_SDK) section.

* platform/spi/cocoa/NEFilterSourceSPI.h: Added declaration of NEFilterSource’
  sourceAppIdentifier property to the !USE(APPLE_INTERNAL_SDK) section and deleted
  unconditional declaration of sourceAppBundleID property, which doesn’t exist.

* platform/spi/cocoa/QuartzCoreSPI.h: Removed redundant declarations.

* platform/spi/ios/DataDetectorsUISPI.h: Moved declarations of DDDetectionController methods
  from WebKit2/UIProcess/ios/{WKActionSheetAssistant,WKContentViewInteraction}.mm to here.
  Removed an unused declaration.

* platform/spi/mac/LookupSPI.h: Moved redundant declarations into the
  !USE(APPLE_INTERNAL_SDK) section.

* platform/spi/mac/NSMenuSPI.h: Changed to import NSMenu_Private.h when using the
  Apple internal SDK. Cleaned up the declarations for the other case.

* platform/spi/mac/TUCallSPI.h: Changed to import TUCall_Strings.h when use the Apple
  internal SDK.

Source/WebKit/mac:

* WebView/WebFullScreenController.mm:
(-[WebFullScreenController applicationDidResignActive:]): Removed check whether NSWindow
  responds to -isOnActiveSpace.
(-[WebFullScreenController exitFullScreen]): Ditto.
(-[WebFullScreenController _updateMenuAndDockForFullScreen]): Removed check whether
  NSApplication responds to -setPresentationOptions.

* WebView/WebHTMLView.mm:
(createShareMenuItem): Removed unnecessary -respondsToSelector: check.
(-[WebHTMLView otherMouseDown:]): Ditto.

* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _clearImmediateActionState]): Ditto.
(-[WebImmediateActionController _animationControllerForDataDetectedText]): Ditto.

* WebView/WebView.mm:
(-[WebView _didStartProvisionalLoadForFrame:]): Removed redundant nil check.
(+[WebView _setCacheModel:]): Removed unnecessary -respondsToSelector: check.

Source/WebKit2:

* Platform/mac/LayerHostingContext.mm:
(WebKit::LayerHostingContext::setColorMatchUntaggedContent): Removed unnecessary
  -respondsToSelector: check.
(WebKit::LayerHostingContext::colorMatchUntaggedContent): Ditto.

* Platform/mac/MenuUtilities.mm:
(WebKit::menuItemTitleForTelephoneNumberGroup): Ditto.

* Platform/spi/ios/UIKitSPI.h: Moved declaration of
  -[UIScrollView _isInterruptingDeceleration] from WKWebView.mm to the
  !USE(APPLE_INTERNAL_SDK) section here.

* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::setSharedHTTPCookieStorage): Removed unnecessary -respondsToSelector:
  check.

* Shared/mac/WebEventFactory.mm:
(WebKit::typeForEvent): Ditto.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _updateVisibleContentRectAfterScrollInView:]): Ditto.

* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup): Ditto.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::dismissContentRelativeChildWindowsFromViewOnly): Ditto.

* UIProcess/WKImagePreviewViewController.mm:
(-[WKImagePreviewViewController previewActions]): Removed check whether _WKElementAction
  responds to -runActionWithElementInfo:.

* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant showDataDetectorsSheet]): Ditto.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _lookup:]): Ditto.
(-[WKContentView _share:]): Ditto.
(-[WKContentView _addShortcut:]): Ditto.
(-[WKContentView _promptForReplace:]): Ditto.
(-[WKContentView _transliterateChinese:]): Ditto.
(-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Removed call to
  -[UIKeyboardImpl didHandleWebKeyEvent], which is a no-op.
(-[WKContentView _interpretKeyEvent:isCharEvent:]): Removed unnecessary -respondsToSelector:
  check.
(-[WKContentView _dataForPreviewItemController:atPosition:type:]): Ditto.

* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::createFence): Ditto.

* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _animationControllerForDataDetectedText]): Ditto.

* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::createShareMenuItem): Ditto.

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

39 files changed:
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebCore/editing/mac/DictionaryLookup.mm
Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.mm
Source/WebCore/platform/cocoa/ScrollController.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm
Source/WebCore/platform/graphics/mac/WebGLLayer.mm
Source/WebCore/platform/mac/PlatformEventFactoryMac.mm
Source/WebCore/platform/mac/WebVideoFullscreenController.mm
Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm
Source/WebCore/platform/spi/cf/CFNetworkSPI.h
Source/WebCore/platform/spi/cocoa/NEFilterSourceSPI.h
Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h
Source/WebCore/platform/spi/ios/DataDetectorsUISPI.h
Source/WebCore/platform/spi/mac/LookupSPI.h
Source/WebCore/platform/spi/mac/NSMenuSPI.h
Source/WebCore/platform/spi/mac/TUCallSPI.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebFullScreenController.mm
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebImmediateActionController.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/mac/LayerHostingContext.mm
Source/WebKit2/Platform/mac/MenuUtilities.mm
Source/WebKit2/Platform/spi/ios/UIKitSPI.h
Source/WebKit2/Shared/mac/ChildProcessMac.mm
Source/WebKit2/Shared/mac/WebEventFactory.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit2/UIProcess/WKImagePreviewViewController.mm
Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm
Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm

index 8ae32d2..2d3a3ac 100644 (file)
@@ -1,3 +1,82 @@
+2017-02-12  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] Some -respondsToSelector: checks are unnecessary
+        https://bugs.webkit.org/show_bug.cgi?id=168183
+
+        Reviewed by Tim Horton.
+
+        * English.lproj/Localizable.strings: Removed a string that’s no longer needed after the
+          change to WebKit2/Platform/mac/MenuUtilities.mm.
+
+        * editing/mac/DictionaryLookup.mm:
+        (WebCore::showPopupOrCreateAnimationController): Removed check whether
+          LULookupDefinitionModule responds to +showDefinitionForTerm:relativeToRect:ofView:options:.
+
+        * platform/cocoa/NetworkExtensionContentFilter.mm:
+        (WebCore::NetworkExtensionContentFilter::initialize): Changed to use
+          -[NEFilterSource setSourceAppIdentifier:], without checking, instead of
+          -setSourceAppBundleID:, which does not exist.
+
+        * platform/cocoa/ScrollController.mm:
+        (systemUptime): Deleted.
+        (WebCore::ScrollController::snapRubberBand): Use -[NSProcessInfo systemUptime] directly.
+
+        * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
+        (WebCore::MediaPlaybackTargetPickerMac::showPlaybackTargetPicker): Remove unnecessary check.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenMode): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck): Replaced
+          -respondsToSelector: check with -isKindOfClass: check corresponding to the above cast.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep): Removed unnecessary
+          check.
+
+        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm:
+        (WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer): Removed unnecessary checks.
+
+        * platform/graphics/mac/WebGLLayer.mm:
+        (-[WebGLLayer initWithGraphicsContext3D:]): Ditto.
+
+        * platform/mac/PlatformEventFactoryMac.mm:
+        (WebCore::typeForEvent): Removed check whether NSMenu responds to +menuTypeForEvent: and
+          all code to handle that case that it doesn’t.
+
+        * platform/mac/WebVideoFullscreenController.mm:
+        (-[WebVideoFullscreenController applicationDidResignActive:]): Removed check whether
+          NSWindow responds to -isOnActiveSpace.
+        (-[WebVideoFullscreenController updateMenuAndDockForFullscreen]): Removed check whether
+          NSApplication responds to -setPresentationOptions:
+
+        * platform/mac/WebVideoFullscreenInterfaceMac.mm:
+        (-[WebVideoFullscreenInterfaceMacObjC updateIsPlaying:newPlaybackRate:]): Removed
+          unnecessary -respondsToSelector: check.
+        (-[WebVideoFullscreenInterfaceMacObjC setVideoDimensions:]): Ditto.
+        (-[WebVideoFullscreenInterfaceMacObjC setUpPIPForVideoView:withFrame:inWindow:]): Ditto.
+
+        * platform/spi/cf/CFNetworkSPI.h: Moved declarations of
+          -[NSURLCache _initWithMemoryCapacity:diskCapacity:relativePath:] and
+          -[NSURLCache _CFURLCache] to the !USE(APPLE_INTERNAL_SDK) section.
+
+        * platform/spi/cocoa/NEFilterSourceSPI.h: Added declaration of NEFilterSource’
+          sourceAppIdentifier property to the !USE(APPLE_INTERNAL_SDK) section and deleted
+          unconditional declaration of sourceAppBundleID property, which doesn’t exist.
+
+        * platform/spi/cocoa/QuartzCoreSPI.h: Removed redundant declarations.
+
+        * platform/spi/ios/DataDetectorsUISPI.h: Moved declarations of DDDetectionController methods
+          from WebKit2/UIProcess/ios/{WKActionSheetAssistant,WKContentViewInteraction}.mm to here.
+          Removed an unused declaration.
+
+        * platform/spi/mac/LookupSPI.h: Moved redundant declarations into the
+          !USE(APPLE_INTERNAL_SDK) section.
+
+        * platform/spi/mac/NSMenuSPI.h: Changed to import NSMenu_Private.h when using the
+          Apple internal SDK. Cleaned up the declarations for the other case.
+
+        * platform/spi/mac/TUCallSPI.h: Changed to import TUCall_Strings.h when use the Apple
+          internal SDK.
+
 2017-02-11  Sam Weinig  <sam@webkit.org>
 
         Remove the remaining functions out of JSDOMBinding
index 27313a9..c5586d8 100644 (file)
 /* Option in segmented control for inserting a bulleted list in text editing */
 "Bulleted list" = "Bulleted list";
 
-/* menu item title for phone number */
-"Call Using iPhone:" = "Call Using iPhone:";
-
 /* Title for Cancel button label in button bar */
 "Cancel button label in button bar" = "Cancel";
 
index f28e12c..85a5a37 100644 (file)
@@ -221,18 +221,16 @@ static PlatformAnimationController showPopupOrCreateAnimationController(bool cre
         textIndicatorInstallationCallback(textIndicator.get());
         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
 
-        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
-            FloatRect firstTextRectInViewCoordinates = textIndicator.get().textRectsInBoundingRectCoordinates()[0];
-            FloatRect textBoundingRectInViewCoordinates = textIndicator.get().textBoundingRectInRootViewCoordinates();
-            if (rootViewToViewConversionCallback)
-                textBoundingRectInViewCoordinates = rootViewToViewConversionCallback(textBoundingRectInViewCoordinates);
-            firstTextRectInViewCoordinates.moveBy(textBoundingRectInViewCoordinates.location());
-            if (createAnimationController)
-                return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:firstTextRectInViewCoordinates ofView:view options:mutableOptions.get()];
-
-            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:firstTextRectInViewCoordinates ofView:view options:mutableOptions.get()];
-            return nil;
-        }
+        FloatRect firstTextRectInViewCoordinates = textIndicator.get().textRectsInBoundingRectCoordinates()[0];
+        FloatRect textBoundingRectInViewCoordinates = textIndicator.get().textBoundingRectInRootViewCoordinates();
+        if (rootViewToViewConversionCallback)
+            textBoundingRectInViewCoordinates = rootViewToViewConversionCallback(textBoundingRectInViewCoordinates);
+        firstTextRectInViewCoordinates.moveBy(textBoundingRectInViewCoordinates.location());
+        if (createAnimationController)
+            return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:firstTextRectInViewCoordinates ofView:view options:mutableOptions.get()];
+
+        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:firstTextRectInViewCoordinates ofView:view options:mutableOptions.get()];
+        return nil;
     }
 
     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
index d403fb5..aac8787 100644 (file)
@@ -75,9 +75,7 @@ void NetworkExtensionContentFilter::initialize(const URL* url)
     ASSERT_UNUSED(url, !url);
     m_neFilterSource = adoptNS([allocNEFilterSourceInstance() initWithDecisionQueue:m_queue.get()]);
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
-    // FIXME: Remove the -respondsToSelector: check once -setSourceAppBundleID: is in an SDK (<rdar://problem/29147174>).
-    if ([m_neFilterSource respondsToSelector:@selector(setSourceAppBundleID:)])
-        [m_neFilterSource setSourceAppBundleID:applicationBundleIdentifier()];
+    [m_neFilterSource setSourceAppIdentifier:applicationBundleIdentifier()];
 #endif
 #else
     ASSERT_ARG(url, url);
index a87d33b..37fabfa 100644 (file)
 
 #if ENABLE(RUBBER_BANDING) || ENABLE(CSS_SCROLL_SNAP)
 
-#if PLATFORM(MAC)
-static NSTimeInterval systemUptime()
-{
-    if ([[NSProcessInfo processInfo] respondsToSelector:@selector(systemUptime)])
-        return [[NSProcessInfo processInfo] systemUptime];
-
-    // Get how long system has been up. Found by looking getting "boottime" from the kernel.
-    static struct timeval boottime = {0, 0};
-    if (!boottime.tv_sec) {
-        int mib[2] = {CTL_KERN, KERN_BOOTTIME};
-        size_t size = sizeof(boottime);
-        if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0))
-            boottime.tv_sec = 0;
-    }
-    struct timeval now;
-    if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) {
-        struct timeval uptime;
-        timersub(&now, &boottime, &uptime);
-        NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6);
-        return result;
-    }
-    return 0;
-}
-#endif
-
 namespace WebCore {
 
 #if ENABLE(RUBBER_BANDING)
@@ -427,7 +402,7 @@ void ScrollController::stopSnapRubberbandTimer()
 
 void ScrollController::snapRubberBand()
 {
-    CFTimeInterval timeDelta = systemUptime() - m_lastMomentumScrollTimestamp;
+    CFTimeInterval timeDelta = [NSProcessInfo processInfo].systemUptime - m_lastMomentumScrollTimestamp;
     if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
         m_momentumVelocity = FloatSize();
 
index 22b04a7..a37eef8 100644 (file)
@@ -116,12 +116,9 @@ void MediaPlaybackTargetPickerMac::showPlaybackTargetPicker(const FloatRect& loc
 
     LOG(Media, "MediaPlaybackTargetPickerMac::showPlaybackTargetPicker - checkActiveRoute = %i", (int)checkActiveRoute);
 
-    AVOutputDeviceMenuControllerType *picker = devicePicker();
-    if (![picker respondsToSelector:@selector(showMenuForRect:appearanceName:allowReselectionOfSelectedOutputDevice:)])
-        return;
-
     m_showingMenu = true;
-    if ([picker showMenuForRect:location appearanceName:NSAppearanceNameVibrantLight allowReselectionOfSelectedOutputDevice:!checkActiveRoute]) {
+
+    if ([devicePicker() showMenuForRect:location appearanceName:NSAppearanceNameVibrantLight allowReselectionOfSelectedOutputDevice:!checkActiveRoute]) {
         if (!checkActiveRoute)
             currentDeviceDidChange();
     }
index 70e6221..c8323f2 100644 (file)
@@ -757,8 +757,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer()
     m_videoFullscreenLayerManager->setVideoLayer(m_videoLayer.get(), defaultSize);
 
 #if PLATFORM(IOS)
-    if ([m_videoLayer respondsToSelector:@selector(setPIPModeEnabled:)])
-        [m_videoLayer setPIPModeEnabled:(player()->fullscreenMode() & MediaPlayer::VideoFullscreenModePictureInPicture)];
+    [m_videoLayer setPIPModeEnabled:(player()->fullscreenMode() & MediaPlayer::VideoFullscreenModePictureInPicture)];
 #endif
 #else
     [m_videoLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())];
@@ -1257,8 +1256,7 @@ void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenGravity(MediaPlayer::
 void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenMode(MediaPlayer::VideoFullscreenMode mode)
 {
 #if PLATFORM(IOS)
-    if (m_videoLayer && [m_videoLayer respondsToSelector:@selector(setPIPModeEnabled:)])
-        [m_videoLayer setPIPModeEnabled:(mode & MediaPlayer::VideoFullscreenModePictureInPicture)];
+    [m_videoLayer setPIPModeEnabled:(mode & MediaPlayer::VideoFullscreenModePictureInPicture)];
     updateDisableExternalPlayback();
 #else
     UNUSED_PARAM(mode);
@@ -2244,7 +2242,7 @@ bool MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck() const
         return false;
 
     WebCoreNSURLSession *session = (WebCoreNSURLSession *)resourceLoader.URLSession;
-    if ([session respondsToSelector:@selector(didPassCORSAccessChecks)])
+    if ([session isKindOfClass:[WebCoreNSURLSession class]])
         return session.didPassCORSAccessChecks;
 #endif
     return false;
@@ -3199,8 +3197,7 @@ URL MediaPlayerPrivateAVFoundationObjC::resolvedURL() const
 void MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep(bool flag)
 {
 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
-    if (m_avPlayer && [m_avPlayer respondsToSelector:@selector(_setPreventsSleepDuringVideoPlayback:)])
-        [m_avPlayer _setPreventsSleepDuringVideoPlayback:flag];
+    [m_avPlayer _setPreventsSleepDuringVideoPlayback:flag];
 #else
     UNUSED_PARAM(flag);
 #endif
index 12fc307..cec1581 100644 (file)
@@ -112,10 +112,8 @@ void VideoFullscreenLayerManager::setVideoFullscreenLayer(PlatformLayer *videoFu
         CAContext *newContext = [m_videoLayer context];
         if (oldContext && newContext && oldContext != newContext) {
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
-            if ([oldContext respondsToSelector:@selector(setCommitPriority:)]) {
-                [oldContext setCommitPriority:0];
-                [newContext setCommitPriority:1];
-            }
+            oldContext.commitPriority = 0;
+            newContext.commitPriority = 1;
 #endif
             mach_port_t fencePort = [oldContext createFencePort];
             [newContext setFencePort:fencePort];
index fcda701..47e6d4d 100644 (file)
@@ -56,8 +56,7 @@ using namespace WebCore;
 #if PLATFORM(MAC)
     self.contentsScale = _devicePixelRatio;
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
-    if ([self respondsToSelector:@selector(setColorspace:)])
-        [self setColorspace:sRGBColorSpaceRef()];
+    self.colorspace = sRGBColorSpaceRef();
 #endif
 #endif
     return self;
index a9a99f3..6ba76f4 100644 (file)
@@ -671,16 +671,7 @@ static inline OptionSet<PlatformEvent::Modifier> modifiersForEvent(NSEvent *even
 
 static int typeForEvent(NSEvent *event)
 {
-    if ([NSMenu respondsToSelector:@selector(menuTypeForEvent:)])
-        return static_cast<int>([NSMenu menuTypeForEvent:event]);
-
-    if (mouseButtonForEvent(event) == RightButton)
-        return static_cast<int>(NSMenuTypeContextMenu);
-
-    if (mouseButtonForEvent(event) == LeftButton && modifiersForEvent(event).contains(PlatformEvent::Modifier::CtrlKey))
-        return static_cast<int>(NSMenuTypeContextMenu);
-
-    return static_cast<int>(NSMenuTypeNone);
+    return static_cast<int>([NSMenu menuTypeForEvent:event]);
 }
     
 class PlatformMouseEventBuilder : public PlatformMouseEvent {
index 8e3dfbe..699a369 100644 (file)
@@ -219,16 +219,13 @@ SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
 - (void)applicationDidResignActive:(NSNotification*)notification
 {   
     UNUSED_PARAM(notification);
-    // Check to see if the fullscreenWindow is on the active space; this function is available
-    // on 10.6 and later, so default to YES if the function is not available:
     NSWindow* fullscreenWindow = [self fullscreenWindow];
-    BOOL isOnActiveSpace = ([fullscreenWindow respondsToSelector:@selector(isOnActiveSpace)] ? [fullscreenWindow isOnActiveSpace] : YES);
 
     // Replicate the QuickTime Player (X) behavior when losing active application status:
     // Is the fullscreen screen the main screen? (Note: this covers the case where only a 
     // single screen is available.)  Is the fullscreen screen on the current space? IFF so, 
     // then exit fullscreen mode.    
-    if ([fullscreenWindow screen] == [[NSScreen screens] objectAtIndex:0] && isOnActiveSpace)
+    if (fullscreenWindow.screen == [NSScreen screens][0] && fullscreenWindow.onActiveSpace)
          [self requestExitFullscreenWithAnimation:NO];
 }
          
@@ -353,10 +350,7 @@ static NSWindow *createBackgroundFullscreenWindow(NSRect frame, int level)
             options |= NSApplicationPresentationAutoHideDock;
     }
 
-    if ([NSApp respondsToSelector:@selector(setPresentationOptions:)])
-        [NSApp setPresentationOptions:options];
-    else
-        SetSystemUIMode(_isEndingFullscreen ? kUIModeNormal : kUIModeAllHidden, 0);
+    NSApp.presentationOptions = options;
 }
 
 - (void)updatePowerAssertions
index 734a661..ec6fa3c 100644 (file)
@@ -170,16 +170,14 @@ enum class PIPState {
 {
     _playing = isPlaying && playbackRate;
 
-    if ([_pipViewController respondsToSelector:@selector(setPlaying:)])
-        [_pipViewController setPlaying:_playing];
+    [_pipViewController setPlaying:_playing];
 }
 
 - (void)setVideoDimensions:(NSSize)videoDimensions
 {
     _videoDimensions = videoDimensions;
 
-    if ([_pipViewController respondsToSelector:@selector(setAspectRatio:)])
-        [_pipViewController setAspectRatio:_videoDimensions];
+    [_pipViewController setAspectRatio:_videoDimensions];
 }
 
 - (void)setUpPIPForVideoView:(NSView *)videoView withFrame:(NSRect)frame inWindow:(NSWindow *)window
@@ -190,10 +188,8 @@ enum class PIPState {
 
     _pipViewController = adoptNS([[getPIPViewControllerClass() alloc] init]);
     [_pipViewController setDelegate:self];
-    if ([_pipViewController respondsToSelector:@selector(setUserCanResize:)])
-        [_pipViewController setUserCanResize:YES];
-    if ([_pipViewController respondsToSelector:@selector(setPlaying:)])
-        [_pipViewController setPlaying:_playing];
+    [_pipViewController setUserCanResize:YES];
+    [_pipViewController setPlaying:_playing];
     [self setVideoDimensions:NSEqualSizes(_videoDimensions, NSZeroSize) ? frame.size : _videoDimensions];
     if (_webVideoFullscreenInterfaceMac && _webVideoFullscreenInterfaceMac->webVideoFullscreenModel())
         _webVideoFullscreenInterfaceMac->webVideoFullscreenModel()->setVideoLayerGravity(WebVideoFullscreenModel::VideoGravityResizeAspectFill);
index 33db751..961a4dd 100644 (file)
@@ -83,6 +83,11 @@ typedef void (^CFCachedURLResponseCallBackBlock)(CFCachedURLResponseRef);
 #endif
 
 #if defined(__OBJC__)
+@interface NSURLCache ()
+-(instancetype)_initWithMemoryCapacity:(NSUInteger)memoryCapacity diskCapacity:(NSUInteger)diskCapacity relativePath:(NSString *)path;
+- (CFURLCacheRef)_CFURLCache;
+@end
+
 @interface NSURLRequest ()
 + (NSArray *)allowsSpecificHTTPSCertificateForHost:(NSString *)host;
 + (void)setAllowsSpecificHTTPSCertificate:(NSArray *)allow forHost:(NSString *)host;
@@ -190,15 +195,6 @@ CFURLResponseRef CFURLResponseCreateWithHTTPResponse(CFAllocatorRef, CFURLRef, C
 
 WTF_EXTERN_C_END
 
-// FIXME: We should only forward declare this SPI when building for iOS without the Apple Internal SDK.
-// As a workaround for <rdar://problem/19025016>, we must forward declare this SPI regardless of whether
-// we are building with the Apple Internal SDK.
-#if defined(__OBJC__) && PLATFORM(IOS)
-@interface NSURLCache ()
--(id)_initWithMemoryCapacity:(NSUInteger)memoryCapacity diskCapacity:(NSUInteger)diskCapacity relativePath:(NSString *)path;
-@end
-#endif
-
 #if defined(__OBJC__) && !USE(APPLE_INTERNAL_SDK)
 enum : NSUInteger {
     NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3,
index 685fc2f..7958c81 100644 (file)
@@ -73,15 +73,11 @@ typedef void (^NEFilterSourceDecisionHandler)(NEFilterSourceStatus, NSDictionary
 - (void)receivedData:(NSData *)data decisionHandler:(NEFilterSourceDecisionHandler)decisionHandler;
 - (void)finishedLoadingWithDecisionHandler:(NEFilterSourceDecisionHandler)decisionHandler;
 - (void)remediateWithDecisionHandler:(NEFilterSourceDecisionHandler)decisionHandler;
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+@property (copy) NSString *sourceAppIdentifier;
+#endif
 @end
 
 #endif
 
 #endif // !USE(APPLE_INTERNAL_SDK)
-
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
-// FIXME: Confine this to the !USE(APPLE_INTERNAL_SDK) section once this is defined in an SDK (<rdar://problem/29147174>).
-@interface NEFilterSource (WKStaging)
-@property (copy) NSString *sourceAppBundleID;
-@end
-#endif
index 10a8aaf..baa91d8 100644 (file)
@@ -33,6 +33,7 @@
 
 #ifdef __OBJC__
 
+#import <QuartzCore/CAContext.h>
 #import <QuartzCore/CALayerHost.h>
 #import <QuartzCore/CALayerPrivate.h>
 #import <QuartzCore/QuartzCorePrivate.h>
 #import <QuartzCore/CADisplay.h>
 #endif
 
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
-@interface CAContext ()
-- (void)setCommitPriority:(uint32_t)commitPriority;
-@end
-#endif
-
 #endif // __OBJC__
 
 #else
@@ -62,6 +57,7 @@
 - (uint32_t)createImageSlot:(CGSize)size hasAlpha:(BOOL)flag;
 - (void)deleteSlot:(uint32_t)name;
 - (void)invalidate;
+- (void)invalidateFences;
 - (mach_port_t)createFencePort;
 - (void)setFencePort:(mach_port_t)port;
 - (void)setFencePort:(mach_port_t)port commitHandler:(void(^)(void))block;
@@ -198,13 +194,6 @@ CFTypeID CAMachPortGetTypeID(void);
 
 WTF_EXTERN_C_END
 
-// FIXME: Move this into the APPLE_INTERNAL_SDK block once it's in an SDK.
-@interface CAContext (AdditionalDetails)
-#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
-- (void)invalidateFences;
-#endif
-@end
-
 extern NSString * const kCATiledLayerRemoveImmediately;
 
 extern NSString * const kCAFilterColorInvert;
index 35b4cd3..4233259 100644 (file)
@@ -35,6 +35,8 @@
 
 #else
 
+#import <WebCore/DataDetectorsCoreSPI.h>
+
 @interface DDAction : NSObject
 @end
 
 + (DDDetectionController *)sharedController;
 + (NSArray *)tapAndHoldSchemes;
 - (void)performAction:(DDAction *)action fromAlertController:(UIAlertController *)alertController interactionDelegate:(id <DDDetectionControllerInteractionDelegate>)interactionDelegate;
+- (NSArray *)actionsForURL:(NSURL *)url identifier:(NSString *)identifier selectedText:(NSString *)selectedText results:(NSArray *)results context:(NSDictionary *)context;
+- (DDResultRef)resultForURL:(NSURL *)url identifier:(NSString *)identifier selectedText:(NSString *)selectedText results:(NSArray *)results context:(NSDictionary *)context extendedContext:(NSDictionary **)extendedContext;
 @end
 
 #endif
 
-@interface DDDetectionController (DetailsToBeRemoved)
-// FIXME: This will be removed as soon as <rdar://problem/16346913> is fixed.
-- (NSArray *)actionsForAnchor:(id)anchor url:(NSURL *)targetURL forFrame:(id)frame;
-@end
-
 SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsUI)
 SOFT_LINK_CLASS(DataDetectorsUI, DDDetectionController)
 SOFT_LINK_CONSTANT(DataDetectorsUI, kDataDetectorsLeadingText, const NSString *)
index 5cae094..e74c547 100644 (file)
@@ -42,24 +42,13 @@ SOFT_LINK_CLASS_OPTIONAL(Lookup, LULookupDefinitionModule)
 
 + (NSRange)tokenRangeForString:(NSString *)string range:(NSRange)range options:(NSDictionary **)options;
 + (void)showDefinitionForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options;
++ (void)showDefinitionForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options;
 + (void)hideDefinition;
-
-@end
-
-#endif // !USE(APPLE_INTERNAL_SDK)
-
-@interface LULookupDefinitionModule ()
-
 + (id<NSImmediateActionAnimationController>)lookupAnimationControllerForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options;
-
 + (id<NSImmediateActionAnimationController>)lookupAnimationControllerForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options;
 
 @end
 
-@interface LULookupDefinitionModule ()
-
-+ (void)showDefinitionForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options;
-
-@end
+#endif // !USE(APPLE_INTERNAL_SDK)
 
 #endif // PLATFORM(MAC)
index c2e2746..c79533a 100644 (file)
 
 #if PLATFORM(MAC)
 
-// FIXME: We should just include the appropriate internal headers.
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppKit/NSMenu_Private.h>
+
+#else
 
 typedef NS_ENUM(NSInteger, NSMenuType) {
     NSMenuTypeNone = 0,
     NSMenuTypeContextMenu,
 };
 
-@interface NSMenu (Private)
+@interface NSMenu ()
 + (NSMenuType)menuTypeForEvent:(NSEvent *)event;
 @end
 
 @class QLPreviewMenuItem;
 
-@interface NSMenuItem (Private)
+@interface NSMenuItem () <NSUserInterfaceItemIdentification>
 + (QLPreviewMenuItem *)standardQuickLookMenuItem;
 + (NSMenuItem *)standardShareMenuItemWithItems:(NSArray *)items;
 @end
 
-@interface NSMenuItem () <NSUserInterfaceItemIdentification>
-@end
+#endif
 
 #endif
index 9b0f882..0ca94ac 100644 (file)
 #import "SoftLinking.h"
 #import <objc/runtime.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <TelephonyUtilities/TUCall_Strings.h>
+
+#else
+
 @interface TUCall : NSObject
 @end
 
@@ -33,5 +39,7 @@
 + (NSString *)supplementalDialTelephonyCallString;
 @end
 
+#endif
+
 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(TelephonyUtilities)
 SOFT_LINK_CLASS(TelephonyUtilities, TUCall)
index 910c9f8..08959fa 100644 (file)
@@ -1,3 +1,29 @@
+2017-02-12  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] Some -respondsToSelector: checks are unnecessary
+        https://bugs.webkit.org/show_bug.cgi?id=168183
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebFullScreenController.mm:
+        (-[WebFullScreenController applicationDidResignActive:]): Removed check whether NSWindow
+          responds to -isOnActiveSpace.
+        (-[WebFullScreenController exitFullScreen]): Ditto.
+        (-[WebFullScreenController _updateMenuAndDockForFullScreen]): Removed check whether
+          NSApplication responds to -setPresentationOptions.
+
+        * WebView/WebHTMLView.mm:
+        (createShareMenuItem): Removed unnecessary -respondsToSelector: check.
+        (-[WebHTMLView otherMouseDown:]): Ditto.
+
+        * WebView/WebImmediateActionController.mm:
+        (-[WebImmediateActionController _clearImmediateActionState]): Ditto.
+        (-[WebImmediateActionController _animationControllerForDataDetectedText]): Ditto.
+
+        * WebView/WebView.mm:
+        (-[WebView _didStartProvisionalLoadForFrame:]): Removed redundant nil check.
+        (+[WebView _setCacheModel:]): Removed unnecessary -respondsToSelector: check.
+
 2017-02-10  Daniel Bates  <dabates@apple.com>
 
         Detach frame from document when entering page cache
index 3de34d5..4bcf499 100644 (file)
@@ -75,10 +75,6 @@ static NSRect convertRectToScreen(NSWindow *window, NSRect rect)
     return [window convertRectToScreen:rect];
 }
 
-@interface NSWindow(IsOnActiveSpaceAdditionForTigerAndLeopard)
-- (BOOL)isOnActiveSpace;
-@end
-
 @implementation WebFullScreenController
 
 #pragma mark -
@@ -165,16 +161,13 @@ static NSRect convertRectToScreen(NSWindow *window, NSRect rect)
 
 - (void)applicationDidResignActive:(NSNotification*)notification
 {   
-    // Check to see if the fullscreenWindow is on the active space; this function is available
-    // on 10.6 and later, so default to YES if the function is not available:
     NSWindow* fullscreenWindow = [self window];
-    BOOL isOnActiveSpace = ([fullscreenWindow respondsToSelector:@selector(isOnActiveSpace)] ? [fullscreenWindow isOnActiveSpace] : YES);
 
     // Replicate the QuickTime Player (X) behavior when losing active application status:
     // Is the fullscreen screen the main screen? (Note: this covers the case where only a 
     // single screen is available.)  Is the fullscreen screen on the current space? IFF so, 
     // then exit fullscreen mode. 
-    if ([fullscreenWindow screen] == [[NSScreen screens] objectAtIndex:0] && isOnActiveSpace)
+    if (fullscreenWindow.screen == [NSScreen screens][0] && fullscreenWindow.onActiveSpace)
          [self cancelOperation:self];
 }
 
@@ -325,7 +318,7 @@ static NSRect convertRectToScreen(NSWindow *window, NSRect rect)
     [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone];
     // If the user has moved the fullScreen window into a new space, temporarily change
     // the collectionBehavior of the webView's window so that it is pulled into the active space:
-    if (!([webWindow respondsToSelector:@selector(isOnActiveSpace)] ? [webWindow isOnActiveSpace] : YES)) {
+    if (!webWindow.onActiveSpace) {
         NSWindowCollectionBehavior behavior = [webWindow collectionBehavior];
         [webWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
         [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]];
@@ -430,10 +423,7 @@ static NSRect convertRectToScreen(NSWindow *window, NSRect rect)
             options |= NSApplicationPresentationAutoHideDock;
     }
     
-    if ([NSApp respondsToSelector:@selector(setPresentationOptions:)])
-        [NSApp setPresentationOptions:options];
-    else
-        SetSystemUIMode(_isFullScreen ? kUIModeAllHidden : kUIModeNormal, 0);
+    NSApp.presentationOptions = options;
 }
 
 #pragma mark -
index 538ba48..605c02d 100644 (file)
@@ -3872,9 +3872,6 @@ static RetainPtr<NSArray> fixMenusReceivedFromOldClients(NSArray *delegateSuppli
 
 static RetainPtr<NSMenuItem> createShareMenuItem(const HitTestResult& hitTestResult)
 {
-    if (![[NSMenuItem class] respondsToSelector:@selector(standardShareMenuItemWithItems:)])
-        return nil;
-
     auto items = adoptNS([[NSMutableArray alloc] init]);
 
     if (!hitTestResult.absoluteLinkURL().isEmpty()) {
@@ -6104,8 +6101,7 @@ static BOOL writingDirectionKeyBindingsEnabled()
 #if !PLATFORM(IOS)
 - (void)otherMouseDown:(NSEvent *)event
 {
-    if ([event buttonNumber] != 2 || ([NSMenu respondsToSelector:@selector(menuTypeForEvent:)]
-        && [NSMenu menuTypeForEvent:event] == NSMenuTypeContextMenu)) {
+    if (event.buttonNumber != 2 || [NSMenu menuTypeForEvent:event] == NSMenuTypeContextMenu) {
         [super otherMouseDown:event];
         return;
     }
index 1f4a50d..8f3d9d7 100644 (file)
@@ -128,8 +128,7 @@ using namespace WebCore;
         return;
 
     DDActionsManager *actionsManager = [getDDActionsManagerClass() sharedManager];
-    if ([actionsManager respondsToSelector:@selector(requestBubbleClosureUnanchorOnFailure:)])
-        [actionsManager requestBubbleClosureUnanchorOnFailure:YES];
+    [actionsManager requestBubbleClosureUnanchorOnFailure:YES];
 
     if (_currentActionContext && _hasActivatedActionContext) {
         _hasActivatedActionContext = NO;
@@ -439,10 +438,8 @@ static IntRect elementBoundingBoxInWindowCoordinatesFromNode(Node* node)
 
     [actionContext setAltMode:YES];
     [actionContext setImmediate:YES];
-    if ([[getDDActionsManagerClass() sharedManager] respondsToSelector:@selector(hasActionsForResult:actionContext:)]) {
-        if (![[getDDActionsManagerClass() sharedManager] hasActionsForResult:[actionContext mainResult] actionContext:actionContext.get()])
-            return nil;
-    }
+    if (![[getDDActionsManagerClass() sharedManager] hasActionsForResult:[actionContext mainResult] actionContext:actionContext.get()])
+        return nil;
 
     auto indicator = TextIndicator::createWithRange(*detectedDataRange, TextIndicatorOptionDefault, TextIndicatorPresentationTransition::FadeIn);
 
index df6e35b..eab4e0f 100644 (file)
@@ -506,10 +506,6 @@ static const char webViewIsOpen[] = "At least one WebView is still open.";
 - (void)_preferencesChanged:(WebPreferences *)preferences;
 - (void)_updateScreenScaleFromWindow;
 @end
-
-@interface NSURLCache (WebPrivate)
-- (CFURLCacheRef)_CFURLCache;
-@end
 #endif
 
 #if !PLATFORM(IOS)
@@ -3331,7 +3327,7 @@ static inline IMP getMethod(id o, SEL s)
     Document* document = core([frame DOMDocument]);
     if (Element* element = document ? document->webkitCurrentFullScreenElement() : 0) {
         SEL selector = @selector(webView:closeFullScreenWithListener:);
-        if (_private->UIDelegate && [_private->UIDelegate respondsToSelector:selector]) {
+        if ([_private->UIDelegate respondsToSelector:selector]) {
             WebKitFullScreenListener *listener = [[WebKitFullScreenListener alloc] initWithElement:element];
             CallUIDelegate(self, selector, listener);
             [listener release];
@@ -8583,7 +8579,7 @@ static WebFrameView *containingFrameView(NSView *view)
 #if PLATFORM(IOS)
     nsurlCacheMemoryCapacity = std::max(nsurlCacheMemoryCapacity, [nsurlCache memoryCapacity]);
     CFURLCacheRef cfCache;
-    if ([nsurlCache respondsToSelector:@selector(_CFURLCache)] && (cfCache = [nsurlCache _CFURLCache]))
+    if ((cfCache = [nsurlCache _CFURLCache]))
         CFURLCacheSetMemoryCapacity(cfCache, nsurlCacheMemoryCapacity);
     else
         [nsurlCache setMemoryCapacity:nsurlCacheMemoryCapacity];
index 5e827cb..a2c01f3 100644 (file)
@@ -1,3 +1,66 @@
+2017-02-12  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] Some -respondsToSelector: checks are unnecessary
+        https://bugs.webkit.org/show_bug.cgi?id=168183
+
+        Reviewed by Tim Horton.
+
+        * Platform/mac/LayerHostingContext.mm:
+        (WebKit::LayerHostingContext::setColorMatchUntaggedContent): Removed unnecessary
+          -respondsToSelector: check.
+        (WebKit::LayerHostingContext::colorMatchUntaggedContent): Ditto.
+
+        * Platform/mac/MenuUtilities.mm:
+        (WebKit::menuItemTitleForTelephoneNumberGroup): Ditto.
+
+        * Platform/spi/ios/UIKitSPI.h: Moved declaration of
+          -[UIScrollView _isInterruptingDeceleration] from WKWebView.mm to the
+          !USE(APPLE_INTERNAL_SDK) section here.
+
+        * Shared/mac/ChildProcessMac.mm:
+        (WebKit::ChildProcess::setSharedHTTPCookieStorage): Removed unnecessary -respondsToSelector:
+          check.
+
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::typeForEvent): Ditto.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _updateVisibleContentRectAfterScrollInView:]): Ditto.
+
+        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup): Ditto.
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::dismissContentRelativeChildWindowsFromViewOnly): Ditto.
+
+        * UIProcess/WKImagePreviewViewController.mm:
+        (-[WKImagePreviewViewController previewActions]): Removed check whether _WKElementAction
+          responds to -runActionWithElementInfo:.
+
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant showDataDetectorsSheet]): Ditto.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _lookup:]): Ditto.
+        (-[WKContentView _share:]): Ditto.
+        (-[WKContentView _addShortcut:]): Ditto.
+        (-[WKContentView _promptForReplace:]): Ditto.
+        (-[WKContentView _transliterateChinese:]): Ditto.
+        (-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Removed call to
+          -[UIKeyboardImpl didHandleWebKeyEvent], which is a no-op.
+        (-[WKContentView _interpretKeyEvent:isCharEvent:]): Removed unnecessary -respondsToSelector:
+          check.
+        (-[WKContentView _dataForPreviewItemController:atPosition:type:]): Ditto.
+
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::createFence): Ditto.
+
+        * UIProcess/mac/WKImmediateActionController.mm:
+        (-[WKImmediateActionController _animationControllerForDataDetectedText]): Ditto.
+
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::createShareMenuItem): Ditto.
+
 2017-02-12  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Unreviewed, minor documentation improvements
index 54fcb90..5d02d05 100644 (file)
@@ -105,15 +105,12 @@ CGColorSpaceRef LayerHostingContext::colorSpace() const
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
 void LayerHostingContext::setColorMatchUntaggedContent(bool colorMatchUntaggedContent)
 {
-    if ([m_context respondsToSelector:@selector(setColorMatchUntaggedContent:)])
-        [m_context setColorMatchUntaggedContent:colorMatchUntaggedContent];
+    [m_context setColorMatchUntaggedContent:colorMatchUntaggedContent];
 }
 
 bool LayerHostingContext::colorMatchUntaggedContent() const
 {
-    if ([m_context respondsToSelector:@selector(colorMatchUntaggedContent)])
-        return [m_context colorMatchUntaggedContent];
-    return false;
+    return [m_context colorMatchUntaggedContent];
 }
 #endif
 
index 07a77a6..06c9ed7 100644 (file)
@@ -43,9 +43,7 @@ namespace WebKit {
 
 NSString *menuItemTitleForTelephoneNumberGroup()
 {
-    if ([getTUCallClass() respondsToSelector:@selector(supplementalDialTelephonyCallString)])
-        return [getTUCallClass() supplementalDialTelephonyCallString];
-    return WEB_UI_STRING("Call Using iPhone:", "menu item title for phone number");
+    return [getTUCallClass() supplementalDialTelephonyCallString];
 }
 
 NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber)
index e83ae81..69d4d7b 100644 (file)
@@ -308,6 +308,7 @@ typedef enum {
 @property (nonatomic, readonly, getter=_isAnimatingScroll) BOOL isAnimatingScroll;
 @property (nonatomic) CGFloat horizontalScrollDecelerationFactor;
 @property (nonatomic) CGFloat verticalScrollDecelerationFactor;
+@property (nonatomic, readonly) BOOL _isInterruptingDeceleration;
 @end
 
 @interface NSString (UIKitDetails)
@@ -521,6 +522,8 @@ typedef NS_ENUM(NSInteger, UIWKGestureType) {
 - (void)selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:(UIWKSelectionTouch)touch;
 - (void)showDictionaryFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
 - (void)showShareSheetFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
+- (void)showTextServiceFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
+- (void)lookup:(NSString *)textWithContext withRange:(NSRange)range fromRect:(CGRect)presentationRect;
 @property (nonatomic, readonly) UILongPressGestureRecognizer *selectionLongPressRecognizer;
 @end
 
@@ -558,12 +561,17 @@ typedef NS_ENUM(NSInteger, UIWKHandlePosition) {
 @interface UIWKTextInteractionAssistant : UITextInteractionAssistant <UIResponderStandardEditActions>
 @end
 
-@interface UIWKTextInteractionAssistant (UIWKTextInteractionAssistantDetails)
+@interface UIWKTextInteractionAssistant ()
 - (void)selectionChangedWithGestureAt:(CGPoint)point withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)gestureState withFlags:(UIWKSelectionFlags)flags;
 - (void)showDictionaryFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
 - (void)selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:(UIWKSelectionTouch)touch;
 - (void)showTextStyleOptions;
 - (void)hideTextStyleOptions;
+- (void)lookup:(NSString *)textWithContext withRange:(NSRange)range fromRect:(CGRect)presentationRect;
+- (void)showShareSheetFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
+- (void)showTextServiceFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
+- (void)scheduleReplacementsForText:(NSString *)text;
+- (void)scheduleChineseTransliterationForText:(NSString *)text;
 
 @property (nonatomic, readonly, assign) UILongPressGestureRecognizer *loupeGesture;
 @property (nonatomic, readonly, assign) UITapGestureRecognizer *singleTapGesture;
index fa625e3..3e8e722 100644 (file)
@@ -180,10 +180,6 @@ void ChildProcess::initializeSandbox(const ChildProcessInitializationParameters&
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
 void ChildProcess::setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier)
 {
-    // FIXME: Remove the runtime check when it's not needed (soon).
-    if (![NSHTTPCookieStorage respondsToSelector:@selector(_setSharedHTTPCookieStorage:)])
-        return;
-
     RetainPtr<CFDataRef> cookieStorageData = adoptCF(CFDataCreate(kCFAllocatorDefault, identifier.data(), identifier.size()));
     RetainPtr<CFHTTPCookieStorageRef> uiProcessCookieStorage = adoptCF(CFHTTPCookieStorageCreateFromIdentifyingData(kCFAllocatorDefault, cookieStorageData.get()));
     [NSHTTPCookieStorage _setSharedHTTPCookieStorage:adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:uiProcessCookieStorage.get()]).get()];
index 8b06ee7..e0b2305 100644 (file)
@@ -328,16 +328,7 @@ static inline WebEvent::Modifiers modifiersForEvent(NSEvent *event)
 
 static int typeForEvent(NSEvent *event)
 {
-    if ([NSMenu respondsToSelector:@selector(menuTypeForEvent:)])
-        return static_cast<int>([NSMenu menuTypeForEvent:event]);
-    
-    if (mouseButtonForEvent(event) == WebMouseEvent::RightButton)
-        return static_cast<int>(NSMenuTypeContextMenu);
-    
-    if (mouseButtonForEvent(event) == WebMouseEvent::LeftButton && (modifiersForEvent(event) & WebEvent::ControlKey))
-        return static_cast<int>(NSMenuTypeContextMenu);
-    
-    return static_cast<int>(NSMenuTypeNone);
+    return static_cast<int>([NSMenu menuTypeForEvent:event]);
 }
 
 bool WebEventFactory::shouldBeHandledAsContextClick(const WebCore::PlatformMouseEvent& event)
index 9f0c875..d16f3cb 100644 (file)
@@ -142,7 +142,6 @@ CFStringRef kAXSAllowForceWebScalingEnabledNotification;
 @interface UIScrollView (UIScrollViewInternal)
 - (void)_adjustForAutomaticKeyboardInfo:(NSDictionary*)info animated:(BOOL)animated lastAdjustment:(CGFloat*)lastAdjustment;
 - (BOOL)_isScrollingToTop;
-- (BOOL)_isInterruptingDeceleration;
 - (CGPoint)_animatedTargetOffset;
 @end
 
@@ -2181,8 +2180,8 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff
         isStableState = ![self _scrollViewIsRubberBanding];
 
     // FIXME: this can be made static after we stop supporting iOS 8.x.
-    if (isStableState && [scrollView respondsToSelector:@selector(_isInterruptingDeceleration)])
-        isStableState = ![scrollView performSelector:@selector(_isInterruptingDeceleration)];
+    if (isStableState)
+        isStableState = !scrollView._isInterruptingDeceleration;
 
     if (NSNumber *stableOverride = self._stableStateOverride)
         isStableState = stableOverride.boolValue;
index ce86660..950320d 100644 (file)
@@ -227,13 +227,6 @@ void WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard(const Str
 void WebPaymentCoordinatorProxy::platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler)
 {
     auto passLibrary = adoptNS([allocPKPassLibraryInstance() init]);
-    if (![passLibrary respondsToSelector:@selector(openPaymentSetupForMerchantIdentifier:domain:completion:)]) {
-        RunLoop::main().dispatch([completionHandler] {
-            completionHandler(false);
-        });
-        return;
-    }
-
     [passLibrary openPaymentSetupForMerchantIdentifier:merchantIdentifier domain:domainName completion:[completionHandler](BOOL result) {
         RunLoop::main().dispatch([completionHandler, result] {
             completionHandler(result);
index 0088644..eca9ea4 100644 (file)
@@ -3112,11 +3112,8 @@ void WebViewImpl::dismissContentRelativeChildWindowsFromViewOnly()
     if (m_view.window.isKeyWindow || hasActiveImmediateAction) {
         WebCore::DictionaryLookup::hidePopup();
 
-        if (DataDetectorsLibrary()) {
-            DDActionsManager *actionsManager = [getDDActionsManagerClass() sharedManager];
-            if ([actionsManager respondsToSelector:@selector(requestBubbleClosureUnanchorOnFailure:)])
-                [actionsManager requestBubbleClosureUnanchorOnFailure:YES];
-        }
+        if (DataDetectorsLibrary())
+            [[getDDActionsManagerClass() sharedManager] requestBubbleClosureUnanchorOnFailure:YES];
     }
 
     clearTextIndicatorWithAnimation(WebCore::TextIndicatorWindowDismissalAnimation::FadeOut);
index 1c2f567..0036b90 100644 (file)
@@ -97,8 +97,7 @@ static CGSize _scaleSizeWithinSize(CGSize source, CGSize destination)
     NSMutableArray<UIViewControllerPreviewAction *> *previewActions = [NSMutableArray array];
     for (_WKElementAction *imageAction in _imageActions.get()) {
         UIViewControllerPreviewAction *previewAction = [UIViewControllerPreviewAction actionWithTitle:imageAction.title handler:^(UIViewControllerPreviewAction *action, UIViewController *previewViewController) {
-            if ([imageAction respondsToSelector:@selector(runActionWithElementInfo:)])
-                [imageAction runActionWithElementInfo:_activatedElementInfo.get()];
+            [imageAction runActionWithElementInfo:_activatedElementInfo.get()];
         }];
 
         [previewActions addObject:previewAction];
index 315d7b4..dd16956 100644 (file)
@@ -59,10 +59,6 @@ SOFT_LINK_PRIVATE_FRAMEWORK(TCC)
 SOFT_LINK(TCC, TCCAccessPreflight, TCCAccessPreflightResult, (CFStringRef service, CFDictionaryRef options), (service, options))
 SOFT_LINK_CONSTANT(TCC, kTCCServicePhotos, CFStringRef)
 
-@interface DDDetectionController (StagingToRemove)
-- (NSArray *)actionsForURL:(NSURL *)url identifier:(NSString *)identifier selectedText:(NSString *)selectedText results:(NSArray *)results context:(NSDictionary *)context;
-@end
-
 using namespace WebKit;
 
 #if HAVE(APP_LINKS)
@@ -480,29 +476,25 @@ static LSAppLink *appLinkForURL(NSURL *url)
         return;
 
     DDDetectionController *controller = [getDDDetectionControllerClass() sharedController];
-    NSArray *dataDetectorsActions = nil;
-    if ([controller respondsToSelector:@selector(actionsForURL:identifier:selectedText:results:context:)]) {
-        NSDictionary *context = nil;
-        NSString *textAtSelection = nil;
-        RetainPtr<NSMutableDictionary> extendedContext;
-
-        if ([delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)])
-            context = [delegate dataDetectionContextForActionSheetAssistant:self];
-        if ([delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)])
-            textAtSelection = [delegate selectedTextForActionSheetAssistant:self];
-        if (!positionInformation.textBefore.isEmpty() || !positionInformation.textAfter.isEmpty()) {
-            extendedContext = adoptNS([@{
-                getkDataDetectorsLeadingText() : positionInformation.textBefore,
-                getkDataDetectorsTrailingText() : positionInformation.textAfter,
-            } mutableCopy]);
-            
-            if (context)
-                [extendedContext addEntriesFromDictionary:context];
-            context = extendedContext.get();
-        }
-        dataDetectorsActions = [controller actionsForURL:targetURL identifier:positionInformation.dataDetectorIdentifier selectedText:textAtSelection results:positionInformation.dataDetectorResults.get() context:context];
-    } else
-        dataDetectorsActions = [controller actionsForAnchor:nil url:targetURL forFrame:nil];
+    NSDictionary *context = nil;
+    NSString *textAtSelection = nil;
+    RetainPtr<NSMutableDictionary> extendedContext;
+
+    if ([delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)])
+        context = [delegate dataDetectionContextForActionSheetAssistant:self];
+    if ([delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)])
+        textAtSelection = [delegate selectedTextForActionSheetAssistant:self];
+    if (!positionInformation.textBefore.isEmpty() || !positionInformation.textAfter.isEmpty()) {
+        extendedContext = adoptNS([@{
+            getkDataDetectorsLeadingText() : positionInformation.textBefore,
+            getkDataDetectorsTrailingText() : positionInformation.textAfter,
+        } mutableCopy]);
+        
+        if (context)
+            [extendedContext addEntriesFromDictionary:context];
+        context = extendedContext.get();
+    }
+    NSArray *dataDetectorsActions = [controller actionsForURL:targetURL identifier:positionInformation.dataDetectorIdentifier selectedText:textAtSelection results:positionInformation.dataDetectorResults.get() context:context];
     if ([dataDetectorsActions count] == 0)
         return;
 
index 5293afa..9a4f16a 100644 (file)
@@ -239,28 +239,6 @@ const CGFloat minimumTapHighlightRadius = 2.0;
 - (void)scheduleReanalysis;
 @end
 
-@interface UITextInteractionAssistant (StagingToRemove)
-- (void)scheduleReplacementsForText:(NSString *)text;
-- (void)showTextServiceFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
-- (void)scheduleChineseTransliterationForText:(NSString *)text;
-- (void)showShareSheetFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
-- (void)lookup:(NSString *)textWithContext fromRect:(CGRect)presentationRect;
-- (void)lookup:(NSString *)textWithContext withRange:(NSRange)range fromRect:(CGRect)presentationRect;
-@end
-
-@interface UIWKSelectionAssistant (StagingToRemove)
-- (void)showTextServiceFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
-- (void)lookup:(NSString *)textWithContext fromRect:(CGRect)presentationRect;
-- (void)lookup:(NSString *)textWithContext withRange:(NSRange)range fromRect:(CGRect)presentationRect;
-@end
-
-@interface UIKeyboardImpl (StagingToRemove)
-- (void)didHandleWebKeyEvent;
-- (void)didHandleWebKeyEvent:(WebIOSEvent *)event;
-- (void)deleteFromInputWithFlags:(NSUInteger)flags;
-- (void)addInputString:(NSString *)string withFlags:(NSUInteger)flags withInputManagerHint:(NSString *)hint;
-@end
-
 @interface UIView (UIViewInternalHack)
 + (BOOL)_addCompletion:(void(^)(BOOL))completion;
 @end
@@ -272,10 +250,6 @@ const CGFloat minimumTapHighlightRadius = 2.0;
 @end
 #endif
 
-@interface DDDetectionController (StagingToRemove)
-- (DDResultRef)resultForURL:(NSURL *)url identifier:(NSString *)identifier selectedText:(NSString *)selectedText results:(NSArray *)results context:(NSDictionary *)context extendedContext:(NSDictionary **)extendedContext;
-@end
-
 @interface WKFocusedElementInfo : NSObject <_WKFocusedElementInfo>
 - (instancetype)initWithAssistedNodeInformation:(const AssistedNodeInformation&)information isUserInitiated:(BOOL)isUserInitiated;
 @end
@@ -1879,15 +1853,9 @@ static void cancelPotentialTapIfNecessary(WKContentView* contentView)
         
         String selectionContext = textBefore + selectedText + textAfter;
         if (view->_textSelectionAssistant) {
-            if ([view->_textSelectionAssistant respondsToSelector:@selector(lookup:withRange:fromRect:)])
-                [view->_textSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
-            else
-                [view->_textSelectionAssistant lookup:selectedText fromRect:presentationRect];
+            [view->_textSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
         } else {
-            if ([view->_webSelectionAssistant respondsToSelector:@selector(lookup:withRange:fromRect:)])
-                [view->_webSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
-            else
-                [view->_webSelectionAssistant lookup:selectedText fromRect:presentationRect];
+            [view->_webSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
         }
     });
 }
@@ -1903,18 +1871,18 @@ static void cancelPotentialTapIfNecessary(WKContentView* contentView)
 
         CGRect presentationRect = view->_page->editorState().postLayoutData().selectionRects[0].rect();
 
-        if (view->_textSelectionAssistant && [view->_textSelectionAssistant respondsToSelector:@selector(showShareSheetFor:fromRect:)])
+        if (view->_textSelectionAssistant)
             [view->_textSelectionAssistant showShareSheetFor:string fromRect:presentationRect];
-        else if (view->_webSelectionAssistant && [view->_webSelectionAssistant respondsToSelector:@selector(showShareSheetFor:fromRect:)])
+        else if (view->_webSelectionAssistant)
             [view->_webSelectionAssistant showShareSheetFor:string fromRect:presentationRect];
     });
 }
 
 - (void)_addShortcut:(id)sender
 {
-    if (_textSelectionAssistant && [_textSelectionAssistant respondsToSelector:@selector(showTextServiceFor:fromRect:)])
+    if (_textSelectionAssistant)
         [_textSelectionAssistant showTextServiceFor:[self selectedText] fromRect:_page->editorState().postLayoutData().selectionRects[0].rect()];
-    else if (_webSelectionAssistant && [_webSelectionAssistant respondsToSelector:@selector(showTextServiceFor:fromRect:)])
+    else if (_webSelectionAssistant)
         [_webSelectionAssistant showTextServiceFor:[self selectedText] fromRect:_page->editorState().postLayoutData().selectionRects[0].rect()];
 }
 
@@ -1944,14 +1912,12 @@ static void cancelPotentialTapIfNecessary(WKContentView* contentView)
     if (wordAtSelection.isEmpty())
         return;
 
-    if ([_textSelectionAssistant respondsToSelector:@selector(scheduleReplacementsForText:)])
-        [_textSelectionAssistant scheduleReplacementsForText:wordAtSelection];
+    [_textSelectionAssistant scheduleReplacementsForText:wordAtSelection];
 }
 
 - (void)_transliterateChinese:(id)sender
 {
-    if ([_textSelectionAssistant respondsToSelector:@selector(scheduleChineseTransliterationForText:)])
-        [_textSelectionAssistant scheduleChineseTransliterationForText:_page->editorState().postLayoutData().wordAtSelection];
+    [_textSelectionAssistant scheduleChineseTransliterationForText:_page->editorState().postLayoutData().wordAtSelection];
 }
 
 - (void)_reanalyze:(id)sender
@@ -3385,14 +3351,6 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
         return;
     }
         
-    if (event.type == WebEventKeyDown) {
-        // FIXME: This is only for staging purposes.
-        if ([[UIKeyboardImpl sharedInstance] respondsToSelector:@selector(didHandleWebKeyEvent:)])
-            [[UIKeyboardImpl sharedInstance] didHandleWebKeyEvent:event];
-        else
-            [[UIKeyboardImpl sharedInstance] didHandleWebKeyEvent];
-    }
-
     // If we aren't interacting with editable content, we still need to call [super _handleKeyUIEvent:]
     // so that keyboard repeat will work correctly. If we are interacting with editable content,
     // we already did so in _handleKeyUIEvent.
@@ -3506,21 +3464,14 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
     case kWebBackspaceKey:
     case kWebDeleteKey:
         if (contentEditable) {
-            // FIXME: remove deleteFromInput once UIKit adopts deleteFromInputWithFlags
-            if ([keyboard respondsToSelector:@selector(deleteFromInputWithFlags:)])
-                [keyboard deleteFromInputWithFlags:event.keyboardFlags];
-            else
-                [keyboard deleteFromInput];
+            [keyboard deleteFromInputWithFlags:event.keyboardFlags];
             return YES;
         }
         break;
 
     case kWebSpaceKey:
         if (contentEditable && isCharEvent) {
-            if ([keyboard respondsToSelector:@selector(addInputString:withFlags:withInputManagerHint:)])
-                [keyboard addInputString:event.characters withFlags:event.keyboardFlags withInputManagerHint:event.inputManagerHint];
-            else
-                [keyboard addInputString:event.characters withFlags:event.keyboardFlags];
+            [keyboard addInputString:event.characters withFlags:event.keyboardFlags withInputManagerHint:event.inputManagerHint];
             return YES;
         }
         break;
@@ -3540,10 +3491,7 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
 
     default:
         if (contentEditable && isCharEvent) {
-            if ([keyboard respondsToSelector:@selector(addInputString:withFlags:withInputManagerHint:)])
-                [keyboard addInputString:event.characters withFlags:event.keyboardFlags withInputManagerHint:event.inputManagerHint];
-            else
-                [keyboard addInputString:event.characters withFlags:event.keyboardFlags];
+            [keyboard addInputString:event.characters withFlags:event.keyboardFlags withInputManagerHint:event.inputManagerHint];
             return YES;
         }
         break;
@@ -4208,25 +4156,23 @@ static bool isAssistableInputType(InputType type)
                 context = [uiDelegate _dataDetectionContextForWebView:_webView];
 
             DDDetectionController *controller = [getDDDetectionControllerClass() sharedController];
-            if ([controller respondsToSelector:@selector(resultForURL:identifier:selectedText:results:context:extendedContext:)]) {
-                NSDictionary *newContext = nil;
-                RetainPtr<NSMutableDictionary> extendedContext;
-                DDResultRef ddResult = [controller resultForURL:dataForPreview[UIPreviewDataLink] identifier:_positionInformation.dataDetectorIdentifier selectedText:[self selectedText] results:_positionInformation.dataDetectorResults.get() context:context extendedContext:&newContext];
-                if (ddResult)
-                    dataForPreview[UIPreviewDataDDResult] = (__bridge id)ddResult;
-                if (!_positionInformation.textBefore.isEmpty() || !_positionInformation.textAfter.isEmpty()) {
-                    extendedContext = adoptNS([@{
-                        getkDataDetectorsLeadingText() : _positionInformation.textBefore,
-                        getkDataDetectorsTrailingText() : _positionInformation.textAfter,
-                    } mutableCopy]);
-                    
-                    if (newContext)
-                        [extendedContext addEntriesFromDictionary:newContext];
-                    newContext = extendedContext.get();
-                }
+            NSDictionary *newContext = nil;
+            RetainPtr<NSMutableDictionary> extendedContext;
+            DDResultRef ddResult = [controller resultForURL:dataForPreview[UIPreviewDataLink] identifier:_positionInformation.dataDetectorIdentifier selectedText:[self selectedText] results:_positionInformation.dataDetectorResults.get() context:context extendedContext:&newContext];
+            if (ddResult)
+                dataForPreview[UIPreviewDataDDResult] = (__bridge id)ddResult;
+            if (!_positionInformation.textBefore.isEmpty() || !_positionInformation.textAfter.isEmpty()) {
+                extendedContext = adoptNS([@{
+                    getkDataDetectorsLeadingText() : _positionInformation.textBefore,
+                    getkDataDetectorsTrailingText() : _positionInformation.textAfter,
+                } mutableCopy]);
+                
                 if (newContext)
-                    dataForPreview[UIPreviewDataDDContext] = newContext;
+                    [extendedContext addEntriesFromDictionary:newContext];
+                newContext = extendedContext.get();
             }
+            if (newContext)
+                dataForPreview[UIPreviewDataDDContext] = newContext;
         }
     } else if (canShowImagePreview) {
         *type = UIPreviewItemTypeImage;
index e2042d3..7173324 100644 (file)
@@ -177,8 +177,7 @@ MachSendRight TiledCoreAnimationDrawingAreaProxy::createFence()
     // Invalidate the fence if a synchronous message arrives while it's installed,
     // because we won't be able to reply during the fence-wait.
     uint64_t callbackID = m_webPageProxy.process().connection()->installIncomingSyncMessageCallback([rootLayerContext] {
-        if ([rootLayerContext respondsToSelector:@selector(invalidateFences)])
-            [rootLayerContext invalidateFences];
+        [rootLayerContext invalidateFences];
     });
     RefPtr<WebPageProxy> retainedPage = &m_webPageProxy;
     [CATransaction addCommitHandler:[callbackID, retainedPage] {
index 1e70864..e4becdb 100644 (file)
@@ -401,10 +401,8 @@ using namespace WebKit;
 
     actionContext.altMode = YES;
     actionContext.immediate = YES;
-    if ([[getDDActionsManagerClass() sharedManager] respondsToSelector:@selector(hasActionsForResult:actionContext:)]) {
-        if (![[getDDActionsManagerClass() sharedManager] hasActionsForResult:actionContext.mainResult actionContext:actionContext])
-            return nil;
-    }
+    if (![[getDDActionsManagerClass() sharedManager] hasActionsForResult:actionContext.mainResult actionContext:actionContext])
+        return nil;
 
     RefPtr<WebPageProxy> page = _page;
     PageOverlay::PageOverlayID overlayID = _hitTestResultData.detectedDataOriginatingPageOverlay;
index 47da217..47bd263 100644 (file)
@@ -266,9 +266,6 @@ void WebContextMenuProxyMac::clearServicesMenu()
 
 RetainPtr<NSMenuItem> WebContextMenuProxyMac::createShareMenuItem()
 {
-    if (![[NSMenuItem class] respondsToSelector:@selector(standardShareMenuItemWithItems:)])
-        return nil;
-
     const WebHitTestResultData& hitTestData = m_context.webHitTestResultData();
 
     auto items = adoptNS([[NSMutableArray alloc] init]);