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>
[Constructor(AccessibleElement anchor, optional Offset offset, optional AccessibleElement root),
[Constructor(AccessibleElement anchor, optional Offset offset, optional AccessibleElement root),
  Constructor(Point point, optional AccessibleElement root),
  Constructor(DOMPoint point, optional AccessibleElement root),
  Constructor(AccessiblePos pos)]
  Constructor(AccessiblePos pos)]
interface AccessiblePos {
interface AccessiblePos {
  AccessiblePos? move(AccessibleElement anchor, Offset offset);
  AccessiblePos? move(DOMPoint);
  AccessiblePos? move(Where where, Matcher);
  AccessiblePos? search(Where where, Matcher);
   readonly attribute AccessibleElement root;
   readonly attribute AccessibleElement root;
   readonly attribute AccessibleElement? anchor;
   readonly attribute AccessibleElement? anchor;
Line 542: Line 544:
   long compare(AccessiblePos pos);
   long compare(AccessiblePos pos);


  AccessiblePos move(AccessibleElement anchor, Offset offset);
  AccessiblePos move(Point, optional Matcher);
  AccessiblePos move(Where where, Matcher);
  AccessiblePos search(Where where, Matcher);
};
};


Line 555: Line 552:
====Construction====
====Construction====
<code>
<code>
AccessiblePos .''Constructor''
AccessiblePos .''Constructor''(AccessibleElement, Offset, AccessibleElement)
::Constructs the accessible position.
::Constructs the accessible position.
::Parameters
::Parameters
Line 566: Line 563:
</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);
var pos = new AccessiblePos(elm, "at").move("backward", matcher);
var pos2 = new AccessiblePos(pos).move("forward", matcher);
or
var pos2 = pos.search("forward", matcher);
</pre>
<pre>
function getText() {
  var p = new A11ePos().move("first", a => a.role == "paragraph");
  var startPos;
  return p.then(function(pos) {
    startPos = pos;
    return pos.search("forward", a => "line"); }).
  then(function(endPos) {
    return startPos.textInBetween(endPos);
  };
}
getText().then(function(text) { /* Say text */ })
</pre>
<pre>
function getText()
{
  var startPos = new A11ePos().move("first", a => a.role == "paragraph");
  var endPos = startPos.search("forward", a => [ "line", "stop" ]);
  return startPos.textInBeetween(startPos, endPos);
}
say(getText());
</pre>


<pre>
<pre>
Line 634: Line 591:


<code>
<code>
OffsetLiterals .''insidestart''
OffsetLiterals .''inside start''
::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>
OffsetLiterals .''insideend''
OffsetLiterals .''inside end''
::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 645: Line 602:


<code>
<code>
AccessiblePos .''Constructor''(Point, AccessibleElement)
::Constructs the accessible position.
::Parameters
:::''point'' of ''DOMPoint''
::::the point the accessible position should be set at
:::''root'' of ''AccessibleElement'', optional
::::root of subtree the position will belong to. If missed then document the anchor resides in is used.
AccessiblePos .''Constructor''
AccessiblePos .''Constructor''
::Constructs the accessible position equal to given position.
::Constructs the accessible position equal to given position.
Line 651: Line 616:
::::accessible position to copy
::::accessible position to copy
</code>
</code>
<pre>
var pos1 = new AccessiblePos(new DOMPoint(x, y), document.accessibleElement);
var pos2 = new AccessiblePos(button.accessibleElement, "at");
var pos3 = new AccessiblePos(pos2);
</pre>


====Move through the content====
====Move through the content====


<code>
<code>
AccessiblePos .''move''
AccessiblePos .''move''(Accessilbe Element, Offset)
::Move the accessible position in the content. Returns true if succeeded.
::Move the accessible position to the given anchor and offset.
::Parameters
::Parameters
:::''element'' of ''AccessibleElement''
:::''element'' of ''AccessibleElement''
Line 758: Line 732:
SearchTerm .''at''
SearchTerm .''at''
::Used to set the position at the element. Search is stopped.
::Used to set the position at the element. Search is stopped.
</code>


<code>
SearchTerm .''stop''
SearchTerm .''stop''
::Search is discontinued after other search terms are processed.
::Search is discontinued after other search terms are processed.
</code>


SearchTerm .''skipsubtree''
SearchTerm .''skipsubtree''
::Subtree of traversed element is ignored for next step.
::Subtree of traversed element is ignored for next step.


<code>
SearchTerm .''next''
SearchTerm .''next''
::Used to continue the search. Default option.
::Used to continue the search. Default option.
</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);
var pos = new AccessiblePos(elm, "at").move("backward", matcher);
var pos2 = new AccessiblePos(pos).move("forward", matcher);
or
var pos2 = pos.search("forward", matcher);
</pre>
<pre>
function getText() {
  var p = new A11ePos().move("first", a => a.role == "paragraph");
  var startPos;
  return p.then(function(pos) {
    startPos = pos;
    return pos.search("forward", a => "line"); }).
  then(function(endPos) {
    return startPos.textInBetween(endPos);
  };
}
getText().then(function(text) { /* Say text */ })
</pre>
<pre>
function getText()
{
  var startPos = new A11ePos().move("first", a => a.role == "paragraph");
  var endPos = startPos.search("forward", a => [ "line", "stop" ]);
  return startPos.textInBeetween(startPos, endPos);
}
say(getText());
</pre>


<pre>
<pre>
Line 793: Line 804:


[
[
Questions:
 
Questions/concerns:
* 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 *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 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?
* Do we need isAnyOf() method additionally?
* Yura: we should have async API for search.
]
]


Confirmed users
1,396

edits

Navigation menu