Confirmed users
1,396
edits
| Line 1,176: | Line 1,176: | ||
* create whole accessible trees for inaccessible content, for example, for graphics, charts in a canvas. | * create whole accessible trees for inaccessible content, for example, for graphics, charts in a canvas. | ||
=== | ===Direct change of accessible properties=== | ||
Accessible element properties can be altered right on the accessible element. Changing accessible property will result in accessible events if needed. For example: | Accessible element properties can be altered right on the accessible element. Changing accessible property will result in accessible events if needed. For example: | ||
| Line 1,185: | Line 1,185: | ||
<script> | <script> | ||
var div = document.getElementById("button").a11ement; | var div = document.getElementById("button").a11ement; | ||
div.name="click me"; | div.name = "click me"; | ||
div.description = "test accessibility"; | div.description = "test accessibility"; | ||
</script> | </script> | ||
| Line 1,267: | Line 1,267: | ||
<div id="AccessibleSource"> | <div id="AccessibleSource"> | ||
=== | ===Extend the semantic via accessible source=== | ||
</div> | </div> | ||
| Line 1,488: | Line 1,488: | ||
In case if interactions cannot be provided then the accessible source have to implement <code>activate</code> method to invoke actions. | In case if interactions cannot be provided then the accessible source have to implement <code>activate</code> method to invoke actions. | ||
==== | ====Proto==== | ||
<code> | <code> | ||
AccessibleSource .'' | AccessibleSource .''proto'' | ||
::Set by the browser when the accessible source is attached to the accessible element. | ::Point to accessible element implementation as it was before 'source' set. Set by the browser when the accessible source is attached to the accessible element. | ||
</code> | </code> | ||
===Change the accessible tree=== | |||
< | The web developer can alter existing accessible tree including subtree creations and deletions. This can be done either by <code>AccessibleSource</code> object assigned to the accessible element or by direct manipulations on the accessible tree. | ||
</ | |||
====Direct manipulations on the tree==== | |||
Accessible source object can be used to create new accessible element and insert it into the tree. If DOM node is used as a source then associated subtrees of accessible elements within the DOM node are reparanted, i.e. they are removed from children of its current accessible parent and added as children of new parent. Accessible element can be removed from children. | |||
<pre> | <pre> | ||
partial interface | partial interface AccessibleChildren { | ||
void append(AccessibleSource or DOMNode ... children); | void append(AccessibleSource or DOMNode ... children); | ||
void insertBefore(AccessibleElement before, AccessibleSource or DOMNode children); | void insertBefore(AccessibleElement before, AccessibleSource or DOMNode ... children); | ||
void insertAfter(AccessibleElement after, AccessibleSource or DOMNode ... children); | |||
void replace(AccessibleSource or DOMNode ... children); | |||
void remove(AccessibleElement ... children); | void remove(AccessibleElement ... children); | ||
void | void clear(); | ||
} | }; | ||
</pre> | </pre> | ||
<code> | <code> | ||
Children .''append'' | Children .''append'' | ||
:: | ::Appends accessible elements provided by sources as children to the accessible element. | ||
Children .''insertBefore'' | |||
::Inserts accessible elements provided by sources before the given child. | |||
Children .''insertAfter'' | |||
::Inserts accessible elements provided by sources after the given child. | |||
Children .''replace'' | |||
::Replaces existing children accessible elements within elements provided by sources. | |||
Children .''remove'' | Children .''remove'' | ||
::Removes accessible elements | ::Removes accessible elements from the accessible tree. | ||
Children .''clear'' | |||
::Removes all child accessible elements. | |||
</code> | </code> | ||
<b>Example</b> | |||
<pre> | |||
<input id="input" role="combobox"> | |||
<div id="list" role="listbox"> | |||
<div role="listitem">choice1</div> | |||
<div role="listitem">choice1</div> | |||
</div> | |||
<script> | |||
var input = document.getElementById("input").a11ement; | |||
input.children.replace(document.getElementById("list")); | |||
</script> | |||
<pre> | |||
====Build up the tree via accessible source==== | |||
You can provide child accessible elements for the given accessible element by assigning <code>AccessibleSource</code> object to it. This approach allows to create whole portions of the accessible tree for the content having no underlying DOM nodes. | |||
<pre> | |||
partial interface AccessibleSource { | |||
sequence<AccessibleSource or DOMNode> children; | |||
}; | |||
</pre> | |||
<code> | <code> | ||
AccessibleSource .''children'' | |||
::Return collection of accessible children. If AccessibleSource is provided then it's used to create a new accessible element and insert it as a child. If accessible DOMNode is provided then its accessible element is used, if inaccessible DOMNode is provided then its accessible children if any are used. | |||
</code> | </code> | ||
<b>Example. Add list with items into the tree.</b> | |||
<pre> | |||
var tree = { | |||
role: "listbox", | |||
name: "colors", | |||
children: [ | |||
{ | |||
role: "listitem", | |||
states: "focusable", | |||
name: "red" | |||
}, | |||
{ | |||
role: "listitem", | |||
states: "focusable", | |||
name: "green" | |||
} | |||
] | |||
}; | |||
divNode.accessibleSource = tree; | |||
</pre> | |||
====Canvas hit regions==== | ====Canvas hit regions==== | ||
Canvas [https://html.spec.whatwg.org/multipage/scripting.html#hit-regions hit region options] are extended by '' | Canvas [https://html.spec.whatwg.org/multipage/scripting.html#hit-regions hit region options] are extended by ''a11ement'' which is used to connect accessible element with hit region. Whenever hit region is activated then ''activate'' method of connected ''AccessibleSource'' object is called with no argument provided. | ||
Say you have a canvas with drawn button. In order to make it accessible you can create accessible button right in JS. | Say you have a canvas with drawn button. In order to make it accessible you can create accessible button right in JS. | ||
<pre> | <pre> | ||
var | var source = { | ||
role: "button", | |||
role: "button", name: "test", | name: "test", | ||
actions: | actions: { | ||
click: { | |||
interactions: { | |||
mouse: "click" | |||
} | |||
} | } | ||
}, | |||
onactivated: function(aEvent) { | |||
if (aEvent.region == "button") | |||
this.states | this.proto.set("focused"); | ||
else | |||
this.proto.states.unset("focused"); | |||
} | } | ||
proto: null | |||
}; | }; | ||
canvasNode.addHitRegion({ id: "button", a11ement: source }); | |||
canvasNode.addHitRegion({ " | canvasNode.addEventListener("click", source.onactivated.bind(source)); | ||
</pre> | </pre> | ||
===Feedback=== | ===Feedback notifications=== | ||
An accessible element may be notified of any kind of event, including its accessible source property change. In case of notification the browser will fire accessible events and update its cache if necessary. Decision when to notify the browser or not should be based on accessible events model. In other words if the property change in native markup causes an accessible event then same change in accessible source requires it too. | An accessible element may be notified of any kind of event, including its accessible source property change. In case of notification the browser will fire accessible events and update its cache if necessary. Decision when to notify the browser or not should be based on accessible events model. In other words if the property change in native markup causes an accessible event then same change in accessible source requires it too. | ||