Accessibility/WebAccessibilityAPI: Difference between revisions

Line 1,201: Line 1,201:
::Toggle the state on the accessible element.
::Toggle the state on the accessible element.
</code>
</code>
</pre>


<b>Example.</b>
<b>Example.</b>
Line 1,364: Line 1,363:


or set it directly on the accessible element
or set it directly on the accessible element
<pre>
document.getElementById("btn").a11ement.name = "new name";
document.getElementById("btn").a11ement.name = "new name";
</pre>
</pre>


or by setting its accessible source
or by setting its accessible source
Line 1,479: Line 1,478:
In case if interactions cannot be provided then the accessible source have to implement <code>activate</code> method to invoke actions.
In case if interactions cannot be provided then the accessible source have to implement <code>activate</code> method to invoke actions.


===Keeping updated===


An accessible source property change may require to notify the browser. The browser will fire accessible events and update its cache if necessary. Decision when to notify the browser or not should be based on accessible events model. In other words if the property change in native markup causes an accessible event then same change in accessible source requires it too.
===Feedback===
 
An accessible element may be notified of any kind of event, including its accessible source property change. In case of notification the browser will fire accessible events and update its cache if necessary. Decision when to notify the browser or not should be based on accessible events model. In other words if the property change in native markup causes an accessible event then same change in accessible source requires it too.


<pre>
<pre>
partial interface AccessibleElement {
partial interface AccessibleElement {
   void notifyOf(DOMString prop, optional any value);
   void notifyOf(DOMString eventType, optional Object attrs);
};
};
</pre>
</pre>
Line 1,497: Line 1,497:
::::Name of the property like ''role'' or ''state''
::::Name of the property like ''role'' or ''state''
:::value
:::value
::::Value of changed property, used for complex properties like ''states''. In this case it points to the changed ''state''.
::::Value describing the event.
</code>
</code>


Line 1,504: Line 1,504:


<pre>
<pre>
<script>
function states(aStates, aAccElm)
{
  this.set = function(aState) {
    this.mStates.add(aState);
    this.mAccElm.notifyOf("states", [ [ "added", aState ] ]);
  }
  this.unset = function(aState) {
    this.mStates.delete(aStates);
    this.mAccElm.notifyOf("states", [ [ "removed", aState ] ]);
  }
  this.has = function(aState) {
    return this.mStates.has(aStates);
  }
  this.mStates = new Set(aStates);
  this.mAccElm = aAccElm;
}
var listboxSource = {
var listboxSource = {
   role: "listbox",
   role: "listbox",
   get states() { return this.statesObj.values(); }
   name: "breed list",
  states: "disabled",


   statesObj: new states("focusable");
   get element() { return this.elm; }
  set element(aElm) {
    this.elm = aElm;
    this.elm.notifyOf("change:name");
    this.elm.notifyOf("change:states", { added: "disabled" });
  }
};
};
function disableEnable()
{
  var states = listboxSource.statesObj;
  if (states.has("disabled"))
    states.unset("disabled");
  else
    states.set("disabled");
}
</script>
</pre>
</pre>


Confirmed users
1,396

edits