Bug 1473605 - Don't clump labels and controls together. It messes with focus events. r=yzen

This commit is contained in:
Eitan Isaacson 2018-07-05 15:06:00 +03:00
parent 35cd421aed
commit 6e015436cb
3 changed files with 18 additions and 17 deletions

View File

@ -51,20 +51,12 @@ BaseTraversalRule.prototype = {
Filters.MATCH | Filters.IGNORE_SUBTREE : Filters.IGNORE;
}
let matchResult =
(this._explicitMatchRoles.has(role) || !this._explicitMatchRoles.size) ?
this._matchFunc(aAccessible) : Filters.IGNORE;
// If we are on a label that nests a checkbox/radio we should land on it.
// It is a bigger touch target, and it reduces clutter.
if (role == Roles.LABEL && !(matchResult & Filters.IGNORE_SUBTREE)) {
let control = Utils.getEmbeddedControl(aAccessible);
if (control && this._explicitMatchRoles.has(control.role)) {
matchResult = this._matchFunc(control) | Filters.IGNORE_SUBTREE;
}
if (this._explicitMatchRoles.has(role) ||
!this._explicitMatchRoles.size) {
return this._matchFunc(aAccessible);
}
return matchResult;
return Filters.IGNORE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIAccessibleTraversalRule])

View File

@ -51,6 +51,10 @@
AndroidEvents.VIEW_CLICKED);
is(evt[1].checked, true, "checkbox is checked");
evt = await runner.moveNext("Simple",
AndroidEvents.VIEW_ACCESSIBILITY_FOCUSED);
runner.eventTextMatches(evt, ["many option"]);
evt = await runner.moveNext("Simple",
AndroidEvents.VIEW_ACCESSIBILITY_FOCUSED);
runner.eventTextMatches(evt, ["much range", "label"]);
@ -119,7 +123,11 @@
evt = await runner.movePrevious("Simple",
AndroidEvents.VIEW_ACCESSIBILITY_FOCUSED);
runner.eventTextMatches(evt, ["many option", "checked", "check button", "First item", "list", "1 item"]);
runner.eventTextMatches(evt, ["many option", "label", "First item", "list", "1 item"]);
evt = await runner.movePrevious("Simple",
AndroidEvents.VIEW_ACCESSIBILITY_FOCUSED);
runner.eventTextMatches(evt, ["many option", "checked", "check button"]);
evt = await runner.activateCurrent(0,
AndroidEvents.VIEW_CLICKED,

View File

@ -39,7 +39,7 @@
["heading-1", "heading-2", "heading-3", "heading-5"]);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Entry, null,
["input-1-1", "label-1-2", "input-1-3",
["input-1-1", "input-1-2", "input-1-3",
"input-1-4", "input-1-5"]);
// move back an element to hit all the form elements, because the VC is
@ -48,7 +48,7 @@
TraversalRules.Heading, "heading-1"));
queueTraversalSequence(gQueue, docAcc, TraversalRules.FormElement, null,
["input-1-1", "label-1-2", "button-1-1",
["input-1-1", "input-1-2", "button-1-1",
"radio-1-1", "radio-1-2", "input-1-3",
"input-1-4", "button-1-2", "checkbox-1-1",
"select-1-1", "select-1-2", "checkbox-1-2",
@ -96,7 +96,8 @@
["table-1", "grid", "table-2"]);
queueTraversalSequence(gQueue, docAcc, TraversalRules.Simple, null,
["heading-1", "Name:", "input-1-1", "label-1-2",
["heading-1", "Name:", "input-1-1",
"Favourite Ice Cream Flavour:", "input-1-2",
"button-1-1", "Radios are old: ", "radio-1-1",
"Radios are new: ", "radio-1-2", "Password:",
"input-1-3", "Unlucky number:", "input-1-4",
@ -130,7 +131,7 @@
queueTraversalSequence(gQueue, docAcc, TraversalRules.Control, null,
["input-1-1", "label-1-2", "button-1-1",
["input-1-1", "input-1-2", "button-1-1",
"radio-1-1", "radio-1-2", "input-1-3",
"input-1-4", "button-1-2", "checkbox-1-1",
"select-1-1", "select-1-2", "checkbox-1-2",