AX: Provide iOS method for setting focus
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Apr 2019 16:36:29 +0000 (16:36 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Apr 2019 16:36:29 +0000 (16:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197200
<rdar://problem/50131679>

Reviewed by Alex Christensen.

Put the focus setting code in a place that iOS and macOS can access.
Override a platform level method for setting focus on iOS.

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper _accessibilitySetFocus:]):
* accessibility/mac/WebAccessibilityObjectWrapperBase.h:
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(-[WebAccessibilityObjectWrapperBase baseAccessibilitySetFocus:]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index bf6cada..1432402 100644 (file)
@@ -1,3 +1,22 @@
+2019-04-26  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Provide iOS method for setting focus
+        https://bugs.webkit.org/show_bug.cgi?id=197200
+        <rdar://problem/50131679>
+
+        Reviewed by Alex Christensen.
+
+        Put the focus setting code in a place that iOS and macOS can access.
+        Override a platform level method for setting focus on iOS.
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper _accessibilitySetFocus:]):
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (-[WebAccessibilityObjectWrapperBase baseAccessibilitySetFocus:]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):
+
 2019-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         propertyRegistry() was not overridden for SVGFEFloodElement and SVGFEMergeElement
index 5024e68..31f2561 100644 (file)
@@ -2007,6 +2007,11 @@ static RenderObject* rendererForView(WAKView* view)
     [self accessibilityModifySelection:granularity increase:YES];
 }
 
+- (void)_accessibilitySetFocus:(BOOL)focus
+{
+    [self baseAccessibilitySetFocus:focus];
+}
+
 - (void)accessibilityDecreaseSelection:(TextGranularity)granularity
 {
     [self accessibilityModifySelection:granularity increase:NO];
index f086890..4c375fe 100644 (file)
@@ -81,6 +81,7 @@ class VisiblePosition;
 - (NSString *)baseAccessibilityHelpText;
 - (NSArray<NSString *> *)baseAccessibilitySpeechHint;
 
+- (void)baseAccessibilitySetFocus:(BOOL)focus;
 - (NSString *)ariaLandmarkRoleDescription;
 
 - (id)attachmentView;
index af8f8a0..34af20a 100644 (file)
@@ -571,6 +571,27 @@ static void convertPathToScreenSpaceFunction(PathConversionInfo& conversion, con
     }
 }
 
+- (void)baseAccessibilitySetFocus:(BOOL)focus
+{
+    // If focus is just set without making the view the first responder, then keyboard focus won't move to the right place.
+    if (focus && !m_object->document()->frame()->selection().isFocusedAndActive()) {
+        FrameView* frameView = m_object->documentFrameView();
+        Page* page = m_object->page();
+        if (page && frameView) {
+            ChromeClient& chromeClient = page->chrome().client();
+            chromeClient.focus();
+
+            // Legacy WebKit1 case.
+            if (frameView->platformWidget())
+                chromeClient.makeFirstResponder(frameView->platformWidget());
+            else
+                chromeClient.assistiveTechnologyMakeFirstResponder();
+        }
+    }
+
+    m_object->setFocused(focus);
+}
+
 - (NSString *)accessibilityPlatformMathSubscriptKey
 {
     ASSERT_NOT_REACHED();
index 1ddf2a6..023c23d 100644 (file)
@@ -3871,27 +3871,7 @@ IGNORE_WARNINGS_END
         ASSERT(textMarkerRange);
         m_object->setSelectedVisiblePositionRange([self visiblePositionRangeForTextMarkerRange:textMarkerRange]);
     } else if ([attributeName isEqualToString: NSAccessibilityFocusedAttribute]) {
-        ASSERT(number);
-        
-        bool focus = [number boolValue];
-        
-        // If focus is just set without making the view the first responder, then keyboard focus won't move to the right place.
-        if (focus && !m_object->document()->frame()->selection().isFocusedAndActive()) {
-            FrameView* frameView = m_object->documentFrameView();
-            Page* page = m_object->page();
-            if (page && frameView) {
-                ChromeClient& chromeClient = page->chrome().client();
-                chromeClient.focus();
-                
-                // Legacy WebKit1 case.
-                if (frameView->platformWidget())
-                    chromeClient.makeFirstResponder(frameView->platformWidget());
-                else
-                    chromeClient.assistiveTechnologyMakeFirstResponder();
-            }
-        }
-        
-        m_object->setFocused(focus);
+        [self baseAccessibilitySetFocus:[number boolValue]];
     } else if ([attributeName isEqualToString: NSAccessibilityValueAttribute]) {
         if (number && m_object->canSetNumericValue())
             m_object->setValue([number floatValue]);