AX: Support keyboard access preference for iOS in WebKit
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2018 00:44:23 +0000 (00:44 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2018 00:44:23 +0000 (00:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192373
<rdar://problem/46462670>

Reviewed by Tim Horton.

* Platform/spi/ios/AccessibilitySupportSPI.h:
* PlatformMac.cmake:
* SourcesCocoa.txt:
* UIProcess/Cocoa/WKFullKeyboardAccessWatcher.h: Added.
* UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm: Added.
(platformIsFullKeyboardAccessEnabled):
(-[WKFullKeyboardAccessWatcher notifyAllProcessPools]):
(-[WKFullKeyboardAccessWatcher retrieveKeyboardUIModeFromPreferences:]):
(-[WKFullKeyboardAccessWatcher init]):
(+[WKFullKeyboardAccessWatcher fullKeyboardAccessEnabled]):
* UIProcess/ios/WebProcessProxyIOS.mm:
(WebKit::WebProcessProxy::fullKeyboardAccessEnabled):
* UIProcess/mac/WKFullKeyboardAccessWatcher.h: Removed.
* UIProcess/mac/WKFullKeyboardAccessWatcher.mm: Removed.
* WebKit.xcodeproj/project.pbxproj:

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

Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/AccessibilitySupportSPI.h
Source/WebKit/PlatformMac.cmake
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/Cocoa/WKFullKeyboardAccessWatcher.h [moved from Source/WebKit/UIProcess/mac/WKFullKeyboardAccessWatcher.h with 90% similarity]
Source/WebKit/UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm [moved from Source/WebKit/UIProcess/mac/WKFullKeyboardAccessWatcher.mm with 67% similarity]
Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj

index 18aa5c1..71e152e 100644 (file)
@@ -1,3 +1,27 @@
+2018-12-16  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support keyboard access preference for iOS in WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=192373
+        <rdar://problem/46462670>
+
+        Reviewed by Tim Horton.
+
+        * Platform/spi/ios/AccessibilitySupportSPI.h:
+        * PlatformMac.cmake:
+        * SourcesCocoa.txt:
+        * UIProcess/Cocoa/WKFullKeyboardAccessWatcher.h: Added.
+        * UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm: Added.
+        (platformIsFullKeyboardAccessEnabled):
+        (-[WKFullKeyboardAccessWatcher notifyAllProcessPools]):
+        (-[WKFullKeyboardAccessWatcher retrieveKeyboardUIModeFromPreferences:]):
+        (-[WKFullKeyboardAccessWatcher init]):
+        (+[WKFullKeyboardAccessWatcher fullKeyboardAccessEnabled]):
+        * UIProcess/ios/WebProcessProxyIOS.mm:
+        (WebKit::WebProcessProxy::fullKeyboardAccessEnabled):
+        * UIProcess/mac/WKFullKeyboardAccessWatcher.h: Removed.
+        * UIProcess/mac/WKFullKeyboardAccessWatcher.mm: Removed.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2018-12-16  Adrian Perez de Castro  <aperez@igalia.com>
 
         Unreviewed follow up after r239260
index 32dfac0..b4b0053 100644 (file)
@@ -38,5 +38,7 @@ extern Boolean _AXSKeyRepeatEnabled();
 extern CFTimeInterval _AXSKeyRepeatDelay();
 extern CFStringRef kAXSWebAccessibilityEventsEnabledNotification;
 extern Boolean _AXSWebAccessibilityEventsEnabled();
+extern CFStringRef kAXSFullKeyboardAccessEnabledNotification;
+extern Boolean _AXSFullKeyboardAccessEnabled();
 
 WTF_EXTERN_C_END
index 8a52d2a..471a0e0 100644 (file)
@@ -256,6 +256,7 @@ list(APPEND WebKit_SOURCES
     UIProcess/Cocoa/UIDelegate.mm
     UIProcess/Cocoa/VersionChecks.mm
     UIProcess/Cocoa/ViewGestureController.cpp
+    UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm
     UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
     UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
     UIProcess/Cocoa/WebPageProxyCocoa.mm
@@ -296,7 +297,6 @@ list(APPEND WebKit_SOURCES
     UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
     UIProcess/mac/ViewGestureControllerMac.mm
     UIProcess/mac/ViewSnapshotStore.mm
-    UIProcess/mac/WKFullKeyboardAccessWatcher.mm
     UIProcess/mac/WKFullScreenWindowController.mm
     UIProcess/mac/WKImmediateActionController.mm
     UIProcess/mac/WKInspectorViewController.mm
index 55eaf59..f1a057a 100644 (file)
@@ -338,6 +338,7 @@ UIProcess/Cocoa/WebProcessPoolCocoa.mm
 UIProcess/Cocoa/WebProcessProxyCocoa.mm
 UIProcess/Cocoa/WebURLSchemeHandlerCocoa.mm
 UIProcess/Cocoa/WebViewImpl.mm
+UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm
 UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
 UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
 
@@ -425,7 +426,6 @@ UIProcess/mac/WebPopupMenuProxyMac.mm
 UIProcess/mac/WebPreferencesMac.mm
 UIProcess/mac/WebProcessProxyMac.mm
 UIProcess/mac/WindowServerConnection.mm
-UIProcess/mac/WKFullKeyboardAccessWatcher.mm
 UIProcess/mac/WKFullScreenWindowController.mm
 UIProcess/mac/WKImmediateActionController.mm
 UIProcess/mac/WKInspectorViewController.mm
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WKFullKeyboardAccessWatcher_h
-#define WKFullKeyboardAccessWatcher_h
+#pragma once
 
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
 
 @interface WKFullKeyboardAccessWatcher : NSObject {
 @private
@@ -37,6 +36,4 @@
 
 @end;
 
-#endif // PLATFORM(MAC)
-
-#endif // WKFullKeyboardAccessWatcher_h
+#endif // PLATFORM(COCOA)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 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
 #import "config.h"
 #import "WKFullKeyboardAccessWatcher.h"
 
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
 
+#import "AccessibilitySupportSPI.h"
 #import "WebProcessPool.h"
 
-NSString * const KeyboardUIModeDidChangeNotification = @"com.apple.KeyboardUIModeDidChange";
-const CFStringRef AppleKeyboardUIMode = CFSTR("AppleKeyboardUIMode");
+#if PLATFORM(MAC)
+static NSString * const KeyboardUIModeDidChangeNotification = @"com.apple.KeyboardUIModeDidChange";
+static const CFStringRef AppleKeyboardUIMode = CFSTR("AppleKeyboardUIMode");
+#endif
 
 @implementation WKFullKeyboardAccessWatcher
 
-- (void)notifyAllProcessPools
+static inline BOOL platformIsFullKeyboardAccessEnabled()
 {
-    for (auto* processPool : WebKit::WebProcessPool::allProcessPools())
-        processPool->fullKeyboardAccessModeChanged(fullKeyboardAccessEnabled);
-}
-
-- (void)retrieveKeyboardUIModeFromPreferences:(NSNotification *)notification
-{
-    BOOL oldValue = fullKeyboardAccessEnabled;
-
+    BOOL fullKeyboardAccessEnabled = NO;
+#if PLATFORM(MAC)
     CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-
+    
     Boolean keyExistsAndHasValidFormat;
     int mode = CFPreferencesGetAppIntegerValue(AppleKeyboardUIMode, kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat);
     if (keyExistsAndHasValidFormat) {
@@ -55,7 +52,25 @@ const CFStringRef AppleKeyboardUIMode = CFSTR("AppleKeyboardUIMode");
         // Bit 1 is set if controls other than text fields are included in the tab order (WebKit also always includes lists).
         fullKeyboardAccessEnabled = (mode & 0x2);
     }
+#elif PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
+    fullKeyboardAccessEnabled = _AXSFullKeyboardAccessEnabled();
+#endif
+    
+    return fullKeyboardAccessEnabled;
+}
+
+- (void)notifyAllProcessPools
+{
+    for (auto* processPool : WebKit::WebProcessPool::allProcessPools())
+        processPool->fullKeyboardAccessModeChanged(fullKeyboardAccessEnabled);
+}
+
+- (void)retrieveKeyboardUIModeFromPreferences:(NSNotification *)notification
+{
+    BOOL oldValue = fullKeyboardAccessEnabled;
 
+    fullKeyboardAccessEnabled = platformIsFullKeyboardAccessEnabled();
+    
     if (fullKeyboardAccessEnabled != oldValue)
         [self notifyAllProcessPools];
 }
@@ -68,9 +83,19 @@ const CFStringRef AppleKeyboardUIMode = CFSTR("AppleKeyboardUIMode");
 
     [self retrieveKeyboardUIModeFromPreferences:nil];
 
-    [[NSDistributedNotificationCenter defaultCenter] 
-        addObserver:self selector:@selector(retrieveKeyboardUIModeFromPreferences:) 
-        name:KeyboardUIModeDidChangeNotification object:nil];
+    NSNotificationCenter *notificationCenter = nil;
+    NSString *notitificationName = nil;
+    
+#if PLATFORM(MAC)
+    notificationCenter = [NSDistributedNotificationCenter defaultCenter];
+    notitificationName = KeyboardUIModeDidChangeNotification;
+#elif PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
+    notificationCenter = [NSNotificationCenter defaultCenter];
+    notitificationName = (NSString *)kAXSFullKeyboardAccessEnabledNotification;
+#endif
+    
+    if (notitificationName)
+        [notificationCenter addObserver:self selector:@selector(retrieveKeyboardUIModeFromPreferences:) name:notitificationName object:nil];
 
     return self;
 }
@@ -83,4 +108,4 @@ const CFStringRef AppleKeyboardUIMode = CFSTR("AppleKeyboardUIMode");
 
 @end
 
-#endif // PLATFORM(MAC)
+#endif // PLATFORM(COCOA)
index c97d720..eaf7dc6 100644 (file)
 
 #if PLATFORM(IOS_FAMILY)
 
-#import <WebCore/NotImplemented.h>
-
+#import "WKFullKeyboardAccessWatcher.h"
 #import "WebProcessMessages.h"
 
 namespace WebKit {
 
 bool WebProcessProxy::fullKeyboardAccessEnabled()
 {
-    notImplemented();
-    return false;
+    return [WKFullKeyboardAccessWatcher fullKeyboardAccessEnabled];
 }
 
 } // namespace WebKit
index adb6dba..2832bb7 100644 (file)
                                51D124321E6DE521002B2820 /* WebURLSchemeHandlerCocoa.mm */,
                                2DFC7DB91BCCC19500C1548C /* WebViewImpl.h */,
                                2DFC7DBA1BCCC19500C1548C /* WebViewImpl.mm */,
+                               E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */,
+                               E1AEA22E14687BDB00804569 /* WKFullKeyboardAccessWatcher.mm */,
                                1AD01BCB1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.h */,
                                1AD01BCA1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.mm */,
                                5CA26D80217ABBB600F97A35 /* WKSafeBrowsingWarning.h */,
                                51D130571382F10500351EDD /* WebProcessProxyMac.mm */,
                                868160CD18763D4B0021E79D /* WindowServerConnection.h */,
                                868160CF187645370021E79D /* WindowServerConnection.mm */,
-                               E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */,
-                               E1AEA22E14687BDB00804569 /* WKFullKeyboardAccessWatcher.mm */,
                                CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */,
                                CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */,
                                9321D5851A38EE3C008052BE /* WKImmediateActionController.h */,