Commit d9898153 authored by Marialicia Villarreal Garcia's avatar Marialicia Villarreal Garcia Committed by Commit Bot

Sync VoiceOver and keyboard focus on navigation through browser frame

This change adds back method accessibilityAttributeNames that was
removed as part of a migration to NSAccessibility API. Despite being
deprecated, this is still called internally by AppKit, and the need for
this method was found because keyboard focus and VO focus were not in
sync anymore while navigating through the browser frame.

This issue is due to setAccessibilityFocused not being called because
accessibilityAttributeNames is the method in charge of returning the
attributes supported and one of them is NSAccessibilityFocusedAttribute.

The unit tests for setAccessibilityFocused are already handled in
ui\views\widget\ax_native_widget_mac_unittest.mm.

Original change: http://crrev.com/c/1508580

Bug: 990014

Change-Id: I505be15afae809690c5cea7599af96a7ce6ca691
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728043
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683473}
parent 97cfcf3d
......@@ -494,6 +494,76 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) {
node_->GetDelegate()->AccessibilityPerformAction(data);
}
// This method, while deprecated, is still called internally by AppKit.
- (NSArray*)accessibilityAttributeNames {
if (!node_)
return @[];
// These attributes are required on all accessibility objects.
NSArray* const kAllRoleAttributes = @[
NSAccessibilityChildrenAttribute,
NSAccessibilityParentAttribute,
NSAccessibilityPositionAttribute,
NSAccessibilityRoleAttribute,
NSAccessibilitySizeAttribute,
NSAccessibilitySubroleAttribute,
// Title is required for most elements. Cocoa asks for the value even if it
// is omitted here, but won't present it to accessibility APIs without this.
NSAccessibilityTitleAttribute,
// Attributes which are not required, but are general to all roles.
NSAccessibilityRoleDescriptionAttribute,
NSAccessibilityEnabledAttribute,
NSAccessibilityFocusedAttribute,
NSAccessibilityHelpAttribute,
NSAccessibilityTopLevelUIElementAttribute,
NSAccessibilityWindowAttribute,
];
// Attributes required for user-editable controls.
NSArray* const kValueAttributes = @[ NSAccessibilityValueAttribute ];
// Attributes required for unprotected textfields and labels.
NSArray* const kUnprotectedTextAttributes = @[
NSAccessibilityInsertionPointLineNumberAttribute,
NSAccessibilityNumberOfCharactersAttribute,
NSAccessibilitySelectedTextAttribute,
NSAccessibilitySelectedTextRangeAttribute,
NSAccessibilityVisibleCharacterRangeAttribute,
];
// Required for all text, including protected textfields.
NSString* const kTextAttributes = NSAccessibilityPlaceholderValueAttribute;
base::scoped_nsobject<NSMutableArray> axAttributes(
[[NSMutableArray alloc] init]);
[axAttributes addObjectsFromArray:kAllRoleAttributes];
switch (node_->GetData().role) {
case ax::mojom::Role::kTextField:
case ax::mojom::Role::kTextFieldWithComboBox:
case ax::mojom::Role::kStaticText:
[axAttributes addObject:kTextAttributes];
if (!node_->GetData().HasState(ax::mojom::State::kProtected))
[axAttributes addObjectsFromArray:kUnprotectedTextAttributes];
FALLTHROUGH;
case ax::mojom::Role::kCheckBox:
case ax::mojom::Role::kComboBoxMenuButton:
case ax::mojom::Role::kMenuItemCheckBox:
case ax::mojom::Role::kMenuItemRadio:
case ax::mojom::Role::kRadioButton:
case ax::mojom::Role::kSearchBox:
case ax::mojom::Role::kSlider:
case ax::mojom::Role::kSliderThumb:
case ax::mojom::Role::kToggleButton:
[axAttributes addObjectsFromArray:kValueAttributes];
break;
// TODO(tapted): Add additional attributes based on role.
default:
break;
}
if (node_->GetData().HasBoolAttribute(ax::mojom::BoolAttribute::kSelected)) {
[axAttributes addObjectsFromArray:@[ NSAccessibilitySelectedAttribute ]];
}
if (ui::IsMenuItem(node_->GetData().role)) {
[axAttributes addObjectsFromArray:@[ @"AXMenuItemMarkChar" ]];
}
return axAttributes.autorelease();
}
// Despite it being deprecated, AppKit internally calls this function sometimes
// in unclear circumstances. It is implemented in terms of the new a11y API
// here.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment