Accessibility/WebAccessibilityAPI: Difference between revisions

No edit summary
Line 515: Line 515:
==Content traversal==
==Content traversal==


This section describes how to traverse the accessible content, for example, if you need to navigate a document by headings or navigate a paragraph by words.
This section describes how to traverse accessible content, for example, if you need to navigate a document by headings or navigate a paragraph by words.


A key concept of the content traversal is accessible position which describes a "point" in the document content. A position can be at accessible element, for example, on a button. It can be before or after accessible element, or inside of the accessible element text, for example, at the end of the first line of a paragraph.
A key concept of the content traversal is accessible position which describes a "location" in the document content. A position can be placed on an accessible element, for example, on a button. It can be placed before or after an accessible element, or inside of the accessible element text, for example, at the end of the first line of a paragraph.


The position can be moved forward or backward in the document to the content complying the given criteria. For example, criteria can be described verbally like "move the position forward to next heading" or "move the position one word back".
The position can be moved forward or backward inside the document to the content complying with the given criteria. For example, criteria can be described verbally like "move the position forward to next heading" or "move the position one word back".


===Accessible Position===
===Accessible Position===
Line 527: Line 527:
  Constructor(DOMNode container, long offset, optional AccessibleElement root),
  Constructor(DOMNode container, long offset, optional AccessibleElement root),
  Constructor(DOMPoint point, optional AccessibleElement root),
  Constructor(DOMPoint point, optional AccessibleElement root),
  Constructor(AccessiblePos pos)]
  Constructor(AccessiblePos pos, optional AccessibleElement root)]
interface AccessiblePos {
interface AccessiblePos {
   AccessiblePos? move(AccessibleElement anchor, Offset offset);
   AccessiblePos? move(AccessibleElement anchor, Offset offset);
  AccessiblePos? move(DOMNode container, long offset);
   AccessiblePos? move(DOMPoint);
   AccessiblePos? move(DOMPoint);
   AccessiblePos? move(Where where, Matcher);
   AccessiblePos? move(Where where, Matcher);
Line 543: Line 544:
};
};


typedef AccessiblePos A11ePos; // Short and nice name?
typedef AccessiblePos A11ePos; // Short and nice name? // Maybe accPos
</pre>
</pre>


Line 555: Line 556:
::::anchor accessible element of the position
::::anchor accessible element of the position
:::''offset'' of ''Offset'', optional
:::''offset'' of ''Offset'', optional
::::the offset relative of the anchor element. If missed then ''at'' or ''insidestart'' is used depending on element type.
::::an offset relative to the anchor element. If not provided then ''at'' or ''afterbegin'' is used depending on element type.
:::''root'' of ''AccessibleElement'', optional
:::''root'' of ''AccessibleElement'', optional
::::root of subtree the position will belong to. If missed then document the anchor resides in is used.
::::a root of subtree containing the position. If not provided then parent document is used.
</code>
</code>


Line 564: Line 565:
typedef long or OffsetLiterals Offset;
typedef long or OffsetLiterals Offset;
enum OffsetLiterals {
enum OffsetLiterals {
   "before",
   "beforebegin",
  "afterbegin",
   "at",
   "at",
   "after",
   "beforeend",
   "inside start",
   "afterend"
  "inside end"
};
};
</pre>
</pre>


<code>
<code>
OffsetLiterals .''before''
OffsetLiterals .''beforebegin''
::Used to set the accessible position right before the accessible element
::Used to set the accessible position right before the accessible element beginning
</code>
</code>


<code>
<code>
OffsetLiterals .''at''
OffsetLiterals .''afterbegin''
::Used to set the accessible position at the accessible element
::Used to set the accessible position right after the accessible element beginning
</code>
</code>


<code>
<code>
OffsetLiterals .''after''
OffsetLiterals .''at''
::Used to set the accessible position right after the accessible element
::Used to set the accessible position at the accessible element
</code>
</code>


<code>
<code>
OffsetLiterals .''inside start''
OffsetLiterals .''beforeend''
::Used to set the accessible position inside of the accessible element right in the beginning of it
::Used to set the accessible position right before the accessible element ending
</code>
</code>


<code>
<code>
OffsetLiterals .''inside end''
OffsetLiterals .''afterend''
::Used to set the accessible position inside of the accessible element in the end of it
::Used to set the accessible position right after the accessible element ending
</code>
</code>


Line 603: Line 604:
::Parameters
::Parameters
:::''point'' of ''DOMPoint''
:::''point'' of ''DOMPoint''
::::the point the accessible position should be set at
::::a point, the accessible position should be set at
:::''root'' of ''AccessibleElement'', optional
:::''root'' of ''AccessibleElement'', optional
::::root of subtree the position will belong to. If missed then document the anchor resides in is used.
::::a root of subtree containing the position. If not provided then parent document is used.
</code>
</code>


Line 618: Line 619:
::::offset within the container node
::::offset within the container node
:::''root'' of ''AccessibleElement'', optional
:::''root'' of ''AccessibleElement'', optional
::::root of subtree the position will belong to. If missed then document the anchor resides in is used.
::::a root of subtree containing the position. If not provided then parent document is used.
</code>
</code>


Line 651: Line 652:
::::the anchor
::::the anchor
:::''offset'' of ''Offsest'', optional
:::''offset'' of ''Offsest'', optional
::::offset relative the anchor
:::Return itself.
AccessiblePos .''move''(DOMNode, long)
::Move the accessible position to the given DOM node at given offset.
::Parameters
:::''node'' of ''DOMNode''
::::the anchor
:::''offset'' of ''long''
::::offset relative the anchor
::::offset relative the anchor
:::Return itself.
:::Return itself.
Line 664: Line 675:


AccessiblePos .''move''(Where, Matcher)
AccessiblePos .''move''(Where, Matcher)
::Move the accessible position in the content. Returns true if succeeded.
::Move the accessible position to the content. Returns true if succeeded.
::Parameters
::Parameters
:::''where'' of ''Where''
:::''where'' of ''Where''
Line 674: Line 685:


AccessiblePos .''search''(Where, Matcher)
AccessiblePos .''search''(Where, Matcher)
::Finds the accessible position relative this one. Returns new instance.
::Finds the accessible position relative the current one. Returns new instance.
::Parameters
::Parameters
:::''where'' of ''Where''
:::''where'' of ''Where''
Line 715: Line 726:


Where .''tofirst''
Where .''tofirst''
::Search first match inside the root.
::Search for a first match inside the root.


Where .''tolast''
Where .''tolast''
::Search backwards (from last to first element) the first match inside the root.
::Search backwards (from last to first element) for a first match inside the root.


Where .''left''
Where .''left''
::Search a match left to the position.
::Search for a match left to the position.


Where .''right''
Where .''right''
::Search a match right to the position.
::Search for a match right to the position.


Where .''up''
Where .''up''
::Search a match up to the position.
::Search for a match up from the position.


Where .''down''
Where .''down''
::Search a match down to the position.
::Search for a match down from the position.


Where .''above''
Where .''above''
::Search a match above the position.
::Search for a match above the position.


Where .''under''
Where .''under''
::Search a match under the position.
::Search for a match under the position.


Where .''closest''
Where .''closest''
::Search a geometrically closest match to the position.
::Search for a geometrically closest match to the position.
</code>
</code>


Line 766: Line 777:
<code>
<code>
Matcher
Matcher
::A matching function used to define algorithm how the position is moved through the document.
::A matching function used to define an algorithm of how the position is moved through the document.
::Returns
::Returns
:::a search term(s)
:::a search term(s)
Line 844: Line 855:
<pre>
<pre>
var pos1 = new A11ePos(document.getElementById("a").a11ement);
var pos1 = new A11ePos(document.getElementById("a").a11ement);
var pos2 = pos1.search("forward", elm = > [ "word", "stop" ]);
var pos2 = pos1.search("forward", () = > {return [ "word", "stop" ];});
var pos3 = pos1.search("forward", elm => [ "word" ]);
var pos3 = pos1.search("forward", () => {return "word"; });
</pre>
</pre>


Line 915: Line 926:
* Ensure that the virtual cursor is survivable. If it ends up in the hidden sub-tree for example. If subtee gets destroyed then cursor should be moved. If AccessiblePos doesn't have matching function then it's unclear where it should be moved.
* Ensure that the virtual cursor is survivable. If it ends up in the hidden sub-tree for example. If subtee gets destroyed then cursor should be moved. If AccessiblePos doesn't have matching function then it's unclear where it should be moved.
* Also take into account walking to/from parent/child frames
* Also take into account walking to/from parent/child frames


==Text==
==Text==
64

edits