Bug 1938624 part 3: Map <input type="search"> and role="searchbox" to the new SEARCHBOX Gecko role. r=eeejay
1. Return this role as appropriate in HTMLTextFieldAccessible and update ARIAMap. 2. Remove Accessible::IsSearchbox, which is no longer required. 3. Remove Mac mozTextAccessible moxSubrole override. This was only used for password inputs and searchboxes, but we can now specify these subroles in the RoleMap instead. 4. Tweak the iOS code for the removal of IsSearchbox. Differential Revision: https://phabricator.services.mozilla.com/D233230
This commit is contained in:
@@ -1158,7 +1158,7 @@ static const nsRoleMapEntry sWAIRoleMaps[] = {
|
||||
},
|
||||
{ // searchbox
|
||||
nsGkAtoms::searchbox,
|
||||
roles::ENTRY,
|
||||
roles::SEARCHBOX,
|
||||
kUseMapRole,
|
||||
eNoValue,
|
||||
eActivateAction,
|
||||
|
||||
@@ -660,7 +660,7 @@ ROLE(PASSWORD_TEXT,
|
||||
nullptr,
|
||||
ATK_ROLE_PASSWORD_TEXT,
|
||||
NSAccessibilityTextFieldRole,
|
||||
NSAccessibilityUnknownSubrole,
|
||||
NSAccessibilitySecureTextFieldSubrole,
|
||||
ROLE_SYSTEM_TEXT,
|
||||
ROLE_SYSTEM_TEXT,
|
||||
java::SessionAccessibility::CLASSNAME_EDITTEXT,
|
||||
|
||||
@@ -451,16 +451,6 @@ already_AddRefed<nsIURI> Accessible::AnchorURIAt(uint32_t aAnchorIndex) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Accessible::IsSearchbox() const {
|
||||
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
||||
if (roleMapEntry && roleMapEntry->Is(nsGkAtoms::searchbox)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RefPtr<nsAtom> inputType = InputType();
|
||||
return inputType == nsGkAtoms::search;
|
||||
}
|
||||
|
||||
#ifdef A11Y_LOG
|
||||
void Accessible::DebugDescription(nsCString& aDesc) const {
|
||||
aDesc.Truncate();
|
||||
@@ -632,9 +622,6 @@ nsStaticAtom* Accessible::ComputedARIARole() const {
|
||||
// map to a unique Gecko role.
|
||||
return roleMap->roleAtom;
|
||||
}
|
||||
if (IsSearchbox()) {
|
||||
return nsGkAtoms::searchbox;
|
||||
}
|
||||
role geckoRole = Role();
|
||||
if (geckoRole == roles::LANDMARK) {
|
||||
// Landmark role from native markup; e.g. <main>, <nav>.
|
||||
|
||||
@@ -646,8 +646,6 @@ class Accessible {
|
||||
|
||||
bool IsDateTimeField() const { return mType == eHTMLDateTimeFieldType; }
|
||||
|
||||
bool IsSearchbox() const;
|
||||
|
||||
virtual bool HasNumericValue() const = 0;
|
||||
|
||||
/**
|
||||
|
||||
@@ -289,9 +289,16 @@ role HTMLTextFieldAccessible::NativeRole() const {
|
||||
if (mType == eHTMLTextPasswordFieldType) {
|
||||
return roles::PASSWORD_TEXT;
|
||||
}
|
||||
if (mContent->AsElement()->HasAttr(nsGkAtoms::list_)) {
|
||||
dom::Element* el = mContent->AsElement();
|
||||
if (el->HasAttr(nsGkAtoms::list_)) {
|
||||
return roles::EDITCOMBOBOX;
|
||||
}
|
||||
if (const nsAttrValue* attr = el->GetParsedAttr(nsGkAtoms::type)) {
|
||||
RefPtr<nsAtom> inputType = attr->GetAsAtom();
|
||||
if (inputType == nsGkAtoms::search) {
|
||||
return roles::SEARCHBOX;
|
||||
}
|
||||
}
|
||||
return roles::ENTRY;
|
||||
}
|
||||
|
||||
|
||||
@@ -374,6 +374,9 @@ static uint64_t GetAccessibilityTraits(Accessible* aAccessible) {
|
||||
case roles::PASSWORD_TEXT:
|
||||
traits |= Trait::SecureTextField;
|
||||
break;
|
||||
case roles::SEARCHBOX:
|
||||
traits |= Trait::SearchField;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -405,10 +408,6 @@ static uint64_t GetAccessibilityTraits(Accessible* aAccessible) {
|
||||
traits |= Trait::IsEditing | Trait::TextOperationsAvailable;
|
||||
}
|
||||
|
||||
if (aAccessible->IsSearchbox()) {
|
||||
traits |= Trait::SearchField;
|
||||
}
|
||||
|
||||
if (state & states::MULTI_LINE) {
|
||||
traits |= Trait::TextArea;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,6 @@
|
||||
// override
|
||||
- (NSString*)moxRole;
|
||||
|
||||
// override
|
||||
- (NSString*)moxSubrole;
|
||||
|
||||
// override
|
||||
- (NSNumber*)moxNumberOfCharacters;
|
||||
|
||||
|
||||
@@ -113,20 +113,6 @@ inline NSString* ToNSString(id aValue) {
|
||||
return [super moxRole];
|
||||
}
|
||||
|
||||
- (NSString*)moxSubrole {
|
||||
MOZ_ASSERT(mGeckoAccessible);
|
||||
|
||||
if (mRole == roles::PASSWORD_TEXT) {
|
||||
return NSAccessibilitySecureTextFieldSubrole;
|
||||
}
|
||||
|
||||
if (mRole == roles::ENTRY && mGeckoAccessible->IsSearchbox()) {
|
||||
return @"AXSearchField";
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSNumber*)moxNumberOfCharacters {
|
||||
return @([self textLength]);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ addAccessibleTask(
|
||||
testComputedARIARole("ariaUnnamedRegion", "navigation");
|
||||
// The directory ARIA role is an alias of list.
|
||||
testComputedARIARole("ariaDirectory", "list");
|
||||
// alertdialog, feed, rowgroup and searchbox map to a Gecko role, but it
|
||||
// isn't unique.
|
||||
// alertdialog, feed and rowgroupmap to a Gecko role, but it isn't unique.
|
||||
testComputedARIARole("ariaAlertdialog", "alertdialog");
|
||||
testComputedARIARole("ariaFeed", "feed");
|
||||
testComputedARIARole("ariaRowgroup", "rowgroup");
|
||||
|
||||
@@ -33,7 +33,7 @@ add_task(async function test_searchbar_a11y_tree() {
|
||||
|
||||
// input element
|
||||
{
|
||||
role: ROLE_ENTRY,
|
||||
role: ROLE_SEARCHBOX,
|
||||
children: [],
|
||||
},
|
||||
|
||||
@@ -72,7 +72,7 @@ add_task(async function test_searchbar_a11y_tree() {
|
||||
|
||||
// input element
|
||||
{
|
||||
role: ROLE_ENTRY,
|
||||
role: ROLE_SEARCHBOX,
|
||||
children: [],
|
||||
},
|
||||
|
||||
|
||||
@@ -765,11 +765,24 @@
|
||||
],
|
||||
};
|
||||
testElm("input_email", obj);
|
||||
testElm("input_search", obj);
|
||||
testElm("input_tel", obj);
|
||||
testElm("input_text", obj);
|
||||
testElm("input_url", obj);
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
// HTML:input@type="search"
|
||||
|
||||
obj = {
|
||||
role: ROLE_SEARCHBOX,
|
||||
extraStates: EXT_STATE_EDITABLE | EXT_STATE_SINGLE_LINE,
|
||||
actions: "activate",
|
||||
interfaces: [ nsIAccessibleText, nsIAccessibleEditableText ],
|
||||
children: [
|
||||
{ role: ROLE_TEXT_LEAF },
|
||||
],
|
||||
};
|
||||
testElm("input_search", obj);
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
// input @type="text" with placeholder attribute
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@
|
||||
testRole("aria_region_as_table_with_miscaption_mixed", ROLE_TABLE);
|
||||
testRole("aria_scrollbar", ROLE_SCROLLBAR);
|
||||
testRole("aria_scrollbar_mixed", ROLE_SCROLLBAR);
|
||||
testRole("aria_searchbox", ROLE_ENTRY);
|
||||
testRole("aria_searchbox_mixed", ROLE_ENTRY);
|
||||
testRole("aria_searchbox", ROLE_SEARCHBOX);
|
||||
testRole("aria_searchbox_mixed", ROLE_SEARCHBOX);
|
||||
testRole("aria_separator", ROLE_SEPARATOR);
|
||||
testRole("aria_separator_mixed", ROLE_SEPARATOR);
|
||||
testRole("aria_slider", ROLE_SLIDER);
|
||||
@@ -481,8 +481,8 @@
|
||||
<table id="aria_region_as_table_with_miscaption_mixed" role="rEGIOn"><caption role="option">hello</caption></table>
|
||||
<span id="aria_scrollbar" role="scrollbar"></span>
|
||||
<span id="aria_scrollbar_mixed" role="sCROLLBAr"></span>
|
||||
<span id="aria_searchbox" role="textbox"></span>
|
||||
<span id="aria_searchbox_mixed" role="tEXTBOx"></span>
|
||||
<span id="aria_searchbox" role="searchbox"></span>
|
||||
<span id="aria_searchbox_mixed" role="sEARCHBOx"></span>
|
||||
<span id="aria_separator" role="separator"></span>
|
||||
<span id="aria_separator_mixed" role="sEPARATOr"></span>
|
||||
<span id="aria_slider" role="slider"></span>
|
||||
|
||||
@@ -35,6 +35,7 @@ this.AccessibilityUtils = (function () {
|
||||
Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT,
|
||||
Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
|
||||
Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
|
||||
Ci.nsIAccessibleRole.ROLE_SEARCHBOX,
|
||||
Ci.nsIAccessibleRole.ROLE_SLIDER,
|
||||
Ci.nsIAccessibleRole.ROLE_SPINBUTTON,
|
||||
Ci.nsIAccessibleRole.ROLE_SUMMARY,
|
||||
|
||||
Reference in New Issue
Block a user