Skip to content

Commit

Permalink
Bug 1136563 - ARIA 1.1: Support role 'switch'
Browse files Browse the repository at this point in the history
  • Loading branch information
rmottola committed Feb 15, 2019
1 parent c5ad5ed commit 2484c9c
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 8 deletions.
11 changes: 11 additions & 0 deletions accessible/base/ARIAMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,17 @@ static nsRoleMapEntry sWAIRoleMaps[] =
kGenericAccType,
kNoReqStates
},
{ // switch
&nsGkAtoms::_switch,
roles::SWITCH,
kUseMapRole,
eNoValue,
eCheckUncheckAction,
eNoLiveAttr,
kGenericAccType,
kNoReqStates,
eARIACheckableBool
},
{ // tab
&nsGkAtoms::tab,
roles::PAGETAB,
Expand Down
7 changes: 6 additions & 1 deletion accessible/base/Role.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,12 @@ enum Role {
*/
KEY = 129,

LAST_ROLE = KEY
/**
* Represent a switch control widget (ARIA role "switch").
*/
SWITCH = 130,

LAST_ROLE = SWITCH
};

} // namespace role
Expand Down
8 changes: 8 additions & 0 deletions accessible/base/RoleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,3 +1055,11 @@ ROLE(KEY,
ROLE_SYSTEM_PUSHBUTTON,
ROLE_SYSTEM_PUSHBUTTON,
eNameFromSubtreeRule)

ROLE(SWITCH,
"switch",
ATK_ROLE_TOGGLE_BUTTON,
NSAccessibilityCheckBoxRole,
ROLE_SYSTEM_CHECKBUTTON,
IA2_ROLE_TOGGLE_BUTTON,
eNameFromSubtreeRule)
7 changes: 6 additions & 1 deletion accessible/interfaces/nsIAccessibleRole.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Defines cross platform (Goanna) roles.
*/
[scriptable, uuid(50db5e86-9a45-4637-a5c3-4ff148c33270)]
[scriptable, uuid(76ce835f-ef86-47c0-ac7b-e871417f1b6e)]
interface nsIAccessibleRole : nsISupports
{
/**
Expand Down Expand Up @@ -778,4 +778,9 @@ interface nsIAccessibleRole : nsISupports
* A keyboard or keypad key.
*/
const unsigned long ROLE_KEY = 129;

/**
* A switch control widget.
*/
const unsigned long ROLE_SWITCH = 130;
};
3 changes: 3 additions & 0 deletions accessible/mac/mozAccessible.mm
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ - (NSString*)subrole
case roles::DEFINITION:
return @"AXDefinition";

case roles::SWITCH:
return @"AXSwitch";

default:
break;
}
Expand Down
14 changes: 14 additions & 0 deletions accessible/tests/mochitest/actions/test_aria.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
actionName: "select",
events: CLICK_EVENTS
},
{
ID: "switch_unchecked",
actionName: "check",
events: CLICK_EVENTS
},
{
ID: "switch_checked",
actionName: "uncheck",
events: CLICK_EVENTS
},
{
ID: "tab",
actionName: "switch",
Expand Down Expand Up @@ -166,6 +176,10 @@
<div id="radio" role="radio">Radio</div>
</div>

<div id="switch_unchecked" role="switch">Switch</div>

<div id="switch_checked" role="switch" aria-checked="true">Switch</div>

<div role="tablist">
<div id="tab" role="tab">Tab</div>
</div>
Expand Down
30 changes: 24 additions & 6 deletions accessible/tests/mochitest/events/test_aria_statechange.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,30 @@
new setAttrOfMixedType(aID, "aria-checked", STATE_CHECKED, aValue);
}

function buildQueueForAttrOfMixedType(aQueue, aID, aInvokerFunc)
function buildQueueForAttr(aList, aQueue, aID, aInvokerFunc)
{
var list = [ "", "undefined", "false", "true", "mixed" ];
for (var i = 0; i < list.length; i++) {
for (var j = i + 1; j < list.length; j++) {
for (var i = 0; i < aList.length; i++) {
for (var j = i + 1; j < aList.length; j++) {
// XXX: changes from/to "undefined"/"" shouldn't fire state change
// events, bug 472142.
aQueue.push(new aInvokerFunc(aID, list[i]));
aQueue.push(new aInvokerFunc(aID, list[j]));
aQueue.push(new aInvokerFunc(aID, aList[i]));
aQueue.push(new aInvokerFunc(aID, aList[j]));
}
}
}

function buildQueueForAttrOfMixedType(aQueue, aID, aInvokerFunc)
{
var list = [ "", "undefined", "false", "true", "mixed" ];
buildQueueForAttr(list, aQueue, aID, aInvokerFunc);
}

function buildQueueForAttrOfBoolType(aQueue, aID, aInvokerFunc)
{
var list = [ "", "undefined", "false", "true" ];
buildQueueForAttr(list, aQueue, aID, aInvokerFunc);
}

function doTests()
{
gQueue = new eventQueue();
Expand All @@ -135,6 +146,7 @@
buildQueueForAttrOfMixedType(gQueue, "pressable", setPressed);
buildQueueForAttrOfMixedType(gQueue, "pressable_native", setPressed);
buildQueueForAttrOfMixedType(gQueue, "checkable", setChecked);
buildQueueForAttrOfBoolType(gQueue, "checkableBool", setChecked);

gQueue.invoke(); // Will call SimpleTest.finish();
}
Expand Down Expand Up @@ -166,6 +178,11 @@
title="Pressed state is not exposed on a button element with aria-pressed attribute"
Mozilla Bug 989958
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1136563"
title="Support ARIA 1.1 switch role"
Mozilla Bug 1136563
</a>

<p id="display"></p>
<div id="content" style="display: none"></div>
Expand All @@ -186,5 +203,6 @@

<!-- aria-checked -->
<div id="checkable" role="checkbox"></div>
<div id="checkableBool" role="switch"></div>
</body>
</html>
1 change: 1 addition & 0 deletions accessible/tests/mochitest/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const ROLE_SLIDER = nsIAccessibleRole.ROLE_SLIDER;
const ROLE_SPINBUTTON = nsIAccessibleRole.ROLE_SPINBUTTON;
const ROLE_STATICTEXT = nsIAccessibleRole.ROLE_STATICTEXT;
const ROLE_STATUSBAR = nsIAccessibleRole.ROLE_STATUSBAR;
const ROLE_SWITCH = nsIAccessibleRole.ROLE_SWITCH;
const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE;
const ROLE_TERM = nsIAccessibleRole.ROLE_TERM;
const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER;
Expand Down
7 changes: 7 additions & 0 deletions accessible/tests/mochitest/role/test_aria.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
testRole("aria_slider", ROLE_SLIDER);
testRole("aria_spinbutton", ROLE_SPINBUTTON);
testRole("aria_status", ROLE_STATUSBAR);
testRole("aria_switch", ROLE_SWITCH);
testRole("aria_tab", ROLE_PAGETAB);
testRole("aria_tablist", ROLE_PAGETABLIST);
testRole("aria_tabpanel", ROLE_PROPERTYPAGE);
Expand Down Expand Up @@ -178,6 +179,11 @@
href="https://bugzilla.mozilla.org/show_bug.cgi?id=735645">
Bug 735645
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1136563"
title="Support ARIA 1.1 switch role"
Bug 1136563
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
Expand Down Expand Up @@ -225,6 +231,7 @@
<span id="aria_slider" role="slider"/>
<span id="aria_spinbutton" role="spinbutton"/>
<span id="aria_status" role="status"/>
<span id="aria_switch" role="switch"/>
<span id="aria_tab" role="tab"/>
<span id="aria_tablist" role="tablist"/>
<span id="aria_tabpanel" role="tabpanel"/>
Expand Down
16 changes: 16 additions & 0 deletions accessible/tests/mochitest/states/test_aria.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
// aria-checked
testStates("aria_checked_checkbox", STATE_CHECKED);
testStates("aria_mixed_checkbox", STATE_MIXED);
testStates("aria_checked_switch", STATE_CHECKED);
testStates("aria_mixed_switch", 0, 0, STATE_MIXED); // unsupported

// test disabled group and all its descendants to see if they are
// disabled, too. See bug 429285.
Expand Down Expand Up @@ -350,6 +352,11 @@
title="Pressed state is not exposed on a button element with aria-pressed attribute"
Mozilla Bug 989958
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1136563"
title="Support ARIA 1.1 switch role"
Mozilla Bug 1136563
</a>

<p id="display"></p>
<div id="content" style="display: none"></div>
Expand Down Expand Up @@ -383,6 +390,15 @@
<div id="aria_mixed_checkbox" role="checkbox" aria-checked="mixed">
I might agree
</div>

<div id="aria_checked_switch" role="switch" aria-checked="true">
I am switched on
</div>

<div id="aria_mixed_switch" role="switch" aria-checked="mixed">
I am unsupported
</div>

<div id="aria_modal" aria-modal="true">modal stuff</div>
<div id="aria_modal_false" aria-modal="false">non modal stuff</div>div>
<div id="aria_multiline_textbox" role="textbox" aria-multiline="true"></div>
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsGkAtomList.h
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,7 @@ GK_ATOM(setsize, "setsize")
GK_ATOM(spelling, "spelling")
GK_ATOM(spinbutton, "spinbutton")
GK_ATOM(status, "status")
GK_ATOM(_switch, "switch")
GK_ATOM(tableCellIndex, "table-cell-index")
GK_ATOM(tablist, "tablist")
GK_ATOM(textIndent, "text-indent")
Expand Down

0 comments on commit 2484c9c

Please sign in to comment.