2012-04-13 23:18:57 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
const Cr = Components.results;
|
|
|
|
|
2012-06-20 21:07:51 +00:00
|
|
|
Cu.import('resource://gre/modules/accessibility/Utils.jsm');
|
2012-04-13 23:18:57 +00:00
|
|
|
Cu.import('resource://gre/modules/accessibility/UtteranceGenerator.jsm');
|
|
|
|
|
|
|
|
var EXPORTED_SYMBOLS = ['VisualPresenter',
|
|
|
|
'AndroidPresenter',
|
2012-05-18 18:56:38 +00:00
|
|
|
'DummyAndroidPresenter',
|
|
|
|
'PresenterContext'];
|
2012-04-13 23:18:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The interface for all presenter classes. A presenter could be, for example,
|
|
|
|
* a speech output module, or a visual cursor indicator.
|
|
|
|
*/
|
|
|
|
function Presenter() {}
|
|
|
|
|
|
|
|
Presenter.prototype = {
|
|
|
|
/**
|
|
|
|
* Attach function for presenter.
|
|
|
|
* @param {ChromeWindow} aWindow Chrome window the presenter could use.
|
|
|
|
*/
|
|
|
|
attach: function attach(aWindow) {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Detach function.
|
|
|
|
*/
|
|
|
|
detach: function detach() {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The virtual cursor's position changed.
|
2012-05-18 18:56:38 +00:00
|
|
|
* @param {PresenterContext} aContext the context object for the new pivot
|
|
|
|
* position.
|
2012-04-13 23:18:57 +00:00
|
|
|
*/
|
2012-05-18 18:56:38 +00:00
|
|
|
pivotChanged: function pivotChanged(aContext) {},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An object's action has been invoked.
|
|
|
|
* @param {nsIAccessible} aObject the object that has been invoked.
|
|
|
|
* @param {string} aActionName the name of the action.
|
|
|
|
*/
|
|
|
|
actionInvoked: function actionInvoked(aObject, aActionName) {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Text has changed, either by the user or by the system. TODO.
|
|
|
|
*/
|
2012-05-14 21:21:59 +00:00
|
|
|
textChanged: function textChanged(aIsInserted, aStartOffset,
|
|
|
|
aLength, aText,
|
|
|
|
aModifiedText) {},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Text selection has changed. TODO.
|
|
|
|
*/
|
|
|
|
textSelectionChanged: function textSelectionChanged() {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selection has changed. TODO.
|
|
|
|
* @param {nsIAccessible} aObject the object that has been selected.
|
|
|
|
*/
|
|
|
|
selectionChanged: function selectionChanged(aObject) {},
|
|
|
|
|
|
|
|
/**
|
2012-05-07 16:44:44 +00:00
|
|
|
* The tab, or the tab's document state has changed.
|
|
|
|
* @param {nsIAccessible} aDocObj the tab document accessible that has had its
|
|
|
|
* state changed, or null if the tab has no associated document yet.
|
|
|
|
* @param {string} aPageState the state name for the tab, valid states are:
|
|
|
|
* 'newtab', 'loading', 'newdoc', 'loaded', 'stopped', and 'reload'.
|
2012-04-13 23:18:57 +00:00
|
|
|
*/
|
2012-05-07 16:44:44 +00:00
|
|
|
tabStateChanged: function tabStateChanged(aDocObj, aPageState) {},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-05-07 16:44:44 +00:00
|
|
|
* The current tab has changed.
|
2012-05-18 18:56:38 +00:00
|
|
|
* @param {PresenterContext} aDocContext context object for tab's
|
|
|
|
* document.
|
|
|
|
* @param {PresenterContext} aVCContext context object for tab's current
|
|
|
|
* virtual cursor position.
|
2012-04-13 23:18:57 +00:00
|
|
|
*/
|
2012-05-18 18:56:38 +00:00
|
|
|
tabSelected: function tabSelected(aDocContext, aVCContext) {},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The viewport has changed, either a scroll, pan, zoom, or
|
|
|
|
* landscape/portrait toggle.
|
|
|
|
*/
|
|
|
|
viewportChanged: function viewportChanged() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Visual presenter. Draws a box around the virtual cursor's position.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function VisualPresenter() {}
|
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
VisualPresenter.prototype = {
|
|
|
|
__proto__: Presenter.prototype,
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
/**
|
|
|
|
* The padding in pixels between the object and the highlight border.
|
|
|
|
*/
|
|
|
|
BORDER_PADDING: 2,
|
|
|
|
|
|
|
|
attach: function VisualPresenter_attach(aWindow) {
|
|
|
|
this.chromeWin = aWindow;
|
|
|
|
|
|
|
|
// Add stylesheet
|
|
|
|
let stylesheetURL = 'chrome://global/content/accessibility/AccessFu.css';
|
|
|
|
this.stylesheet = aWindow.document.createProcessingInstruction(
|
|
|
|
'xml-stylesheet', 'href="' + stylesheetURL + '" type="text/css"');
|
|
|
|
aWindow.document.insertBefore(this.stylesheet, aWindow.document.firstChild);
|
|
|
|
|
|
|
|
// Add highlight box
|
|
|
|
this.highlightBox = this.chromeWin.document.
|
|
|
|
createElementNS('http://www.w3.org/1999/xhtml', 'div');
|
|
|
|
this.chromeWin.document.documentElement.appendChild(this.highlightBox);
|
|
|
|
this.highlightBox.id = 'virtual-cursor-box';
|
|
|
|
|
|
|
|
// Add highlight inset for inner shadow
|
|
|
|
let inset = this.chromeWin.document.
|
|
|
|
createElementNS('http://www.w3.org/1999/xhtml', 'div');
|
|
|
|
inset.id = 'virtual-cursor-inset';
|
|
|
|
|
|
|
|
this.highlightBox.appendChild(inset);
|
|
|
|
},
|
|
|
|
|
|
|
|
detach: function VisualPresenter_detach() {
|
|
|
|
this.chromeWin.document.removeChild(this.stylesheet);
|
|
|
|
this.highlightBox.parentNode.removeChild(this.highlightBox);
|
|
|
|
this.highlightBox = this.stylesheet = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
viewportChanged: function VisualPresenter_viewportChanged() {
|
|
|
|
if (this._currentObject)
|
|
|
|
this._highlight(this._currentObject);
|
|
|
|
},
|
|
|
|
|
2012-05-18 18:56:38 +00:00
|
|
|
pivotChanged: function VisualPresenter_pivotChanged(aContext) {
|
|
|
|
this._currentObject = aContext.accessible;
|
2012-05-14 21:21:59 +00:00
|
|
|
|
2012-05-18 18:56:38 +00:00
|
|
|
if (!aContext.accessible) {
|
2012-05-14 21:21:59 +00:00
|
|
|
this._hide();
|
|
|
|
return;
|
|
|
|
}
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
try {
|
2012-05-18 18:56:38 +00:00
|
|
|
aContext.accessible.scrollTo(
|
|
|
|
Ci.nsIAccessibleScrollType.SCROLL_TYPE_ANYWHERE);
|
|
|
|
this._highlight(aContext.accessible);
|
2012-05-14 21:21:59 +00:00
|
|
|
} catch (e) {
|
2012-06-20 21:07:51 +00:00
|
|
|
Logger.error('Failed to get bounds: ' + e);
|
2012-05-14 21:21:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-18 18:56:38 +00:00
|
|
|
tabSelected: function VisualPresenter_tabSelected(aDocContext, aVCContext) {
|
|
|
|
this.pivotChanged(aVCContext);
|
2012-05-14 21:21:59 +00:00
|
|
|
},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
tabStateChanged: function VisualPresenter_tabStateChanged(aDocObj,
|
|
|
|
aPageState) {
|
|
|
|
if (aPageState == 'newdoc')
|
2012-05-18 18:56:38 +00:00
|
|
|
this._hide();
|
2012-05-14 21:21:59 +00:00
|
|
|
},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
// Internals
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
_hide: function _hide() {
|
|
|
|
this.highlightBox.style.display = 'none';
|
|
|
|
},
|
2012-05-07 16:44:44 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
_highlight: function _highlight(aObject) {
|
2012-06-20 21:07:51 +00:00
|
|
|
let vp = Utils.getViewport(this.chromeWin) || { zoom: 1.0, offsetY: 0 };
|
2012-05-14 21:21:59 +00:00
|
|
|
let bounds = this._getBounds(aObject, vp.zoom);
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
// First hide it to avoid flickering when changing the style.
|
|
|
|
this.highlightBox.style.display = 'none';
|
|
|
|
this.highlightBox.style.top = bounds.top + 'px';
|
|
|
|
this.highlightBox.style.left = bounds.left + 'px';
|
|
|
|
this.highlightBox.style.width = bounds.width + 'px';
|
|
|
|
this.highlightBox.style.height = bounds.height + 'px';
|
|
|
|
this.highlightBox.style.display = 'block';
|
|
|
|
},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
_getBounds: function _getBounds(aObject, aZoom, aStart, aEnd) {
|
|
|
|
let objX = {}, objY = {}, objW = {}, objH = {};
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
if (aEnd >= 0 && aStart >= 0 && aEnd != aStart) {
|
|
|
|
// TODO: Get bounds for text ranges. Leaving this blank until we have
|
|
|
|
// proper text navigation in the virtual cursor.
|
|
|
|
}
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
aObject.getBounds(objX, objY, objW, objH);
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
// Can't specify relative coords in nsIAccessible.getBounds, so we do it.
|
|
|
|
let docX = {}, docY = {};
|
|
|
|
let docRoot = aObject.rootDocument.QueryInterface(Ci.nsIAccessible);
|
|
|
|
docRoot.getBounds(docX, docY, {}, {});
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
let rv = {
|
|
|
|
left: Math.round((objX.value - docX.value - this.BORDER_PADDING) * aZoom),
|
|
|
|
top: Math.round((objY.value - docY.value - this.BORDER_PADDING) * aZoom),
|
|
|
|
width: Math.round((objW.value + (this.BORDER_PADDING * 2)) * aZoom),
|
|
|
|
height: Math.round((objH.value + (this.BORDER_PADDING * 2)) * aZoom)
|
|
|
|
};
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
return rv;
|
2012-04-13 23:18:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Android presenter. Fires Android a11y events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function AndroidPresenter() {}
|
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
AndroidPresenter.prototype = {
|
|
|
|
__proto__: Presenter.prototype,
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
// Android AccessibilityEvent type constants.
|
|
|
|
ANDROID_VIEW_CLICKED: 0x01,
|
|
|
|
ANDROID_VIEW_LONG_CLICKED: 0x02,
|
|
|
|
ANDROID_VIEW_SELECTED: 0x04,
|
|
|
|
ANDROID_VIEW_FOCUSED: 0x08,
|
|
|
|
ANDROID_VIEW_TEXT_CHANGED: 0x10,
|
|
|
|
ANDROID_WINDOW_STATE_CHANGED: 0x20,
|
2012-06-25 17:34:52 +00:00
|
|
|
ANDROID_VIEW_SCROLLED: 0x1000,
|
|
|
|
|
|
|
|
attach: function AndroidPresenter_attach(aWindow) {
|
|
|
|
this.chromeWin = aWindow;
|
|
|
|
},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-18 18:56:38 +00:00
|
|
|
pivotChanged: function AndroidPresenter_pivotChanged(aContext) {
|
2012-05-22 18:01:39 +00:00
|
|
|
if (!aContext.accessible)
|
|
|
|
return;
|
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
let output = [];
|
2012-05-29 20:46:08 +00:00
|
|
|
aContext.newAncestry.forEach(
|
2012-06-20 21:07:51 +00:00
|
|
|
function(acc) {
|
2012-05-29 20:46:08 +00:00
|
|
|
output.push.apply(output, UtteranceGenerator.genForObject(acc));
|
|
|
|
}
|
|
|
|
);
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
output.push.apply(output,
|
2012-05-29 20:46:08 +00:00
|
|
|
UtteranceGenerator.genForObject(aContext.accessible));
|
|
|
|
|
|
|
|
aContext.subtreePreorder.forEach(
|
2012-06-20 21:07:51 +00:00
|
|
|
function(acc) {
|
2012-05-29 20:46:08 +00:00
|
|
|
output.push.apply(output, UtteranceGenerator.genForObject(acc));
|
|
|
|
}
|
|
|
|
);
|
2012-05-14 21:21:59 +00:00
|
|
|
|
|
|
|
this.sendMessageToJava({
|
|
|
|
gecko: {
|
|
|
|
type: 'Accessibility:Event',
|
|
|
|
eventType: this.ANDROID_VIEW_FOCUSED,
|
|
|
|
text: output
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
actionInvoked: function AndroidPresenter_actionInvoked(aObject, aActionName) {
|
|
|
|
this.sendMessageToJava({
|
|
|
|
gecko: {
|
|
|
|
type: 'Accessibility:Event',
|
|
|
|
eventType: this.ANDROID_VIEW_CLICKED,
|
|
|
|
text: UtteranceGenerator.genForAction(aObject, aActionName)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-05-18 18:56:38 +00:00
|
|
|
tabSelected: function AndroidPresenter_tabSelected(aDocContext, aVCContext) {
|
2012-05-14 21:21:59 +00:00
|
|
|
// Send a pivot change message with the full context utterance for this doc.
|
2012-05-18 18:56:38 +00:00
|
|
|
this.pivotChanged(aVCContext);
|
2012-05-14 21:21:59 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
tabStateChanged: function AndroidPresenter_tabStateChanged(aDocObj,
|
|
|
|
aPageState) {
|
|
|
|
let stateUtterance = UtteranceGenerator.
|
|
|
|
genForTabStateChange(aDocObj, aPageState);
|
|
|
|
|
|
|
|
if (!stateUtterance.length)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.sendMessageToJava({
|
|
|
|
gecko: {
|
|
|
|
type: 'Accessibility:Event',
|
|
|
|
eventType: this.ANDROID_VIEW_TEXT_CHANGED,
|
|
|
|
text: stateUtterance,
|
|
|
|
addedCount: stateUtterance.join(' ').length,
|
|
|
|
removedCount: 0,
|
|
|
|
fromIndex: 0
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
textChanged: function AndroidPresenter_textChanged(aIsInserted, aStart,
|
|
|
|
aLength, aText,
|
|
|
|
aModifiedText) {
|
|
|
|
let androidEvent = {
|
2012-04-13 23:18:57 +00:00
|
|
|
type: 'Accessibility:Event',
|
2012-05-14 21:21:59 +00:00
|
|
|
eventType: this.ANDROID_VIEW_TEXT_CHANGED,
|
|
|
|
text: [aText],
|
2012-06-15 22:34:22 +00:00
|
|
|
fromIndex: aStart,
|
|
|
|
removedCount: 0,
|
|
|
|
addedCount: 0
|
2012-05-14 21:21:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (aIsInserted) {
|
|
|
|
androidEvent.addedCount = aLength;
|
|
|
|
androidEvent.beforeText =
|
|
|
|
aText.substring(0, aStart) + aText.substring(aStart + aLength);
|
|
|
|
} else {
|
|
|
|
androidEvent.removedCount = aLength;
|
|
|
|
androidEvent.beforeText =
|
|
|
|
aText.substring(0, aStart) + aModifiedText + aText.substring(aStart);
|
2012-04-13 23:18:57 +00:00
|
|
|
}
|
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
this.sendMessageToJava({gecko: androidEvent});
|
|
|
|
},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-06-25 17:34:52 +00:00
|
|
|
viewportChanged: function AndroidPresenter_viewportChanged() {
|
|
|
|
if (Utils.AndroidSdkVersion < 14)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let win = Utils.getBrowserApp(this.chromeWin).selectedBrowser.contentWindow;
|
|
|
|
this.sendMessageToJava({
|
|
|
|
gecko: {
|
|
|
|
type: 'Accessibility:Event',
|
|
|
|
eventType: this.ANDROID_VIEW_SCROLLED,
|
|
|
|
text: [],
|
|
|
|
scrollX: win.scrollX,
|
|
|
|
scrollY: win.scrollY,
|
|
|
|
maxScrollX: win.scrollMaxX,
|
|
|
|
maxScrollY: win.scrollMaxY
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
sendMessageToJava: function AndroidPresenter_sendMessageTojava(aMessage) {
|
|
|
|
return Cc['@mozilla.org/android/bridge;1'].
|
|
|
|
getService(Ci.nsIAndroidBridge).
|
|
|
|
handleGeckoMessage(JSON.stringify(aMessage));
|
2012-05-07 16:44:44 +00:00
|
|
|
}
|
2012-04-13 23:18:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A dummy Android presenter for desktop testing
|
|
|
|
*/
|
|
|
|
|
|
|
|
function DummyAndroidPresenter() {}
|
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
DummyAndroidPresenter.prototype = {
|
|
|
|
__proto__: AndroidPresenter.prototype,
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-14 21:21:59 +00:00
|
|
|
sendMessageToJava: function DummyAndroidPresenter_sendMessageToJava(aMsg) {
|
2012-06-20 21:07:51 +00:00
|
|
|
Logger.debug('Android event:\n' + JSON.stringify(aMsg, null, 2));
|
2012-05-14 21:21:59 +00:00
|
|
|
}
|
2012-04-13 23:18:57 +00:00
|
|
|
};
|
2012-05-18 18:56:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PresenterContext: An object that generates and caches context information
|
|
|
|
* for a given accessible and its relationship with another accessible.
|
|
|
|
*/
|
|
|
|
function PresenterContext(aAccessible, aOldAccessible) {
|
|
|
|
this._accessible = aAccessible;
|
2012-05-22 18:01:39 +00:00
|
|
|
this._oldAccessible =
|
|
|
|
this._isDefunct(aOldAccessible) ? null : aOldAccessible;
|
2012-05-18 18:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PresenterContext.prototype = {
|
|
|
|
get accessible() {
|
|
|
|
return this._accessible;
|
|
|
|
},
|
|
|
|
|
|
|
|
get oldAccessible() {
|
|
|
|
return this._oldAccessible;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a list of the accessible's ancestry up to the common ancestor
|
|
|
|
* of the accessible and the old accessible. It is useful for giving the
|
|
|
|
* user context as to where they are in the heirarchy.
|
|
|
|
*/
|
|
|
|
get newAncestry() {
|
|
|
|
if (!this._newAncestry) {
|
|
|
|
let newLineage = [];
|
|
|
|
let oldLineage = [];
|
|
|
|
|
|
|
|
let parent = this._accessible;
|
2012-05-29 20:46:08 +00:00
|
|
|
while (parent && (parent = parent.parent))
|
2012-05-18 18:56:38 +00:00
|
|
|
newLineage.push(parent);
|
|
|
|
|
2012-05-29 20:46:08 +00:00
|
|
|
parent = this._oldAccessible;
|
|
|
|
while (parent && (parent = parent.parent))
|
|
|
|
oldLineage.push(parent);
|
2012-05-18 18:56:38 +00:00
|
|
|
|
|
|
|
this._newAncestry = [];
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
let newAncestor = newLineage.pop();
|
|
|
|
let oldAncestor = oldLineage.pop();
|
|
|
|
|
|
|
|
if (newAncestor == undefined)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (newAncestor != oldAncestor)
|
|
|
|
this._newAncestry.push(newAncestor);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._newAncestry;
|
2012-05-22 18:01:39 +00:00
|
|
|
},
|
|
|
|
|
2012-05-29 20:46:08 +00:00
|
|
|
/*
|
|
|
|
* This is a flattened list of the accessible's subtree in preorder.
|
|
|
|
* It only includes the accessible's visible chidren.
|
|
|
|
*/
|
|
|
|
get subtreePreorder() {
|
|
|
|
function traversePreorder(aAccessible) {
|
|
|
|
let list = [];
|
|
|
|
let child = aAccessible.firstChild;
|
|
|
|
while (child) {
|
|
|
|
let state = {};
|
|
|
|
child.getState(state, {});
|
|
|
|
|
|
|
|
if (!(state.value & Ci.nsIAccessibleStates.STATE_INVISIBLE)) {
|
|
|
|
list.push(child);
|
|
|
|
list.push.apply(list, traversePreorder(child));
|
|
|
|
}
|
|
|
|
|
|
|
|
child = child.nextSibling;
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this._subtreePreOrder)
|
|
|
|
this._subtreePreOrder = traversePreorder(this._accessible);
|
|
|
|
|
|
|
|
return this._subtreePreOrder;
|
|
|
|
},
|
|
|
|
|
2012-05-22 18:01:39 +00:00
|
|
|
_isDefunct: function _isDefunct(aAccessible) {
|
|
|
|
try {
|
|
|
|
let extstate = {};
|
|
|
|
aAccessible.getState({}, extstate);
|
|
|
|
return !!(aAccessible.value & Ci.nsIAccessibleStates.EXT_STATE_DEFUNCT);
|
|
|
|
} catch (x) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-05-18 18:56:38 +00:00
|
|
|
}
|
|
|
|
};
|