2012-04-13 16:18:57 -07: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;
|
|
|
|
|
2013-06-17 07:36:41 -07:00
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Utils',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Logger',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'PivotContext',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'UtteranceGenerator',
|
|
|
|
'resource://gre/modules/accessibility/OutputGenerator.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'BrailleGenerator',
|
|
|
|
'resource://gre/modules/accessibility/OutputGenerator.jsm');
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-12-07 10:39:17 -08:00
|
|
|
this.EXPORTED_SYMBOLS = ['Presentation'];
|
2012-04-13 16:18:57 -07: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 = {
|
2012-10-01 13:33:26 -07:00
|
|
|
/**
|
|
|
|
* The type of presenter. Used for matching it with the appropriate output method.
|
|
|
|
*/
|
|
|
|
type: 'Base',
|
|
|
|
|
2012-04-13 16:18:57 -07:00
|
|
|
/**
|
|
|
|
* The virtual cursor's position changed.
|
2013-04-04 15:16:37 -07:00
|
|
|
* @param {PivotContext} aContext the context object for the new pivot
|
2012-05-18 11:56:38 -07:00
|
|
|
* position.
|
2012-06-25 10:34:52 -07:00
|
|
|
* @param {int} aReason the reason for the pivot change.
|
|
|
|
* See nsIAccessiblePivot.
|
2012-04-13 16:18:57 -07:00
|
|
|
*/
|
2012-06-25 10:34:52 -07:00
|
|
|
pivotChanged: function pivotChanged(aContext, aReason) {},
|
2012-04-13 16:18:57 -07: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 14:21:59 -07:00
|
|
|
textChanged: function textChanged(aIsInserted, aStartOffset,
|
|
|
|
aLength, aText,
|
|
|
|
aModifiedText) {},
|
2012-04-13 16:18:57 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Text selection has changed. TODO.
|
|
|
|
*/
|
2013-07-11 12:55:40 -07:00
|
|
|
textSelectionChanged: function textSelectionChanged(aText, aStart, aEnd, aOldStart, aOldEnd, aIsFromUser) {},
|
2012-04-13 16:18:57 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Selection has changed. TODO.
|
|
|
|
* @param {nsIAccessible} aObject the object that has been selected.
|
|
|
|
*/
|
|
|
|
selectionChanged: function selectionChanged(aObject) {},
|
|
|
|
|
|
|
|
/**
|
2012-05-07 09:44:44 -07: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 16:18:57 -07:00
|
|
|
*/
|
2012-05-07 09:44:44 -07:00
|
|
|
tabStateChanged: function tabStateChanged(aDocObj, aPageState) {},
|
2012-04-13 16:18:57 -07:00
|
|
|
|
|
|
|
/**
|
2012-05-07 09:44:44 -07:00
|
|
|
* The current tab has changed.
|
2013-04-04 15:16:37 -07:00
|
|
|
* @param {PivotContext} aDocContext context object for tab's
|
2012-05-18 11:56:38 -07:00
|
|
|
* document.
|
2013-04-04 15:16:37 -07:00
|
|
|
* @param {PivotContext} aVCContext context object for tab's current
|
2012-05-18 11:56:38 -07:00
|
|
|
* virtual cursor position.
|
2012-04-13 16:18:57 -07:00
|
|
|
*/
|
2012-05-18 11:56:38 -07:00
|
|
|
tabSelected: function tabSelected(aDocContext, aVCContext) {},
|
2012-04-13 16:18:57 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The viewport has changed, either a scroll, pan, zoom, or
|
|
|
|
* landscape/portrait toggle.
|
2012-10-01 13:33:26 -07:00
|
|
|
* @param {Window} aWindow window of viewport that changed.
|
2012-04-13 16:18:57 -07:00
|
|
|
*/
|
2012-10-01 13:33:26 -07:00
|
|
|
viewportChanged: function viewportChanged(aWindow) {},
|
2012-07-10 16:10:15 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* We have entered or left text editing mode.
|
|
|
|
*/
|
2012-12-07 10:39:17 -08:00
|
|
|
editingModeChanged: function editingModeChanged(aIsEditing) {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Announce something. Typically an app state change.
|
|
|
|
*/
|
|
|
|
announce: function announce(aAnnouncement) {}
|
2012-04-13 16:18:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Visual presenter. Draws a box around the virtual cursor's position.
|
|
|
|
*/
|
|
|
|
|
2013-07-03 15:02:44 -07:00
|
|
|
this.VisualPresenter = function VisualPresenter() {
|
|
|
|
this._displayedAccessibles = new WeakMap();
|
|
|
|
};
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-05-14 14:21:59 -07:00
|
|
|
VisualPresenter.prototype = {
|
|
|
|
__proto__: Presenter.prototype,
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
type: 'Visual',
|
|
|
|
|
2012-05-14 14:21:59 -07:00
|
|
|
/**
|
|
|
|
* The padding in pixels between the object and the highlight border.
|
|
|
|
*/
|
|
|
|
BORDER_PADDING: 2,
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
viewportChanged: function VisualPresenter_viewportChanged(aWindow) {
|
2013-07-03 15:02:44 -07:00
|
|
|
let currentAcc = this._displayedAccessibles.get(aWindow);
|
|
|
|
if (Utils.isAliveAndVisible(currentAcc)) {
|
|
|
|
let bounds = Utils.getBounds(currentAcc);
|
2012-10-01 13:33:26 -07:00
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: {
|
2012-12-07 10:39:17 -08:00
|
|
|
method: 'showBounds',
|
2013-07-03 15:02:44 -07:00
|
|
|
bounds: bounds,
|
2012-10-01 13:33:26 -07:00
|
|
|
padding: this.BORDER_PADDING
|
|
|
|
}
|
|
|
|
};
|
2012-10-17 10:23:26 -07:00
|
|
|
}
|
2012-10-01 13:33:26 -07:00
|
|
|
|
|
|
|
return null;
|
2012-05-14 14:21:59 -07:00
|
|
|
},
|
|
|
|
|
2012-06-25 10:34:52 -07:00
|
|
|
pivotChanged: function VisualPresenter_pivotChanged(aContext, aReason) {
|
2013-07-03 15:02:44 -07:00
|
|
|
this._displayedAccessibles.set(aContext.accessible.document.window,
|
|
|
|
aContext.accessible);
|
2012-05-14 14:21:59 -07:00
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
if (!aContext.accessible)
|
2012-12-07 10:39:17 -08:00
|
|
|
return {type: this.type, details: {method: 'hideBounds'}};
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-05-14 14:21:59 -07:00
|
|
|
try {
|
2012-05-18 11:56:38 -07:00
|
|
|
aContext.accessible.scrollTo(
|
|
|
|
Ci.nsIAccessibleScrollType.SCROLL_TYPE_ANYWHERE);
|
2012-10-01 13:33:26 -07:00
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: {
|
2012-12-07 10:39:17 -08:00
|
|
|
method: 'showBounds',
|
2012-10-01 13:33:26 -07:00
|
|
|
bounds: aContext.bounds,
|
|
|
|
padding: this.BORDER_PADDING
|
|
|
|
}
|
|
|
|
};
|
2012-05-14 14:21:59 -07:00
|
|
|
} catch (e) {
|
2013-06-27 14:15:36 -07:00
|
|
|
Logger.logException(e, 'Failed to get bounds');
|
2012-10-01 13:33:26 -07:00
|
|
|
return null;
|
2012-05-14 14:21:59 -07:00
|
|
|
}
|
|
|
|
},
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-05-18 11:56:38 -07:00
|
|
|
tabSelected: function VisualPresenter_tabSelected(aDocContext, aVCContext) {
|
2012-10-01 13:33:26 -07:00
|
|
|
return this.pivotChanged(aVCContext, Ci.nsIAccessiblePivot.REASON_NONE);
|
2012-05-14 14:21:59 -07:00
|
|
|
},
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-05-14 14:21:59 -07:00
|
|
|
tabStateChanged: function VisualPresenter_tabStateChanged(aDocObj,
|
|
|
|
aPageState) {
|
|
|
|
if (aPageState == 'newdoc')
|
2012-12-07 10:39:17 -08:00
|
|
|
return {type: this.type, details: {method: 'hideBounds'}};
|
2012-05-07 09:44:44 -07:00
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
return null;
|
2012-12-07 10:39:17 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
announce: function VisualPresenter_announce(aAnnouncement) {
|
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: {
|
|
|
|
method: 'showAnnouncement',
|
|
|
|
text: aAnnouncement,
|
|
|
|
duration: 1000
|
|
|
|
}
|
|
|
|
};
|
2012-04-13 16:18:57 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Android presenter. Fires Android a11y events.
|
|
|
|
*/
|
|
|
|
|
2012-11-12 15:46:09 -08:00
|
|
|
this.AndroidPresenter = function AndroidPresenter() {};
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-05-14 14:21:59 -07:00
|
|
|
AndroidPresenter.prototype = {
|
|
|
|
__proto__: Presenter.prototype,
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
type: 'Android',
|
|
|
|
|
2012-05-14 14:21:59 -07: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 10:34:52 -07:00
|
|
|
ANDROID_VIEW_HOVER_ENTER: 0x80,
|
|
|
|
ANDROID_VIEW_HOVER_EXIT: 0x100,
|
2012-06-25 10:34:52 -07:00
|
|
|
ANDROID_VIEW_SCROLLED: 0x1000,
|
2013-06-19 13:11:46 -07:00
|
|
|
ANDROID_VIEW_TEXT_SELECTION_CHANGED: 0x2000,
|
2012-08-20 15:29:22 -07:00
|
|
|
ANDROID_ANNOUNCEMENT: 0x4000,
|
|
|
|
ANDROID_VIEW_ACCESSIBILITY_FOCUSED: 0x8000,
|
2013-06-19 13:11:46 -07:00
|
|
|
ANDROID_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY: 0x20000,
|
2012-06-25 10:34:52 -07:00
|
|
|
|
2012-06-25 10:34:52 -07:00
|
|
|
pivotChanged: function AndroidPresenter_pivotChanged(aContext, aReason) {
|
2012-05-22 11:01:39 -07:00
|
|
|
if (!aContext.accessible)
|
2012-10-01 13:33:26 -07:00
|
|
|
return null;
|
2012-05-22 11:01:39 -07:00
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
let androidEvents = [];
|
|
|
|
|
2012-06-25 10:34:52 -07:00
|
|
|
let isExploreByTouch = (aReason == Ci.nsIAccessiblePivot.REASON_POINT &&
|
|
|
|
Utils.AndroidSdkVersion >= 14);
|
2012-08-20 15:29:22 -07:00
|
|
|
let focusEventType = (Utils.AndroidSdkVersion >= 16) ?
|
|
|
|
this.ANDROID_VIEW_ACCESSIBILITY_FOCUSED :
|
|
|
|
this.ANDROID_VIEW_FOCUSED;
|
2012-06-25 10:34:52 -07:00
|
|
|
|
|
|
|
if (isExploreByTouch) {
|
|
|
|
// This isn't really used by TalkBack so this is a half-hearted attempt
|
|
|
|
// for now.
|
2012-10-01 13:33:26 -07:00
|
|
|
androidEvents.push({eventType: this.ANDROID_VIEW_HOVER_EXIT, text: []});
|
2012-06-25 10:34:52 -07:00
|
|
|
}
|
|
|
|
|
2013-05-23 07:06:27 -07:00
|
|
|
let state = Utils.getStates(aContext.accessible)[0];
|
|
|
|
|
2013-07-11 12:55:40 -07:00
|
|
|
let brailleOutput = {};
|
2013-06-17 07:36:41 -07:00
|
|
|
if (Utils.AndroidSdkVersion >= 16) {
|
|
|
|
if (!this._braillePresenter) {
|
|
|
|
this._braillePresenter = new BraillePresenter();
|
|
|
|
}
|
2013-07-11 12:55:40 -07:00
|
|
|
brailleOutput = this._braillePresenter.pivotChanged(aContext, aReason).
|
2013-07-03 15:20:11 -07:00
|
|
|
details;
|
2013-06-17 07:36:41 -07:00
|
|
|
}
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
androidEvents.push({eventType: (isExploreByTouch) ?
|
|
|
|
this.ANDROID_VIEW_HOVER_ENTER : focusEventType,
|
2013-07-03 15:20:11 -07:00
|
|
|
text: UtteranceGenerator.genForContext(aContext).output,
|
2013-05-23 07:06:27 -07:00
|
|
|
bounds: aContext.bounds,
|
|
|
|
clickable: aContext.accessible.actionCount > 0,
|
|
|
|
checkable: !!(state &
|
|
|
|
Ci.nsIAccessibleStates.STATE_CHECKABLE),
|
|
|
|
checked: !!(state &
|
2013-06-17 07:36:41 -07:00
|
|
|
Ci.nsIAccessibleStates.STATE_CHECKED),
|
2013-07-11 12:55:40 -07:00
|
|
|
brailleOutput: brailleOutput});
|
2013-05-23 07:06:27 -07:00
|
|
|
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: androidEvents
|
|
|
|
};
|
2012-05-14 14:21:59 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
actionInvoked: function AndroidPresenter_actionInvoked(aObject, aActionName) {
|
2013-05-23 07:06:27 -07:00
|
|
|
let state = Utils.getStates(aObject)[0];
|
2012-10-01 13:33:26 -07:00
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: [{
|
2012-05-14 14:21:59 -07:00
|
|
|
eventType: this.ANDROID_VIEW_CLICKED,
|
2013-05-23 07:06:27 -07:00
|
|
|
text: UtteranceGenerator.genForAction(aObject, aActionName),
|
|
|
|
checked: !!(state & Ci.nsIAccessibleStates.STATE_CHECKED)
|
2012-10-01 13:33:26 -07:00
|
|
|
}]
|
|
|
|
};
|
2012-05-14 14:21:59 -07:00
|
|
|
},
|
|
|
|
|
2012-05-18 11:56:38 -07:00
|
|
|
tabSelected: function AndroidPresenter_tabSelected(aDocContext, aVCContext) {
|
2012-05-14 14:21:59 -07:00
|
|
|
// Send a pivot change message with the full context utterance for this doc.
|
2012-10-01 13:33:26 -07:00
|
|
|
return this.pivotChanged(aVCContext, Ci.nsIAccessiblePivot.REASON_NONE);
|
2012-05-14 14:21:59 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
tabStateChanged: function AndroidPresenter_tabStateChanged(aDocObj,
|
|
|
|
aPageState) {
|
2012-12-07 10:39:17 -08:00
|
|
|
return this.announce(
|
|
|
|
UtteranceGenerator.genForTabStateChange(aDocObj, aPageState).join(' '));
|
2012-05-14 14:21:59 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
textChanged: function AndroidPresenter_textChanged(aIsInserted, aStart,
|
|
|
|
aLength, aText,
|
|
|
|
aModifiedText) {
|
2012-10-19 13:39:37 -07:00
|
|
|
let eventDetails = {
|
|
|
|
eventType: this.ANDROID_VIEW_TEXT_CHANGED,
|
|
|
|
text: [aText],
|
|
|
|
fromIndex: aStart,
|
|
|
|
removedCount: 0,
|
|
|
|
addedCount: 0
|
2012-05-14 14:21:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
if (aIsInserted) {
|
2012-10-19 13:39:37 -07:00
|
|
|
eventDetails.addedCount = aLength;
|
|
|
|
eventDetails.beforeText =
|
2012-05-14 14:21:59 -07:00
|
|
|
aText.substring(0, aStart) + aText.substring(aStart + aLength);
|
|
|
|
} else {
|
2012-10-19 13:39:37 -07:00
|
|
|
eventDetails.removedCount = aLength;
|
|
|
|
eventDetails.beforeText =
|
2012-05-14 14:21:59 -07:00
|
|
|
aText.substring(0, aStart) + aModifiedText + aText.substring(aStart);
|
2012-04-13 16:18:57 -07:00
|
|
|
}
|
|
|
|
|
2012-10-19 13:39:37 -07:00
|
|
|
return {type: this.type, details: [eventDetails]};
|
2012-05-14 14:21:59 -07:00
|
|
|
},
|
2012-04-13 16:18:57 -07:00
|
|
|
|
2013-06-19 13:11:46 -07:00
|
|
|
textSelectionChanged: function AndroidPresenter_textSelectionChanged(aText, aStart,
|
|
|
|
aEnd, aOldStart,
|
2013-07-11 12:55:40 -07:00
|
|
|
aOldEnd, aIsFromUser) {
|
2013-06-19 13:11:46 -07:00
|
|
|
let androidEvents = [];
|
|
|
|
|
2013-07-11 12:55:40 -07:00
|
|
|
if (Utils.AndroidSdkVersion >= 14 && !aIsFromUser) {
|
|
|
|
if (!this._braillePresenter) {
|
|
|
|
this._braillePresenter = new BraillePresenter();
|
|
|
|
}
|
|
|
|
let brailleOutput = this._braillePresenter.textSelectionChanged(aText, aStart, aEnd,
|
|
|
|
aOldStart, aOldEnd,
|
|
|
|
aIsFromUser).details;
|
|
|
|
|
2013-06-19 13:11:46 -07:00
|
|
|
androidEvents.push({
|
|
|
|
eventType: this.ANDROID_VIEW_TEXT_SELECTION_CHANGED,
|
|
|
|
text: [aText],
|
|
|
|
fromIndex: aStart,
|
|
|
|
toIndex: aEnd,
|
2013-07-11 12:55:40 -07:00
|
|
|
itemCount: aText.length,
|
|
|
|
brailleOutput: brailleOutput
|
2013-06-19 13:11:46 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-07-11 12:55:40 -07:00
|
|
|
if (Utils.AndroidSdkVersion >= 16 && aIsFromUser) {
|
2013-06-19 13:11:46 -07:00
|
|
|
let [from, to] = aOldStart < aStart ? [aOldStart, aStart] : [aStart, aOldStart];
|
|
|
|
androidEvents.push({
|
|
|
|
eventType: this.ANDROID_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
|
|
|
|
text: [aText],
|
|
|
|
fromIndex: from,
|
|
|
|
toIndex: to
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: androidEvents
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
viewportChanged: function AndroidPresenter_viewportChanged(aWindow) {
|
2012-06-25 10:34:52 -07:00
|
|
|
if (Utils.AndroidSdkVersion < 14)
|
2012-10-01 13:33:26 -07:00
|
|
|
return null;
|
2012-06-25 10:34:52 -07:00
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: [{
|
2012-06-25 10:34:52 -07:00
|
|
|
eventType: this.ANDROID_VIEW_SCROLLED,
|
|
|
|
text: [],
|
2012-10-01 13:33:26 -07:00
|
|
|
scrollX: aWindow.scrollX,
|
|
|
|
scrollY: aWindow.scrollY,
|
|
|
|
maxScrollX: aWindow.scrollMaxX,
|
|
|
|
maxScrollY: aWindow.scrollMaxY
|
|
|
|
}]
|
|
|
|
};
|
2012-06-25 10:34:52 -07:00
|
|
|
},
|
|
|
|
|
2012-07-10 16:10:15 -07:00
|
|
|
editingModeChanged: function AndroidPresenter_editingModeChanged(aIsEditing) {
|
2012-12-07 10:39:17 -08:00
|
|
|
return this.announce(
|
|
|
|
UtteranceGenerator.genForEditingMode(aIsEditing).join(' '));
|
2012-07-10 16:10:15 -07:00
|
|
|
},
|
|
|
|
|
2012-12-07 10:39:17 -08:00
|
|
|
announce: function AndroidPresenter_announce(aAnnouncement) {
|
2012-10-01 13:33:26 -07:00
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: [{
|
2012-08-20 15:29:22 -07:00
|
|
|
eventType: (Utils.AndroidSdkVersion >= 16) ?
|
|
|
|
this.ANDROID_ANNOUNCEMENT : this.ANDROID_VIEW_TEXT_CHANGED,
|
2012-12-07 10:39:17 -08:00
|
|
|
text: [aAnnouncement],
|
|
|
|
addedCount: aAnnouncement.length,
|
2012-07-10 16:10:15 -07:00
|
|
|
removedCount: 0,
|
|
|
|
fromIndex: 0
|
2012-10-01 13:33:26 -07:00
|
|
|
}]
|
|
|
|
};
|
2012-05-14 14:21:59 -07:00
|
|
|
}
|
2012-04-13 16:18:57 -07:00
|
|
|
};
|
2012-05-18 11:56:38 -07:00
|
|
|
|
2012-07-20 09:46:54 -07:00
|
|
|
/**
|
|
|
|
* A speech presenter for direct TTS output
|
|
|
|
*/
|
|
|
|
|
2012-11-12 15:46:09 -08:00
|
|
|
this.SpeechPresenter = function SpeechPresenter() {};
|
2012-07-20 09:46:54 -07:00
|
|
|
|
|
|
|
SpeechPresenter.prototype = {
|
|
|
|
__proto__: Presenter.prototype,
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
type: 'Speech',
|
2012-07-20 09:46:54 -07:00
|
|
|
|
|
|
|
pivotChanged: function SpeechPresenter_pivotChanged(aContext, aReason) {
|
|
|
|
if (!aContext.accessible)
|
2012-10-01 13:33:26 -07:00
|
|
|
return null;
|
2012-07-20 09:46:54 -07:00
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: {
|
|
|
|
actions: [
|
|
|
|
{method: 'playEarcon', data: 'tick', options: {}},
|
2013-04-04 15:16:37 -07:00
|
|
|
{method: 'speak',
|
2013-07-03 15:20:11 -07:00
|
|
|
data: UtteranceGenerator.genForContext(aContext).output.join(' '),
|
2013-04-04 15:16:37 -07:00
|
|
|
options: {enqueue: true}}
|
2012-10-01 13:33:26 -07:00
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
2013-06-27 14:15:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
actionInvoked: function SpeechPresenter_actionInvoked(aObject, aActionName) {
|
|
|
|
return {
|
|
|
|
type: this.type,
|
|
|
|
details: {
|
|
|
|
actions: [
|
|
|
|
{method: 'speak',
|
|
|
|
data: UtteranceGenerator.genForAction(aObject, aActionName).join(' '),
|
|
|
|
options: {enqueue: false}}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
2012-07-20 09:46:54 -07:00
|
|
|
}
|
2012-10-01 13:33:26 -07:00
|
|
|
};
|
2012-11-12 15:46:09 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A haptic presenter
|
|
|
|
*/
|
|
|
|
|
|
|
|
this.HapticPresenter = function HapticPresenter() {};
|
|
|
|
|
|
|
|
HapticPresenter.prototype = {
|
|
|
|
__proto__: Presenter.prototype,
|
|
|
|
|
|
|
|
type: 'Haptic',
|
|
|
|
|
|
|
|
PIVOT_CHANGE_PATTHERN: [20],
|
|
|
|
|
|
|
|
pivotChanged: function HapticPresenter_pivotChanged(aContext, aReason) {
|
|
|
|
return { type: this.type, details: { pattern: this.PIVOT_CHANGE_PATTHERN } };
|
|
|
|
}
|
|
|
|
};
|
2012-07-20 09:46:54 -07:00
|
|
|
|
2013-06-17 07:36:41 -07:00
|
|
|
/**
|
|
|
|
* A braille presenter
|
|
|
|
*/
|
|
|
|
|
|
|
|
this.BraillePresenter = function BraillePresenter() {};
|
|
|
|
|
|
|
|
BraillePresenter.prototype = {
|
|
|
|
__proto__: Presenter.prototype,
|
|
|
|
|
|
|
|
type: 'Braille',
|
|
|
|
|
|
|
|
pivotChanged: function BraillePresenter_pivotChanged(aContext, aReason) {
|
|
|
|
if (!aContext.accessible) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-07-03 15:20:11 -07:00
|
|
|
let brailleOutput = BrailleGenerator.genForContext(aContext);
|
|
|
|
brailleOutput.output = brailleOutput.output.join(' ');
|
2013-07-11 12:55:40 -07:00
|
|
|
brailleOutput.selectionStart = 0;
|
|
|
|
brailleOutput.selectionEnd = 0;
|
2013-06-17 07:36:41 -07:00
|
|
|
|
2013-07-03 15:20:11 -07:00
|
|
|
return { type: this.type, details: brailleOutput };
|
2013-07-11 12:55:40 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
textSelectionChanged: function BraillePresenter_textSelectionChanged(aText, aStart,
|
|
|
|
aEnd, aOldStart,
|
|
|
|
aOldEnd, aIsFromUser) {
|
|
|
|
return { type: this.type,
|
|
|
|
details: { selectionStart: aStart,
|
|
|
|
selectionEnd: aEnd } };
|
|
|
|
},
|
|
|
|
|
2013-06-17 07:36:41 -07:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-12-07 10:39:17 -08:00
|
|
|
this.Presentation = {
|
|
|
|
get presenters() {
|
|
|
|
delete this.presenters;
|
|
|
|
this.presenters = [new VisualPresenter()];
|
|
|
|
|
2013-04-25 12:39:16 -07:00
|
|
|
if (Utils.MozBuildApp == 'mobile/android') {
|
|
|
|
this.presenters.push(new AndroidPresenter());
|
|
|
|
} else {
|
2012-12-07 10:39:17 -08:00
|
|
|
this.presenters.push(new SpeechPresenter());
|
|
|
|
this.presenters.push(new HapticPresenter());
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.presenters;
|
|
|
|
},
|
|
|
|
|
|
|
|
pivotChanged: function Presentation_pivotChanged(aPosition,
|
|
|
|
aOldPosition,
|
|
|
|
aReason) {
|
2013-04-04 15:16:37 -07:00
|
|
|
let context = new PivotContext(aPosition, aOldPosition);
|
2012-12-07 10:39:17 -08:00
|
|
|
return [p.pivotChanged(context, aReason)
|
|
|
|
for each (p in this.presenters)];
|
|
|
|
},
|
|
|
|
|
|
|
|
actionInvoked: function Presentation_actionInvoked(aObject, aActionName) {
|
|
|
|
return [p.actionInvoked(aObject, aActionName)
|
|
|
|
for each (p in this.presenters)];
|
|
|
|
},
|
|
|
|
|
|
|
|
textChanged: function Presentation_textChanged(aIsInserted, aStartOffset,
|
|
|
|
aLength, aText,
|
|
|
|
aModifiedText) {
|
|
|
|
return [p.textChanged(aIsInserted, aStartOffset, aLength,
|
|
|
|
aText, aModifiedText)
|
|
|
|
for each (p in this.presenters)];
|
|
|
|
},
|
|
|
|
|
2013-07-11 12:55:40 -07:00
|
|
|
textSelectionChanged: function textSelectionChanged(aText, aStart, aEnd,
|
|
|
|
aOldStart, aOldEnd,
|
|
|
|
aIsFromUser) {
|
|
|
|
return [p.textSelectionChanged(aText, aStart, aEnd,
|
|
|
|
aOldStart, aOldEnd, aIsFromUser)
|
2013-06-19 13:11:46 -07:00
|
|
|
for each (p in this.presenters)];
|
|
|
|
},
|
|
|
|
|
2012-12-07 10:39:17 -08:00
|
|
|
tabStateChanged: function Presentation_tabStateChanged(aDocObj, aPageState) {
|
|
|
|
return [p.tabStateChanged(aDocObj, aPageState)
|
|
|
|
for each (p in this.presenters)];
|
|
|
|
},
|
|
|
|
|
|
|
|
viewportChanged: function Presentation_viewportChanged(aWindow) {
|
|
|
|
return [p.viewportChanged(aWindow)
|
|
|
|
for each (p in this.presenters)];
|
|
|
|
},
|
|
|
|
|
|
|
|
editingModeChanged: function Presentation_editingModeChanged(aIsEditing) {
|
|
|
|
return [p.editingModeChanged(aIsEditing)
|
|
|
|
for each (p in this.presenters)];
|
2012-12-07 10:39:17 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
announce: function Presentation_announce(aAnnouncement) {
|
|
|
|
// XXX: Typically each presenter uses the UtteranceGenerator,
|
|
|
|
// but there really isn't a point here.
|
|
|
|
return [p.announce(UtteranceGenerator.genForAnnouncement(aAnnouncement)[0])
|
|
|
|
for each (p in this.presenters)];
|
2012-12-07 10:39:17 -08:00
|
|
|
}
|
|
|
|
};
|