Accessibility/WebAccessibilityAPI: Difference between revisions

Jump to navigation Jump to search
Line 561: Line 561:
   AccessiblePos? move(DOMNode container, long offset);
   AccessiblePos? move(DOMNode container, long offset);
   AccessiblePos? move(DOMPoint);
   AccessiblePos? move(DOMPoint);
  AccessiblePos? move(Where where, Controller);


   AccessiblePos? search(Where where, Controller);
  AccessiblePos? move(Where where, Criteria);
   AccessiblePos? search(Where where, Criteria);


   readonly attribute AccessibleElement root;
   readonly attribute AccessibleElement root;
Line 709: Line 709:




Construction from a DOM node and offset relative it. See [[#Caret_and_selection|selection]] for examples.
Construction from a DOM node and offset relative it. See [[#Caret_and_selection|selection]] section for examples.


<code>
<code>
Line 924: Line 924:
var pos1 = new A11ePos(p, "begin", p), pos2 = null;
var pos1 = new A11ePos(p, "begin", p), pos2 = null;
while (pos2 = pos1.search("forward", "word")) {
while (pos2 = pos1.search("forward", "word")) {
   console.log(pos2.textInBetween(pos1));
   console.log(pos2.text(pos1));
   pos1 = pos2;
   pos1 = pos2;
}
}
Line 934: Line 934:
</pre>
</pre>


the log is "Mozilla ", "is ", "a ", "free-", "software ", "community", "which ", "produces ", "the ", "Firefox ", "web ", "browser."
The script above generates the log "Mozilla ", "is ", "a ", "free-", "software ", "community", "which ", "produces ", "the ", "Firefox ", "web ", "browser."
 
 
<b>Example #2. Traverse by words.</b>


<pre>
<pre>
Line 944: Line 941:


The log is "Mozilla".
The log is "Mozilla".
<b>Examples #3.</b>
<pre>
var pos1 = new A11ePos(document.getElementById("a").a11ement);
var pos2 = pos1.search("forward", () = > { return [ "word", "stop" ];});
var pos3 = pos1.search("forward", () => { return "word"; });
</pre>
<pre>
<p>Click <a id="a">here</a>, fellow</p>
</pre>
pos2 and pos3 points after "here" word in the link.
<pre>
<p>Click <a id="a"><img src=""></a>, fellow</p>
</pre>
pos2 equals to pos1, pos3 points after "fellow" word in the link.




Line 970: Line 949:
<code>
<code>
CriteriaFunc
CriteriaFunc
::A criteria function used to define an algorithm of how the position is moved through the document.
::A criteria function used to define an algorithm of the match.
::Returns
::Returns
:::a search term(s)
:::a criteria term or offset(s)
</code>
</code>


If "next" is returned then criteria function is reentered with next traversed accessible. If offset is given then traversing is stopped, the accessible position is moved to the traversed accessible element and returned offset. If criteria literal is returned then the accessible position is moved to the position complying the criteria.
If "next" is returned then criteria function is reentered with next traversed accessible. If offset is given then traversing is stopped, the accessible position is moved to the traversed accessible element and given offset. If criteria literal is returned then the accessible position is moved to the position complying the criteria. If it cannot be moved withing current accessible then it reenters with next accessible.




Line 989: Line 968:
     return "at";
     return "at";


   // Reenters with next accessible if it cannot move to the next word within this accessible.
   // Reenters with next accessible if it cannot move to the next line within this accessible.
   if (role.is("textcontainer"))
   if (role.is("textcontainer"))
     return "line";
     return "line";
// how to land on first line and then traverse all of them one by one?


   return "next";
   return "next";
}
}


pos.move("next", finder);
pos.move("next", criteria);
</pre>
</pre>


====Other methods====
====Other methods====
Confirmed users
1,396

edits

Navigation menu