Accessibility/WebAccessibilityAPI: Difference between revisions

Line 532: Line 532:
   AccessiblePos? move(DOMNode container, long offset);
   AccessiblePos? move(DOMNode container, long offset);
   AccessiblePos? move(DOMPoint);
   AccessiblePos? move(DOMPoint);
   AccessiblePos? move(Where where, Matcher);
   AccessiblePos? move(Where where, Controller);


   AccessiblePos? search(Where where, Matcher);
   AccessiblePos? search(Where where, Controller);


   readonly attribute AccessibleElement root;
   readonly attribute AccessibleElement root;
Line 574: Line 574:


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


<code>
<code>
OffsetLiterals .''afterend''
OffsetLiterals .''after''
::Used to set the accessible position right after the accessible element ending
::Used to set the accessible position right after the accessible element ending
</code>
</code>
Line 637: Line 637:


var pos2 = new A11ePos(button.accessibleElement, "at");
var pos2 = new A11ePos(button.accessibleElement, "at");
var pos3 = new A11ePos(paragraph.accessibleElement, "inside start");
var pos3 = new A11ePos(paragraph.accessibleElement, "afterbegin");


var pos4 = new A11ePos(pos2);
var pos4 = new A11ePos(pos2);
Line 674: Line 674:




AccessiblePos .''move''(Where, Matcher)
AccessiblePos .''move''(Where, Controller)
::Move the accessible position to 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''
::::where the search should be performed
::::where the search should be performed
:::''matcher'' of ''Matcher''
:::''controller'' of ''Controller''
::::function describing a match
::::function describing a match
:::Return itself.
:::Return itself.




AccessiblePos .''search''(Where, Matcher)
AccessiblePos .''search''(Where, Controller)
::Finds the accessible position relative the current one. Returns new instance.
::Finds the accessible position relative the current one. Returns new instance.
::Parameters
::Parameters
:::''where'' of ''Where''
:::''where'' of ''Where''
::::where the search should be performed
::::where the search should be performed
:::''matcher'' of ''Matcher''
:::''controller'' of ''Controller''
::::function describing a match
::::function describing a match
:::Return new instance.
:::Return new instance.
Line 756: Line 756:
Examples:
Examples:
<pre>
<pre>
function matcher(elm) { }
function controller(elm) { }
var pos1 = new A11ePos(new DOMPoint(x, y), a11edoc).move("forward", matcher);
var pos1 = new A11ePos(new DOMPoint(x, y), a11edoc).move("forward", controller);


var pos2 = new A11ePos(elm, "at").move("backward", matcher);
var pos2 = new A11ePos(elm, "at").move("backward", controller);


var pos3 = new A11ePos(pos).move("forward", matcher);
var pos3 = new A11ePos(pos).move("forward", controller);
or
or
var pos2 = pos2.search("forward", matcher);
var pos2 = pos2.search("forward", controller);
</pre>
</pre>


Line 771: Line 771:


<pre>
<pre>
callback Matcher = SearchTerm sequence<SearchTerm> (AccessibleElement);
callback Controller = SearchTerm sequence<SearchTerm> (AccessibleElement);
</pre>
</pre>




<code>
<code>
Matcher
Controller
::A matching function used to define an algorithm of 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
Line 855: 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", () = > {return [ "word", "stop" ];});
var pos2 = pos1.search("forward", () = > { return [ "word", "stop" ];});
var pos3 = pos1.search("forward", () => {return "word"; });
var pos3 = pos1.search("forward", () => { return "word"; });
</pre>
</pre>


Line 872: Line 872:
<b> Example. Navigate by widgets and structures, and by words in case of text.</b>
<b> Example. Navigate by widgets and structures, and by words in case of text.</b>
<pre>
<pre>
function matcher(aElm)
function controller(aEl)
{
{
   var role = document.taxonOf("role", aElm.role);
   var role = document.taxonOf("role", aEl.role);
   if (role.is("widget")
   if (role.is("widget")
     return [ "at", "skipsubtree" ];
     return [ "at", "skipsubtree" ];
Confirmed users
1,396

edits