Report ARIA switch controls as "switch" with a state of on or off (#14282)
Fixes #11310
Summary of the issue:
Currently elements on the web with an ARIA role of "switch" are presented in NVDA as checkboxes.
This is because:
• There is no switch role in IAccessible2
• ARIA practices recommend that browsers map the switch role to the toggleButton role in IAccessible2, but there is some confusion around whether the pressed or checked state should be exposed to denote the switch is on.
• NVDA historically has chosen to deliberately map switches to checkboxes with checked, rather than toggleButton with pressed.
• ARIA practices state that a switch is the same as a checkbox, just with no indeterminate state.
There is a lot of pressure from web authors and standards groups for NVDA to specifically report switch controls as having a role of "switch" rather than checkbox, as it is believed this improves communication between blind and sited individuals, as visually the switch control looks like a switch, not a checkbox.
Description of user facing changes
• switch controls in Firefox, Chrome and Edge, via IAccessible2, are now reported in NVDA as switch controls, rather than checkboxes.
◦ They are spoken with a role of "switch" and state of either "on" or "off".
◦ In Braille, they are represented with a role of "swtch" and a state braille pattern the same as checked / not checked.
Description of development approach
• Added a new role of SWITCH
• Added a new state of ON
• The negative state of ON is "off".
• Only a role of switch forces a negative of the ON state. I.e. Switch is the only control that will report as "off" if no ON state exists.
• The switch role is treated as having a text presentation type of singleLine, similar to checkbox.
• for IA2Web NVDAObjects and IAccessible2 virtualBuffers (Chrome, Firefox, Edge), IAccessible2 objects with "switch" in xml-roles:
◦ map to an NVDA role of switch
◦ pressed and checkable states are discarded
◦ the checked state is mapped to the ON state.
The w3c ARIA examples submodule has also been updated to the latest main commit as the existing commit we were on did not yet have the switch example.