Accessibility/WebAccessibilityAPI: Difference between revisions

Jump to navigation Jump to search
Line 526: Line 526:


===Accessible Position===
===Accessible Position===
<pre>
Yura: we should have async API for search.
</pre>


<pre>
<pre>
// yzen:
// yzen:
// default where should be "at" or "inside start"
// default where should be "at" or "inside start"
[Constructor(AccessibleElement anchor, Offset offset, optional AccessibleElement root),
[Constructor(AccessibleElement anchor, optional Offset offset, optional AccessibleElement root),
  Constructor(Where where, FinderFunc, optional AccessibleElement root),
  Constructor(Where where, Matcher, optional AccessibleElement root),
  Constructor(Point point, optional AccessibleElement root),
  Constructor(Point point, optional Matcher, optional AccessibleElement root),
  Constructor(AccessiblePos pos)]
  Constructor(AccessiblePos pos)]
interface AccessiblePos {
interface AccessiblePos {
Line 540: Line 544:


   long compare(AccessiblePos pos);
   long compare(AccessiblePos pos);
  boolean move(Direction dir, Filter or TextUnit rule);


   boolean move(AccessibleElement anchor, Offset offset);
   boolean move(AccessibleElement anchor, Offset offset);
   boolean move(Where where, optional FinderFunc);
   boolean move(Where where, optional Matcher);
   boolean move(Point, optional FinderFunc);
   boolean move(Point, optional Matcher);
};
};
</pre>
</pre>


<code>
AccessiblePos .''anchor''
::Returns the accessible element the position is contained by. If the position is at element then element itself.
</code>
<code>
AccessiblePos .''compare''
::Returns -1 if the given position is before in accessible tree than this position, 0 if they are the same, 1 if the given position is after.
</code>


====Construction====
====Construction====
Line 572: Line 565:
::::describes where position should be placed relative anchor element
::::describes where position should be placed relative anchor element
</code>
</code>
<pre>
("first" or "last" or AccessiblePos or (AccessibleElement and Offset), Matcher, optional AccessibleElement root)
var pos = new AccessiblePos(new Point(x, y), root);
function matcher(elm) { }
var pos = new AccessiblePos(new Point(x, y), root).move("forward", matcher);
or
var pos = new AccessiblePos(new Point(x, y), matcher, root).move("forward");
var pos = new AccessiblePos(elm, "at").move("backward", matcher);
or
var pos = new AccessiblePos(elm, "at", matcher).move("backward");
var pos2 = new AccessiblePos(pos).move("forward", matcher);
or
var pos2 = new AccessiblePos(pos, matcher).move("forward");
</pre>


<pre>
<pre>
typedef long or OffsetLiterals Offset;
typedef long or OffsetLiterals Offset;
enum WhereBit [OffsetLiterals] {
enum OffsetLiterals {
   "before",
   "before",
   "at",
   "at",
Line 585: Line 598:


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


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


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


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


<code>
<code>
WhereBit .''inside end''
OffsetLiterals .''insideend''
::Used to set the accessible position inside of the accessible element in the end of it
::Used to set the accessible position inside of the accessible element in the end of it
</code>
</code>
Line 624: Line 637:
::Move the accessible position in the content. Returns true if succeeded.
::Move the accessible position in the content. Returns true if succeeded.
::Parameters
::Parameters
:::''dir'' of ''Direction''
:::''element'' of ''AccessibleElement''
::::direction the position will be moved in
:::''offset'' of ''Offsest'', optional
:::''rule'' of ''Filter'' or ''TextUnit''
 
::::describes how position can be moved
AccessiblePos .''move''
::Move the accessible position in the content. Returns true if succeeded.
::Parameters
:::''where'' of ''Where''
:::''matcher'' of ''Matcher'', optional.
 
AccessiblePos .''move''
::Move the accessible position in the content. Returns true if succeeded.
::Parameters
:::''point'' of ''Point''
:::''matcher'' of ''Matcher'', optional. If provided then search the matching element closest to the point
</code>
</code>


Line 641: Line 664:
};
};
</pre>
</pre>
====Matching function====


<pre>
<pre>
// yzen: comment for \/
callback Matcher = sequence<SearchTerm> or SearchTerm (AccessibleElement);
</pre>
 
 
<code>
Matcher
::A matching function used to define algorithm how the position is moved through the document.
::Returns
:::a search term(s)
</code>


enum TreeFilterResult {
  true, // means 'accept'
  false, // means 'skip'
  "accept",
  "reject",
  "skip"
};
callback TreeFilter = TreeFilterResult (AccessibleElement);
</pre>


<pre>
<pre>
enum TextUnit {
enum SearchTerm {
   "char",
   "char",
   "word",
   "word",
Line 668: Line 694:


<code>
<code>
TextUnit .''char''
SearchTerm .''char''
::Used to move the position one char long.
::Used to move the position one char long.
</code>
</code>


<code>
<code>
TextUnit .''word''
SearchTerm .''word''
::Used to move the position to the next word.
::Used to move the position to the next word.
</code>
</code>


<code>
<code>
TextUnit .''sentence''
SearchTerm .''sentence''
::Used to move the position to the next sentence.
::Used to move the position to the next sentence.
</code>
</code>


<code>
<code>
TextUnit .''line''
SearchTerm .''line''
::Used to move the position to beginning of next line or end of previous line.
::Used to move the position to beginning of next line or end of previous line.
</code>
</code>


<code>
<code>
TextUnit .''paragraph''
SearchTerm .''paragraph''
::Used to move the position to beginning of next/previous paragraph.
::Used to move the position to beginning of next/previous paragraph.
</code>
</code>


<code>
<code>
TextUnit .''change''
SearchTerm .''change''
::Used to move the position to next change either of text attribute or new accessible.
::Used to move the position to next change either of text attribute or new accessible.
</code>
</code>


<code>
<code>
TextUnit .''bit''
SearchTerm .''bit''
::Used to move the position to next/previous navigable position. For example, from accessible start inside of it to right before accessible outside of it or moving from end of this line to start of next line in case of soft line break lines.
::Used to move the position to next/previous navigable position. For example, from accessible start inside of it to right before accessible outside of it or moving from end of this line to start of next line in case of soft line break lines.
</code>
</code>




[
<code>
alternative
SearchTerm .''reject''
::Used to ignore the entire subtree of traversed element.
</code>
 
<code>
SearchTerm .''at''
::Used to set the cursor at the element.
</code>
 
<code>
SearchTerm .''next''
::Used to continue the search.
</code>


<pre>
interface AccessiblePos {
  void move(Where where, MoverCallback func);
};
</pre>


<pre>
<pre>
function finder(aElm, aOffset)
function finder(aElm)
{
{
   if (aElm.hasText())
  var role = document.taxaOf(aElm.role);
     return "word"; // reenters with next accessible if it cannot move to the next word within this accessible
   if (role.is("widget")
     return [ "at", "reject" ];


   if (aElm.role == "table")
   if (role.is("structure")
     return "at";
     return "at";
  // Reenters with next accessible if it cannot move to the next word within this accessible.
  if (role.is("textcontainer"))
    return "word";
}
}


Line 725: Line 763:
</pre>
</pre>


[
Questions:
* Do we need *is* method right on AccessibleElement or should we have Role interface having that method or should AccessibleElement return role taxa as a role.
* Do we need to have "inContextOf" on AccessibleElement to check what the accessilbe belongs to. Note, native implementation doing some cache may be faster than tree traversal. If we need it then it's worth to consider *is* method too.
* Do we need isAnyOf() method additionally?
]
]
====Other methods====
<code>
AccessiblePos .''anchor''
::Returns the accessible element the position is contained by. If the position is at element then element itself.
</code>
<code>
AccessiblePos .''compare''
::Returns -1 if the given position is before in accessible tree than this position, 0 if they are the same, 1 if the given position is after.
</code>


===Virtual cursor===
===Virtual cursor===
Confirmed users
1,396

edits

Navigation menu