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-06-19 13:11:46 -07:00
|
|
|
textSelectionChanged: function textSelectionChanged(aText, aStart, aEnd, aOldStart, aOldEnd) {},
|
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.
|
|
|
|
*/
|
|
|
|
|
2012-11-12 15:46:09 -08:00
|
|
|
this.VisualPresenter = function VisualPresenter() {};
|
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) {
|
2012-10-17 10:23:26 -07:00
|
|
|
if (this._currentAccessible) {
|
2013-04-04 15:16:37 -07:00
|
|
|
let context = new PivotContext(this._currentAccessible);
|
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-17 10:23:26 -07:00
|
|
|
bounds: context.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) {
|
2012-10-17 10:23:26 -07:00
|
|
|
this._currentAccessible = 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-06-17 07:36:41 -07:00
|
|
|
let brailleText = '';
|
|
|
|
if (Utils.AndroidSdkVersion >= 16) {
|
|
|
|
if (!this._braillePresenter) {
|
|
|
|
this._braillePresenter = new BraillePresenter();
|
|
|
|
}
|
|
|
|
brailleText = this._braillePresenter.pivotChanged(aContext, aReason).
|
|
|
|
details.text;
|
|
|
|
}
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
androidEvents.push({eventType: (isExploreByTouch) ?
|
|
|
|
this.ANDROID_VIEW_HOVER_ENTER : focusEventType,
|
2013-04-04 15:16:37 -07:00
|
|
|
text: UtteranceGenerator.genForContext(aContext),
|
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),
|
|
|
|
brailleText: brailleText});
|
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,
|
|
|
|
aOldEnd) {
|
|
|
|
let androidEvents = [];
|
|
|
|
|
|
|
|
if (Utils.AndroidSdkVersion >= 14) {
|
|
|
|
androidEvents.push({
|
|
|
|
eventType: this.ANDROID_VIEW_TEXT_SELECTION_CHANGED,
|
|
|
|
text: [aText],
|
|
|
|
fromIndex: aStart,
|
|
|
|
toIndex: aEnd,
|
|
|
|
itemCount: aText.length
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Utils.AndroidSdkVersion >= 16) {
|
|
|
|
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',
|
|
|
|
data: UtteranceGenerator.genForContext(aContext).join(' '),
|
|
|
|
options: {enqueue: true}}
|
2012-10-01 13:33:26 -07:00
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
let text = BrailleGenerator.genForContext(aContext);
|
|
|
|
|
|
|
|
return { type: this.type, details: {text: text.join(' ')} };
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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-06-19 13:11:46 -07:00
|
|
|
textSelectionChanged: function textSelectionChanged(aText, aStart, aEnd, aOldStart, aOldEnd) {
|
|
|
|
return [p.textSelectionChanged(aText, aStart, aEnd, aOldStart, aOldEnd)
|
|
|
|
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
|
|
|
}
|
|
|
|
};
|