Skip to content
Permalink
Browse files
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:]):


Canonical link: https://commits.webkit.org/211526@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244691 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
fleizach committed Apr 26, 2019
1 parent 841df53 commit 04bcae8cf25950f38a006746d0f0b9e428895591
Showing 5 changed files with 47 additions and 21 deletions.
@@ -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
@@ -2007,6 +2007,11 @@ - (void)accessibilityIncreaseSelection:(TextGranularity)granularity
[self accessibilityModifySelection:granularity increase:YES];
}

- (void)_accessibilitySetFocus:(BOOL)focus
{
[self baseAccessibilitySetFocus:focus];
}

- (void)accessibilityDecreaseSelection:(TextGranularity)granularity
{
[self accessibilityModifySelection:granularity increase:NO];
@@ -81,6 +81,7 @@ class VisiblePosition;
- (NSString *)baseAccessibilityHelpText;
- (NSArray<NSString *> *)baseAccessibilitySpeechHint;

- (void)baseAccessibilitySetFocus:(BOOL)focus;
- (NSString *)ariaLandmarkRoleDescription;

- (id)attachmentView;
@@ -571,6 +571,27 @@ - (NSString *)ariaLandmarkRoleDescription
}
}

- (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();
@@ -3871,27 +3871,7 @@ - (void)_accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName
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]);

0 comments on commit 04bcae8

Please sign in to comment.