2012-10-01 13:33:26 -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/. */
|
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
let Ci = Components.interfaces;
|
|
|
|
let Cu = Components.utils;
|
|
|
|
|
2013-07-24 14:52:57 -07:00
|
|
|
const MOVEMENT_GRANULARITY_CHARACTER = 1;
|
|
|
|
const MOVEMENT_GRANULARITY_WORD = 2;
|
|
|
|
const MOVEMENT_GRANULARITY_PARAGRAPH = 8;
|
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Logger',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Presentation',
|
|
|
|
'resource://gre/modules/accessibility/Presentation.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'TraversalRules',
|
|
|
|
'resource://gre/modules/accessibility/TraversalRules.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Utils',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'EventManager',
|
|
|
|
'resource://gre/modules/accessibility/EventManager.jsm');
|
2013-11-19 10:17:43 -08:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Roles',
|
|
|
|
'resource://gre/modules/accessibility/Constants.jsm');
|
2012-10-01 13:33:26 -07:00
|
|
|
|
|
|
|
Logger.debug('content-script.js');
|
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
let eventManager = null;
|
|
|
|
|
2014-02-11 10:41:02 -08:00
|
|
|
function clearCursor(aMessage) {
|
|
|
|
try {
|
|
|
|
Utils.getVirtualCursor(content.document).position = null;
|
|
|
|
forwardToChild(aMessage);
|
|
|
|
} catch (x) {
|
|
|
|
Logger.logException(x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
function moveCursor(aMessage) {
|
|
|
|
if (Logger.logLevel >= Logger.DEBUG) {
|
|
|
|
Logger.debug(aMessage.name, JSON.stringify(aMessage.json, null, ' '));
|
|
|
|
}
|
2012-10-01 13:33:26 -07:00
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
let vc = Utils.getVirtualCursor(content.document);
|
|
|
|
let origin = aMessage.json.origin;
|
|
|
|
let action = aMessage.json.action;
|
|
|
|
let rule = TraversalRules[aMessage.json.rule];
|
|
|
|
|
|
|
|
function moveCursorInner() {
|
|
|
|
try {
|
|
|
|
if (origin == 'parent' &&
|
|
|
|
!Utils.isAliveAndVisible(vc.position)) {
|
|
|
|
// We have a bad position in this frame, move vc to last or first item.
|
|
|
|
if (action == 'moveNext') {
|
|
|
|
return vc.moveFirst(rule);
|
|
|
|
} else if (action == 'movePrevious') {
|
|
|
|
return vc.moveLast(rule);
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
2013-07-16 11:45:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return vc[action](rule);
|
|
|
|
} catch (x) {
|
|
|
|
if (action == 'moveNext' || action == 'movePrevious') {
|
|
|
|
// If we are trying to move next/prev put the vc on the focused item.
|
2012-10-08 00:06:38 -07:00
|
|
|
let acc = Utils.AccRetrieval.
|
|
|
|
getAccessibleFor(content.document.activeElement);
|
2013-07-16 11:45:17 -07:00
|
|
|
return vc.moveNext(rule, acc, true);
|
|
|
|
} else {
|
|
|
|
throw x;
|
2012-10-19 10:06:08 -07:00
|
|
|
}
|
2013-07-16 11:45:17 -07:00
|
|
|
}
|
2012-10-19 10:06:08 -07:00
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (origin != 'child' &&
|
|
|
|
forwardToChild(aMessage, moveCursor, vc.position)) {
|
|
|
|
// We successfully forwarded the move to the child document.
|
|
|
|
return;
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
if (moveCursorInner()) {
|
|
|
|
// If we moved, try forwarding the message to the new position,
|
|
|
|
// it may be a frame with a vc of its own.
|
|
|
|
forwardToChild(aMessage, moveCursor, vc.position);
|
|
|
|
} else {
|
|
|
|
// If we did not move, we probably reached the end or start of the
|
|
|
|
// document, go back to parent content and move us out of the iframe.
|
2012-10-01 13:33:26 -07:00
|
|
|
if (origin == 'parent') {
|
|
|
|
vc.position = null;
|
|
|
|
}
|
2013-07-16 11:45:17 -07:00
|
|
|
forwardToParent(aMessage);
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
} catch (x) {
|
2013-07-16 11:45:17 -07:00
|
|
|
Logger.logException(x, 'Cursor move failed');
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
function moveToPoint(aMessage) {
|
|
|
|
if (Logger.logLevel >= Logger.DEBUG) {
|
|
|
|
Logger.debug(aMessage.name, JSON.stringify(aMessage.json, null, ' '));
|
|
|
|
}
|
|
|
|
|
|
|
|
let vc = Utils.getVirtualCursor(content.document);
|
|
|
|
let details = aMessage.json;
|
|
|
|
let rule = TraversalRules[details.rule];
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
try {
|
2013-07-17 13:41:29 -07:00
|
|
|
let dpr = content.devicePixelRatio;
|
|
|
|
vc.moveToPoint(rule, details.x * dpr, details.y * dpr, true);
|
2013-07-16 11:45:17 -07:00
|
|
|
forwardToChild(aMessage, moveToPoint, vc.position);
|
2012-10-01 13:33:26 -07:00
|
|
|
} catch (x) {
|
2013-07-16 11:45:17 -07:00
|
|
|
Logger.logException(x, 'Failed move to point');
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
2013-07-16 11:45:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function showCurrent(aMessage) {
|
|
|
|
if (Logger.logLevel >= Logger.DEBUG) {
|
|
|
|
Logger.debug(aMessage.name, JSON.stringify(aMessage.json, null, ' '));
|
|
|
|
}
|
|
|
|
|
|
|
|
let vc = Utils.getVirtualCursor(content.document);
|
|
|
|
|
|
|
|
if (!forwardToChild(vc, showCurrent, aMessage)) {
|
|
|
|
if (!vc.position && aMessage.json.move) {
|
|
|
|
vc.moveFirst(TraversalRules.Simple);
|
|
|
|
} else {
|
|
|
|
sendAsyncMessage('AccessFu:Present', Presentation.pivotChanged(
|
2013-07-24 14:52:57 -07:00
|
|
|
vc.position, null, Ci.nsIAccessiblePivot.REASON_NONE,
|
|
|
|
vc.startOffset, vc.endOffset));
|
2013-07-16 11:45:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function forwardToParent(aMessage) {
|
|
|
|
// XXX: This is a silly way to make a deep copy
|
|
|
|
let newJSON = JSON.parse(JSON.stringify(aMessage.json));
|
|
|
|
newJSON.origin = 'child';
|
|
|
|
sendAsyncMessage(aMessage.name, newJSON);
|
|
|
|
}
|
|
|
|
|
|
|
|
function forwardToChild(aMessage, aListener, aVCPosition) {
|
|
|
|
let acc = aVCPosition || Utils.getVirtualCursor(content.document).position;
|
|
|
|
|
2013-11-19 10:17:43 -08:00
|
|
|
if (!Utils.isAliveAndVisible(acc) || acc.role != Roles.INTERNAL_FRAME) {
|
2013-07-16 11:45:17 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Logger.logLevel >= Logger.DEBUG) {
|
|
|
|
Logger.debug('forwardToChild', Logger.accessibleToString(acc),
|
|
|
|
aMessage.name, JSON.stringify(aMessage.json, null, ' '));
|
|
|
|
}
|
|
|
|
|
|
|
|
let mm = Utils.getMessageManager(acc.DOMNode);
|
2014-02-11 10:41:02 -08:00
|
|
|
|
|
|
|
if (aListener) {
|
|
|
|
mm.addMessageListener(aMessage.name, aListener);
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
// XXX: This is a silly way to make a deep copy
|
|
|
|
let newJSON = JSON.parse(JSON.stringify(aMessage.json));
|
|
|
|
newJSON.origin = 'parent';
|
|
|
|
if (Utils.isContentProcess) {
|
|
|
|
// XXX: OOP content's screen offset is 0,
|
|
|
|
// so we remove the real screen offset here.
|
|
|
|
newJSON.x -= content.mozInnerScreenX;
|
|
|
|
newJSON.y -= content.mozInnerScreenY;
|
|
|
|
}
|
|
|
|
mm.sendAsyncMessage(aMessage.name, newJSON);
|
|
|
|
return true;
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function activateCurrent(aMessage) {
|
|
|
|
Logger.debug('activateCurrent');
|
|
|
|
function activateAccessible(aAccessible) {
|
2013-12-20 11:14:26 -08:00
|
|
|
try {
|
|
|
|
if (aMessage.json.activateIfKey &&
|
|
|
|
aAccessible.role != Roles.KEY) {
|
|
|
|
// Only activate keys, don't do anything on other objects.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// accessible is invalid. Silently fail.
|
2013-09-23 10:28:10 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
if (aAccessible.actionCount > 0) {
|
|
|
|
aAccessible.doAction(0);
|
|
|
|
} else {
|
2013-10-14 12:56:19 -07:00
|
|
|
let control = Utils.getEmbeddedControl(aAccessible);
|
|
|
|
if (control && control.actionCount > 0) {
|
|
|
|
control.doAction(0);
|
|
|
|
}
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
// XXX Some mobile widget sets do not expose actions properly
|
|
|
|
// (via ARIA roles, etc.), so we need to generate a click.
|
|
|
|
// Could possibly be made simpler in the future. Maybe core
|
|
|
|
// engine could expose nsCoreUtiles::DispatchMouseEvent()?
|
|
|
|
let docAcc = Utils.AccRetrieval.getAccessibleFor(content.document);
|
|
|
|
let docX = {}, docY = {}, docW = {}, docH = {};
|
|
|
|
docAcc.getBounds(docX, docY, docW, docH);
|
|
|
|
|
|
|
|
let objX = {}, objY = {}, objW = {}, objH = {};
|
|
|
|
aAccessible.getBounds(objX, objY, objW, objH);
|
|
|
|
|
|
|
|
let x = Math.round((objX.value - docX.value) + objW.value / 2);
|
|
|
|
let y = Math.round((objY.value - docY.value) + objH.value / 2);
|
|
|
|
|
2013-04-25 12:39:16 -07:00
|
|
|
let node = aAccessible.DOMNode || aAccessible.parent.DOMNode;
|
|
|
|
|
|
|
|
function dispatchMouseEvent(aEventType) {
|
2013-05-21 11:16:49 -07:00
|
|
|
let evt = content.document.createEvent('MouseEvents');
|
2013-04-25 12:39:16 -07:00
|
|
|
evt.initMouseEvent(aEventType, true, true, content,
|
|
|
|
x, y, 0, 0, 0, false, false, false, false, 0, null);
|
|
|
|
node.dispatchEvent(evt);
|
|
|
|
}
|
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
dispatchMouseEvent('mousedown');
|
|
|
|
dispatchMouseEvent('mouseup');
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
2013-11-26 16:53:45 -08:00
|
|
|
|
|
|
|
if (aAccessible.role !== Roles.KEY) {
|
|
|
|
// Keys will typically have a sound of their own.
|
|
|
|
sendAsyncMessage('AccessFu:Present',
|
|
|
|
Presentation.actionInvoked(aAccessible, 'click'));
|
|
|
|
}
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
|
2013-07-03 15:20:11 -07:00
|
|
|
function moveCaretTo(aAccessible, aOffset) {
|
|
|
|
let accText = aAccessible.QueryInterface(Ci.nsIAccessibleText);
|
|
|
|
let oldOffset = accText.caretOffset;
|
|
|
|
let text = accText.getText(0, accText.characterCount);
|
|
|
|
|
|
|
|
if (aOffset >= 0 && aOffset <= accText.characterCount) {
|
|
|
|
accText.caretOffset = aOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
presentCaretChange(text, oldOffset, accText.caretOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
let focusedAcc = Utils.AccRetrieval.getAccessibleFor(content.document.activeElement);
|
2013-11-19 10:17:43 -08:00
|
|
|
if (focusedAcc && focusedAcc.role === Roles.ENTRY) {
|
2013-07-03 15:20:11 -07:00
|
|
|
moveCaretTo(focusedAcc, aMessage.json.offset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
let position = Utils.getVirtualCursor(content.document).position;
|
|
|
|
if (!forwardToChild(aMessage, activateCurrent, position)) {
|
|
|
|
activateAccessible(position);
|
|
|
|
}
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
|
2013-06-03 11:29:14 -07:00
|
|
|
function activateContextMenu(aMessage) {
|
|
|
|
function sendContextMenuCoordinates(aAccessible) {
|
2013-07-16 04:49:00 -07:00
|
|
|
let bounds = Utils.getBounds(aAccessible);
|
2013-07-17 13:41:29 -07:00
|
|
|
sendAsyncMessage('AccessFu:ActivateContextMenu', {bounds: bounds});
|
2013-06-03 11:29:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-16 04:49:00 -07:00
|
|
|
let position = Utils.getVirtualCursor(content.document).position;
|
|
|
|
if (!forwardToChild(aMessage, activateContextMenu, position)) {
|
|
|
|
sendContextMenuCoordinates(position);
|
2013-07-16 11:45:17 -07:00
|
|
|
}
|
2013-06-03 11:29:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-24 14:52:57 -07:00
|
|
|
function moveByGranularity(aMessage) {
|
|
|
|
let direction = aMessage.json.direction;
|
|
|
|
let vc = Utils.getVirtualCursor(content.document);
|
|
|
|
let granularity;
|
|
|
|
|
|
|
|
switch(aMessage.json.granularity) {
|
|
|
|
case MOVEMENT_GRANULARITY_CHARACTER:
|
|
|
|
granularity = Ci.nsIAccessiblePivot.CHAR_BOUNDARY;
|
|
|
|
break;
|
|
|
|
case MOVEMENT_GRANULARITY_WORD:
|
|
|
|
granularity = Ci.nsIAccessiblePivot.WORD_BOUNDARY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2013-06-19 13:11:46 -07:00
|
|
|
|
2013-07-24 14:52:57 -07:00
|
|
|
if (direction === 'Previous') {
|
|
|
|
vc.movePreviousByText(granularity);
|
|
|
|
} else if (direction === 'Next') {
|
|
|
|
vc.moveNextByText(granularity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function moveCaret(aMessage) {
|
2013-06-19 13:11:46 -07:00
|
|
|
let direction = aMessage.json.direction;
|
|
|
|
let granularity = aMessage.json.granularity;
|
|
|
|
let accessible = Utils.getVirtualCursor(content.document).position;
|
|
|
|
let accText = accessible.QueryInterface(Ci.nsIAccessibleText);
|
|
|
|
let oldOffset = accText.caretOffset;
|
|
|
|
let text = accText.getText(0, accText.characterCount);
|
|
|
|
|
|
|
|
let start = {}, end = {};
|
|
|
|
if (direction === 'Previous' && !aMessage.json.atStart) {
|
|
|
|
switch (granularity) {
|
|
|
|
case MOVEMENT_GRANULARITY_CHARACTER:
|
|
|
|
accText.caretOffset--;
|
|
|
|
break;
|
|
|
|
case MOVEMENT_GRANULARITY_WORD:
|
|
|
|
accText.getTextBeforeOffset(accText.caretOffset,
|
|
|
|
Ci.nsIAccessibleText.BOUNDARY_WORD_START, start, end);
|
|
|
|
accText.caretOffset = end.value === accText.caretOffset ? start.value : end.value;
|
|
|
|
break;
|
|
|
|
case MOVEMENT_GRANULARITY_PARAGRAPH:
|
|
|
|
let startOfParagraph = text.lastIndexOf('\n', accText.caretOffset - 1);
|
|
|
|
accText.caretOffset = startOfParagraph !== -1 ? startOfParagraph : 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (direction === 'Next' && !aMessage.json.atEnd) {
|
|
|
|
switch (granularity) {
|
|
|
|
case MOVEMENT_GRANULARITY_CHARACTER:
|
|
|
|
accText.caretOffset++;
|
|
|
|
break;
|
|
|
|
case MOVEMENT_GRANULARITY_WORD:
|
|
|
|
accText.getTextAtOffset(accText.caretOffset,
|
|
|
|
Ci.nsIAccessibleText.BOUNDARY_WORD_END, start, end);
|
|
|
|
accText.caretOffset = end.value;
|
|
|
|
break;
|
|
|
|
case MOVEMENT_GRANULARITY_PARAGRAPH:
|
|
|
|
accText.caretOffset = text.indexOf('\n', accText.caretOffset + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-03 15:20:11 -07:00
|
|
|
presentCaretChange(text, oldOffset, accText.caretOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
function presentCaretChange(aText, aOldOffset, aNewOffset) {
|
|
|
|
if (aOldOffset !== aNewOffset) {
|
|
|
|
let msg = Presentation.textSelectionChanged(aText, aNewOffset, aNewOffset,
|
2013-07-11 12:55:40 -07:00
|
|
|
aOldOffset, aOldOffset, true);
|
2013-06-19 13:11:46 -07:00
|
|
|
sendAsyncMessage('AccessFu:Present', msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
function scroll(aMessage) {
|
2013-07-26 08:18:12 -07:00
|
|
|
function sendScrollCoordinates(aAccessible) {
|
|
|
|
let bounds = Utils.getBounds(aAccessible);
|
|
|
|
sendAsyncMessage('AccessFu:DoScroll',
|
|
|
|
{ bounds: bounds,
|
|
|
|
page: aMessage.json.page,
|
|
|
|
horizontal: aMessage.json.horizontal });
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
|
2013-07-26 08:18:12 -07:00
|
|
|
let position = Utils.getVirtualCursor(content.document).position;
|
|
|
|
if (!forwardToChild(aMessage, scroll, position)) {
|
|
|
|
sendScrollCoordinates(position);
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 09:43:53 -08:00
|
|
|
function adjustRange(aMessage) {
|
|
|
|
function sendUpDownKey(aAccessible) {
|
2014-01-23 10:37:38 -08:00
|
|
|
let acc = Utils.getEmbeddedControl(aAccessible) || aAccessible;
|
2014-01-27 10:38:06 -08:00
|
|
|
let elem = acc.DOMNode;
|
|
|
|
if (elem) {
|
|
|
|
if (elem.tagName === 'INPUT' && elem.type === 'range') {
|
|
|
|
elem[aMessage.json.direction === 'forward' ? 'stepDown' : 'stepUp']();
|
|
|
|
let changeEvent = content.document.createEvent('UIEvent');
|
|
|
|
changeEvent.initEvent('change', true, true);
|
|
|
|
elem.dispatchEvent(changeEvent);
|
|
|
|
} else {
|
|
|
|
let evt = content.document.createEvent('KeyboardEvent');
|
|
|
|
let keycode = aMessage.json.direction == 'forward' ?
|
|
|
|
content.KeyEvent.DOM_VK_DOWN : content.KeyEvent.DOM_VK_UP;
|
|
|
|
evt.initKeyEvent(
|
|
|
|
"keypress", false, true, null, false, false, false, false, keycode, 0);
|
|
|
|
elem.dispatchEvent(evt);
|
|
|
|
}
|
2013-11-06 09:43:53 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let position = Utils.getVirtualCursor(content.document).position;
|
|
|
|
if (!forwardToChild(aMessage, adjustRange, position)) {
|
|
|
|
sendUpDownKey(position);
|
|
|
|
}
|
|
|
|
}
|
2012-10-01 13:33:26 -07:00
|
|
|
addMessageListener(
|
|
|
|
'AccessFu:Start',
|
|
|
|
function(m) {
|
2013-04-23 10:39:15 -07:00
|
|
|
Logger.debug('AccessFu:Start');
|
2012-10-01 13:33:26 -07:00
|
|
|
if (m.json.buildApp)
|
|
|
|
Utils.MozBuildApp = m.json.buildApp;
|
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
addMessageListener('AccessFu:MoveToPoint', moveToPoint);
|
|
|
|
addMessageListener('AccessFu:MoveCursor', moveCursor);
|
|
|
|
addMessageListener('AccessFu:ShowCurrent', showCurrent);
|
2013-04-23 10:39:15 -07:00
|
|
|
addMessageListener('AccessFu:Activate', activateCurrent);
|
2013-06-03 11:29:14 -07:00
|
|
|
addMessageListener('AccessFu:ContextMenu', activateContextMenu);
|
2013-04-23 10:39:15 -07:00
|
|
|
addMessageListener('AccessFu:Scroll', scroll);
|
2013-11-06 09:43:53 -08:00
|
|
|
addMessageListener('AccessFu:AdjustRange', adjustRange);
|
2013-06-19 13:11:46 -07:00
|
|
|
addMessageListener('AccessFu:MoveCaret', moveCaret);
|
2013-07-24 14:52:57 -07:00
|
|
|
addMessageListener('AccessFu:MoveByGranularity', moveByGranularity);
|
2014-02-11 10:41:02 -08:00
|
|
|
addMessageListener('AccessFu:ClearCursor', clearCursor);
|
2013-04-23 10:39:15 -07:00
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
if (!eventManager) {
|
|
|
|
eventManager = new EventManager(this);
|
|
|
|
}
|
|
|
|
eventManager.start();
|
2014-02-26 16:39:14 -08:00
|
|
|
|
|
|
|
sendAsyncMessage('AccessFu:ContentStarted');
|
2012-10-01 13:33:26 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
addMessageListener(
|
|
|
|
'AccessFu:Stop',
|
|
|
|
function(m) {
|
|
|
|
Logger.debug('AccessFu:Stop');
|
|
|
|
|
2013-07-16 11:45:17 -07:00
|
|
|
removeMessageListener('AccessFu:MoveToPoint', moveToPoint);
|
|
|
|
removeMessageListener('AccessFu:MoveCursor', moveCursor);
|
|
|
|
removeMessageListener('AccessFu:ShowCurrent', showCurrent);
|
2013-04-23 10:39:15 -07:00
|
|
|
removeMessageListener('AccessFu:Activate', activateCurrent);
|
2013-06-03 11:29:14 -07:00
|
|
|
removeMessageListener('AccessFu:ContextMenu', activateContextMenu);
|
2013-04-23 10:39:15 -07:00
|
|
|
removeMessageListener('AccessFu:Scroll', scroll);
|
2013-06-19 13:11:46 -07:00
|
|
|
removeMessageListener('AccessFu:MoveCaret', moveCaret);
|
2013-07-24 14:52:57 -07:00
|
|
|
removeMessageListener('AccessFu:MoveByGranularity', moveByGranularity);
|
2014-02-11 10:41:02 -08:00
|
|
|
removeMessageListener('AccessFu:ClearCursor', clearCursor);
|
2013-04-23 10:39:15 -07:00
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
eventManager.stop();
|
2012-10-01 13:33:26 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
sendAsyncMessage('AccessFu:Ready');
|