From 64d2a266cdca2b1e2b24182f4adfb29f7d30e80f Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Thu, 10 Dec 2020 19:00:05 +0000 Subject: [PATCH] Bug 1680277 - 3/3: Use AXTextArea for multiline and aria text boxes. r=morgan By spec, it would need to be an area for aria-multiline=true and a field for aria-multiline=false. Chrome seems to assign all aria text boxes to areas. For some reason this allows VO to recognize links when editing. Webkit doesn't need this, for some reason and can get links announces in AXTextField as well. Depends on D99312 Differential Revision: https://phabricator.services.mozilla.com/D99313 --- accessible/mac/mozAccessible.h | 3 +++ accessible/mac/mozAccessible.mm | 2 -- accessible/mac/mozTextAccessible.h | 3 +++ accessible/mac/mozTextAccessible.mm | 9 +++++++++ .../tests/browser/mac/browser_roles_elements.js | 12 ++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/accessible/mac/mozAccessible.h b/accessible/mac/mozAccessible.h index 673bdad4714d..5c188e194b83 100644 --- a/accessible/mac/mozAccessible.h +++ b/accessible/mac/mozAccessible.h @@ -111,6 +111,9 @@ inline mozAccessible* GetNativeFromGeckoAccessible( // Handle a role change - (void)handleRoleChanged:(mozilla::a11y::role)newRole; +// Get ARIA role +- (nsStaticAtom*)ARIARole; + #pragma mark - mozAccessible protocol / widget // override diff --git a/accessible/mac/mozAccessible.mm b/accessible/mac/mozAccessible.mm index 75f6f2ca84ad..53871facb259 100644 --- a/accessible/mac/mozAccessible.mm +++ b/accessible/mac/mozAccessible.mm @@ -41,8 +41,6 @@ using namespace mozilla::a11y; @interface mozAccessible () - (BOOL)providesLabelNotTitle; -- (nsStaticAtom*)ARIARole; - - (void)maybePostLiveRegionChanged; @end diff --git a/accessible/mac/mozTextAccessible.h b/accessible/mac/mozTextAccessible.h index 0f4c4e646765..55d0ac7a06bf 100644 --- a/accessible/mac/mozTextAccessible.h +++ b/accessible/mac/mozTextAccessible.h @@ -24,6 +24,9 @@ // override - (NSNumber*)moxInsertionPointLineNumber; +// override +- (NSString*)moxRole; + // override - (NSString*)moxSubrole; diff --git a/accessible/mac/mozTextAccessible.mm b/accessible/mac/mozTextAccessible.mm index b815549361ce..4f8907929b94 100644 --- a/accessible/mac/mozTextAccessible.mm +++ b/accessible/mac/mozTextAccessible.mm @@ -134,6 +134,15 @@ inline NSString* ToNSString(id aValue) { return (lineNumber >= 0) ? [NSNumber numberWithInt:lineNumber] : nil; } +- (NSString*)moxRole { + if ([self ARIARole] == nsGkAtoms::textbox || + [self stateWithMask:states::MULTI_LINE]) { + return NSAccessibilityTextAreaRole; + } + + return [super moxRole]; +} + - (NSString*)moxSubrole { MOZ_ASSERT(!mGeckoAccessible.IsNull()); diff --git a/accessible/tests/browser/mac/browser_roles_elements.js b/accessible/tests/browser/mac/browser_roles_elements.js index 221a6fe9cfeb..5f07961486ed 100644 --- a/accessible/tests/browser/mac/browser_roles_elements.js +++ b/accessible/tests/browser/mac/browser_roles_elements.js @@ -73,6 +73,12 @@ addAccessibleTask(
+ +
+
+ + + @@ -175,6 +181,12 @@ addAccessibleTask( testRoleAndSubRole(accDoc, "timer", null, "AXApplicationTimer"); testRoleAndSubRole(accDoc, "tooltip", "AXGroup", "AXUserInterfaceTooltip"); + // Text boxes + testRoleAndSubRole(accDoc, "textbox_multiline", "AXTextArea"); + testRoleAndSubRole(accDoc, "textbox_singleline", "AXTextArea"); + testRoleAndSubRole(accDoc, "textArea", "AXTextArea"); + testRoleAndSubRole(accDoc, "textInput", "AXTextField"); + // True HTML5 search field testRoleAndSubRole(accDoc, "htmlSearch", "AXTextField", "AXSearchField");