Accessibility/WebAccessibilityAPI: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 41: Line 41:
   readonly attribute AccesibleElement? lastChild;
   readonly attribute AccesibleElement? lastChild;
   readonly attribute AccesibleElement? nextSibling;
   readonly attribute AccesibleElement? nextSibling;
   readonly attribute AccesibleElement? lastSibling;
   readonly attribute AccesibleElement? previousSibling;
   readonly attribute AccessibleChildren children;
   readonly attribute AccessibleChildren children;


Line 51: Line 51:


===Node interface extension===
===Node interface extension===
The accessible element can be requested from a DOM node if the DOM node is accessible, i.e. it expresses semantics meaningful to the assistive technology.
Accessible element can be requested from a DOM node if the DOM node is accessible, i.e. it expresses meaningful semantics to the assistive technology.
<pre>
<pre>
partial interface Node {
partial interface Node {
   AccessibleElement? accessibleElement;
   AccessibleElement? accessibleElement;


   A11eElement? a11ement; // nicer and shorter verison?
   A11eElement? a11ement; // nicer and shorter verison? // another version: accElement, accEl
};
};
</pre>
</pre>
Line 65: Line 65:
<code>
<code>
AccessibleElement .''role''
AccessibleElement .''role''
::Returns accessible role as string. Examples: "button", "menu", "textfield".
::Returns accessible role as a string. Examples: "button", "menu", "textfield".
</code>
</code>


Line 95: Line 95:
<code>
<code>
AccessibleElement .''states''
AccessibleElement .''states''
::Returns a [[#States|StateSet]] live object for all accessible states on the accessible element.
::Returns a [[#States|StateSet]] live object for all accessible states of an accessible element.
</code>
</code>




The accessible states on the accessible element are presented by <code>StateSet</code> object. It is a live object, i.e. if the states on the accessible element are changed then the object reflects that. Implementation is not required to compute any state until requested.
Accessible states of an accessible element are presented by the <code>StateSet</code> object. It is a live object, i.e. if the states of the accessible element change then the object reflects that. Implementation is not required to compute any state until requested.


<pre>
<pre>
Line 112: Line 112:
<code>
<code>
StateSet .''hasAnyOf''
StateSet .''hasAnyOf''
::Return true if any of the given states is presented on the accessible element.
::Returns true if any of the given states are present on the accessible element.
</code>
</code>


<code>
<code>
StateSet .''hasAllOf''
StateSet .''hasAllOf''
::Return true if all given states are presented on the accessible element.
::Returns true if all given states are present on the accessible element.
</code>
</code>




Example of a script announcing states on the accessible element.
Example of a script that logs to console all accessible element states.
<pre>
<pre>
var accElm = document.getElementById("foo").accessibleElement;
var accEl = document.getElementById("foo").accessibleElement;
for (let state of accElm.states) {
for (let state of accElm.states) {
   say(state);
   console.log(state);
}
}
</pre>
</pre>
Line 132: Line 132:
===Attributes===
===Attributes===


The accessible element may support a number of attributes to express the semantics that cannot be described by base properties of accessible element.
The accessible element may support a number of attributes to express the semantics that cannot be described by base properties of an accessible element.


<code>
<code>
AccessibleElement .''attributes''
AccessibleElement .''attributes''
::Returns a [[#AttributeMap|AttributeMap]] live object for all object attributes exposed on the accessible element. If attributes on the accessible element are changed then the object reflects the actual state of attributes. The implementation is not required to precompute any of the attributes.
::Returns a [[#AttributeMap|AttributeMap]] live object for all object attributes exposed on the accessible element. If accessible element attributes are changed then the object reflects the actual state of attributes. The implementation is not required to pre-compute any of the attributes.
</code>
</code>


Line 150: Line 150:
   readonly maplike<DOMString, any>;
   readonly maplike<DOMString, any>;


   boolean hasAnyOf(Object map);
   boolean hasAnyOf(Object map); // Needs more work
   boolean hasAllOf(Object map);
   boolean hasAllOf(Object map); // Needs more work
};
};
</pre>
</pre>
Line 157: Line 157:
<code>
<code>
AttributeSet .''hasAnyOf''
AttributeSet .''hasAnyOf''
::Return true if any of the given object property and its non null value matches a { name, value } pair from the map. If a null value property value matches a map name then value is ignored and is not part of the match.
::Return true if any of the given object properties and its non null value matches a { name, value } pair from the map. If a null value property value matches a map name then value is ignored and is not part of the match.


AttributeSet .''hasAllOf''
AttributeSet .''hasAllOf''
Line 176: Line 176:
====Attribute list====
====Attribute list====


Set of exposed attributes depends on semantics of the element. As example typical attributes are:
Set of exposed attributes depends on semantics of the element. As an example, typical attributes are:


<code>
<code>
Line 191: Line 191:
===Patterns===
===Patterns===


A pattern is a collection of attributes or methods expressing the accessible element semantics other than AccessibleElement interface provides. The patterns concept is quite similar to attributes but tends to be more powerful. Basically it's alternative implementation of queryInterface.
A pattern is a collection of attributes or methods that expresses an accessible element semantics and compliments what the AccessibleElement interface provides. The patterns concept is quite similar to attributes but tends to be more powerful. Basically, it is an alternative implementation of COM's queryInterface.


<code>
<code>
Object .''toPattern''(DOMString type)
Object .''toPattern''(DOMString type)
::Returns an object for the pattern of given type if supported by the accessible element.
::Returns an object for the pattern of given type if supported by an accessible element.
</code>
</code>


Line 205: Line 205:
<code>
<code>
AccessibleElement? .''relativeOf''(DOMString type)
AccessibleElement? .''relativeOf''(DOMString type)
::Returns related accessible element of the given relation type. If related accessible is not sole then the first one is returned.
::Returns related accessible element of the given relation type. If relation points to multiple accessible elements, the first one is returned.




RelationMap .''relations''
RelationMap .''relations''
::Returns the map of related accessible elements and relation types.
::Returns a map of relation types as keys and related accessible elements as values.
</code>
</code>


Line 220: Line 220:
====Relation types====
====Relation types====


This is a typical list of relation types that may be exposed by the accessible element. Note, the accessible element may support custom relations as well.
This is a typical list of relation types that may be exposed by an accessible element. Note, the accessible element may support custom relations as well.


<code>
<code>
Line 246: Line 246:
====Examples====
====Examples====


Announcement of all headers of the grid cell and name of the grid itself.
Console logging of all headers of the grid cell and name of the grid itself.


<pre>
<pre>
   var headers = cell.relations.get("labelledby");
   var headers = cell.relations.get("labelledby");
   for (let header of headers)
   for (let header of headers) {
     say(header.role +", " + header.name);
     console.log(header.role, header.name);
  }


   var grid = cell.relativeOf("widget");
   var grid = cell.relativeOf("widget");
   say(grid.name);
   console.log(grid.name);
</pre>
</pre>


===Actions===
===Actions===


The accessible element may support actions that can be invoked on it. For example, <code>jump</code> on a link or <code>press</code> on a button, or it can be generic propose actions like <code>scroll</code> or <code>focus</code>. Certain accessible actions may take extra parameters.
An accessible element may support actions that can be invoked on it. For example, <code>jump</code> on a link or <code>press</code> on a button, or it can be generic purpose actions like <code>scroll</code> or <code>focus</code>. Certain accessible actions may take optional parameters.


<code>
<code>
Line 284: Line 285:
<code>
<code>
''activate''
''activate''
::Exposed on accessible elements that may be activated. Accessible elements may use other names for this action to emphasise the semantics they expose. For example, ''jump'' on links, ''press'' on buttons, ''check'' and ''uncheck'' on checkboxes. Accessible element may provide more than one activation actions. For example, tree item can provide ''select''/''unselect'' as its primary action and ''expand''/''collapse'' as secondary. Tree column may implement ''sort'' action.
::Exposed on accessible elements that may be activated. Accessible elements may use other names for this action to emphasize the semantics they expose. For example, ''jump'' on links, ''press'' on buttons, ''check'' and ''uncheck'' on checkboxes. Accessible element may provide more than one action. For example, tree item can provide ''select''/''unselect'' as its primary action and ''expand''/''collapse'' as secondary. Tree column may implement ''sort'' action.
</code>
</code>


<code>
<code>
''focus''
''focus''
::Focus the accessible element. May be different from "activate" action, for example, in case of buttons where "activate" means press.
::Focus on an accessible element. May be different from "activate" action, for example, in case of buttons where "activate" means press.
</code>
</code>


<code>
<code>
''scroll''
''scroll''
::Scrolls the accessible element into view, optionally takes coordinates relative the element to scroll the view to
::Scrolls an accessible element into view, optionally takes coordinates relative the element to scroll the view to
::Parameter:
::Parameter:
:::''delta'' of ''ScrollDelta''
:::''delta'' of ''ScrollDelta''
Line 301: Line 302:
<code>
<code>
''drag'' and ''drop''
''drag'' and ''drop''
::Used to start dragging and dropping the content related to the accessible element the action is invoked for.
::Used to start dragging and dropping the content related to the accessible element the action is invoked on.
</code>
</code>


Line 327: Line 328:
</pre>
</pre>


<code>ScrollDelta</code> structure describes a scroll change within the accessible element, the scroll change can expressed in different units, for example, it can be in pixels or in pages. The accessible element may provide its custom set of supported modes which has to be described in [[#Taxonomy|taxonomy]].
<code>ScrollDelta</code> structure describes a scroll change within the accessible element, the scroll change can be expressed in different units, for example, it can be in pixels or in pages. The accessible element may provide its custom set of supported modes which has to be described in [[#Taxonomy|taxonomy]].


<code>
<code>
Line 339: Line 340:
:::''pixel'' - ''x'', ''y'' and ''z'' (optional) specifies how many pixles to scroll (2d or 3d)
:::''pixel'' - ''x'', ''y'' and ''z'' (optional) specifies how many pixles to scroll (2d or 3d)
:::''line'' - ''x'' specifies how many lines to scroll
:::''line'' - ''x'' specifies how many lines to scroll
:::''paragraph'' - ''x'' specifies how many paragraphs to scroll
:::''page'' - ''x'' specifies how many pages to scroll
:::''page'' - ''x'' specifies how many pages to scroll
</code>
</code>
Line 394: Line 396:
====Interactions====
====Interactions====


A widget may support actions that can be invoked through variety of devices or by AT like screen readers. The way the action is triggered by the user is described by interaction. Examples of user interactions are <code>swipe</code>, a mouse gesture to toggle a switch control; <code>space</code>, a key to toggle a checkbox. Access keys (<code>alt+letter</code>) and keyboard shortcuts (<code>ctrl+shift+letter</code>) used to activate the widgets are also examples of interactions. Complex widgets like grid control may support several actions, for example <code>ctrl+A</code> for <code>selectall</code> action, <code>ArrowDown/ArrowUp</code> keys for <code>movedown/moveup</code> actions, <code>ArrowRight/ArrowLeft</code> keys for <code>movenext/moveprev</code> actions.
A widget may support actions that can be invoked through variety of devices or by AT like screen readers. The way the action is triggered by the user is described by the interaction. Examples of user interactions are <code>swipe</code>, a mouse gesture to toggle a switch control; <code>space</code>, a key to toggle a checkbox. Access keys (<code>alt+letter</code>) and keyboard shortcuts (<code>ctrl+shift+letter</code>) used to activate the widgets are also examples of interactions. Complex widgets like grid control may support several actions, for example <code>ctrl+A</code> for <code>selectall</code> action, <code>ArrowDown/ArrowUp</code> keys for <code>movedown/moveup</code> actions, <code>ArrowRight/ArrowLeft</code> keys for <code>movenext/moveprev</code> actions.


The AT may need to know the used shortcuts to avoid possible conflicts or to supply a native way to invoke the action. For example, if presentation supports <code>swipe</code> gesture to navigate the slides then the AT can announce this info for the user.
The AT may need to know the used shortcuts to avoid possible conflicts or to supply a native way to invoke the action. For example, if presentation supports <code>swipe</code> gesture to navigate the slides then the AT can announce this info for the user.
Line 401: Line 403:
<code>
<code>
AccessibleElement .''interactions''
AccessibleElement .''interactions''
::Return an ''InteractionSet'' object describing all interactions that can be performed on the accessible element.
::Return an ''InteractionSet'' object describing all interactions that can be performed with the accessible element.
</code>
</code>


Line 415: Line 417:
<code>
<code>
AccessibleElement .''hasAnyOf''
AccessibleElement .''hasAnyOf''
::Return true if all given interaction are in use by the widget.
::Return true if any of given interaction are in use by the widget.
::Parameters:
::Parameters:
:::''interaction''
:::''interaction''
Line 421: Line 423:


AccessibleElement .''allOf''
AccessibleElement .''allOf''
::Return a list of all interactions on the accessible element as ''InteractionSet'' used to invoke the given action on the given device.
::Return a list of all interactions with the accessible element as ''InteractionSet'' used to invoke the given action on the given device.
::Parameters:
::Parameters:
:::''action''
:::''action''
Line 443: Line 445:
actions.forEach(action => { var set = action.interactions;
actions.forEach(action => { var set = action.interactions;
                             say(action.name);
                             say(action.name);
                             set.forEach(item => say(interaction.description));
                             set.values().forEach(item => say(item.description));
                           });
                           });
</pre>
</pre>
Line 496: Line 498:
===Accessible providers===
===Accessible providers===


The accessible element can be created for different kinds of sources. Most of the accessible elements are created for a DOM element to expose its semantics to the assistive technology. In some cases the browser may not have underlying DOM node for the content. In this case the accessible object having no associated DOM node is created. In some cases the web author may need to change the semantics for existing element or add new semantics or even may need a whole new accessible subtree to make the content accessible. In this case the author needs to describe desired semantics in JavaScript. See [[#JSSource|Making the content accessible in JavaScript]] for details.
The accessible element can be created with different kinds of sources. Most of the accessible elements are created for a DOM element to expose its semantics to the assistive technology. In some cases the browser may not have underlying DOM node for the content. In this case the accessible object is created, without having a corresponding DOM element. In some cases a web author may need to change the semantics for existing elements, add new semantics or create a new accessible subtree to make content accessible. In this case the author needs to describe desired semantics in JavaScript. See [[#JSSource|Making the content accessible in JavaScript]] for details.


[[File:WebAccessibilityAPI_SourceProviders.png|The accessible element may be sourced by different kinds of providers]]
[[File:WebAccessibilityAPI_SourceProviders.png|The accessible element may be sourced by different kinds of providers]]
Line 502: Line 504:
<code>
<code>
AccessibleElement .''DOMNode''
AccessibleElement .''DOMNode''
::Returns the DOM node associated with the accessible element if any. The accessible element does not have a DOM node, either when it has been unattached from the DOM node or it's not DOM node based. The first case happens when the JavaScript holds reference to the object longer than the object life cycle. The second case happens because of browser-specific implementation or in JavaScript created trees.
::Returns a DOM node associated with the accessible element if any. Accessible element does not have a DOM node when it is either not based on it, or when it has been detached from the DOM node. The first case happens for browser-specific implementations or for trees created in JavaScript. The second case happens when the JavaScript holds reference to the object longer than the object life cycle.
</code>
</code>


Line 508: Line 510:
<code>
<code>
AccessibleElement .''source''
AccessibleElement .''source''
::Returns [[#AccessibleSource|AccessibleSource]] associated with the accessible element if any. Also used to provide an accessible source to override accessible properties of the element.
::Returns [[#AccessibleSource|AccessibleSource]] if present, refers to an accessible source, used to override accessible properties of the element.
</code>
</code>


64

edits

Navigation menu