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
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
2013-07-01 20:50:39 -07:00
|
|
|
const EVENT_VIRTUALCURSOR_CHANGED = Ci.nsIAccessibleEvent.EVENT_VIRTUALCURSOR_CHANGED;
|
|
|
|
const EVENT_STATE_CHANGE = Ci.nsIAccessibleEvent.EVENT_STATE_CHANGE;
|
|
|
|
const EVENT_SCROLLING_START = Ci.nsIAccessibleEvent.EVENT_SCROLLING_START;
|
|
|
|
const EVENT_TEXT_CARET_MOVED = Ci.nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED;
|
|
|
|
const EVENT_TEXT_INSERTED = Ci.nsIAccessibleEvent.EVENT_TEXT_INSERTED;
|
|
|
|
const EVENT_TEXT_REMOVED = Ci.nsIAccessibleEvent.EVENT_TEXT_REMOVED;
|
|
|
|
const EVENT_FOCUS = Ci.nsIAccessibleEvent.EVENT_FOCUS;
|
|
|
|
|
|
|
|
const ROLE_INTERNAL_FRAME = Ci.nsIAccessibleRole.ROLE_INTERNAL_FRAME;
|
|
|
|
const ROLE_DOCUMENT = Ci.nsIAccessibleRole.ROLE_DOCUMENT;
|
|
|
|
const ROLE_CHROME_WINDOW = Ci.nsIAccessibleRole.ROLE_CHROME_WINDOW;
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
2013-05-21 11:16:49 -07:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Services',
|
|
|
|
'resource://gre/modules/Services.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Utils',
|
|
|
|
'resource://gre/modules/accessibility/Utils.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');
|
2012-10-01 13:33:26 -07:00
|
|
|
|
2012-10-31 09:13:28 -07:00
|
|
|
this.EXPORTED_SYMBOLS = ['EventManager'];
|
2012-10-01 13:33:26 -07:00
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
this.EventManager = function EventManager(aContentScope) {
|
|
|
|
this.contentScope = aContentScope;
|
|
|
|
this.addEventListener = this.contentScope.addEventListener.bind(
|
|
|
|
this.contentScope);
|
|
|
|
this.removeEventListener = this.contentScope.removeEventListener.bind(
|
|
|
|
this.contentScope);
|
|
|
|
this.sendMsgFunc = this.contentScope.sendAsyncMessage.bind(
|
|
|
|
this.contentScope);
|
|
|
|
this.webProgress = this.contentScope.docShell.
|
|
|
|
QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIWebProgress);
|
|
|
|
};
|
|
|
|
|
|
|
|
this.EventManager.prototype = {
|
2012-10-01 13:33:26 -07:00
|
|
|
editState: {},
|
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
start: function start() {
|
2012-10-01 13:33:26 -07:00
|
|
|
try {
|
|
|
|
if (!this._started) {
|
2012-12-07 10:39:17 -08:00
|
|
|
Logger.info('EventManager.start', Utils.MozBuildApp);
|
2012-10-01 13:33:26 -07:00
|
|
|
|
|
|
|
this._started = true;
|
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
AccessibilityEventObserver.addListener(this);
|
|
|
|
|
|
|
|
this.webProgress.addProgressListener(this,
|
|
|
|
(Ci.nsIWebProgress.NOTIFY_STATE_ALL |
|
|
|
|
Ci.nsIWebProgress.NOTIFY_LOCATION));
|
|
|
|
this.addEventListener('scroll', this, true);
|
|
|
|
this.addEventListener('resize', this, true);
|
|
|
|
// XXX: Ideally this would be an a11y event. Bug #742280.
|
|
|
|
this.addEventListener('DOMActivate', this, true);
|
|
|
|
}
|
2012-12-07 10:39:17 -08:00
|
|
|
this.present(Presentation.tabStateChanged(null, 'newtab'));
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
} catch (x) {
|
2013-06-27 14:15:36 -07:00
|
|
|
Logger.logException(x, 'Failed to start EventManager');
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-05-21 11:16:49 -07:00
|
|
|
// XXX: Stop is not called when the tab is closed (|TabClose| event is too
|
|
|
|
// late). It is only called when the AccessFu is disabled explicitly.
|
2012-10-01 13:33:26 -07:00
|
|
|
stop: function stop() {
|
2013-04-23 10:39:15 -07:00
|
|
|
if (!this._started) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Logger.info('EventManager.stop', Utils.MozBuildApp);
|
2013-05-21 11:16:49 -07:00
|
|
|
AccessibilityEventObserver.removeListener(this);
|
|
|
|
try {
|
|
|
|
this.webProgress.removeProgressListener(this);
|
|
|
|
this.removeEventListener('scroll', this, true);
|
|
|
|
this.removeEventListener('resize', this, true);
|
|
|
|
// XXX: Ideally this would be an a11y event. Bug #742280.
|
|
|
|
this.removeEventListener('DOMActivate', this, true);
|
|
|
|
} catch (x) {
|
|
|
|
// contentScope is dead.
|
|
|
|
} finally {
|
|
|
|
this._started = false;
|
|
|
|
}
|
2012-10-01 13:33:26 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
handleEvent: function handleEvent(aEvent) {
|
|
|
|
try {
|
|
|
|
switch (aEvent.type) {
|
|
|
|
case 'DOMActivate':
|
|
|
|
{
|
|
|
|
let activatedAcc =
|
|
|
|
Utils.AccRetrieval.getAccessibleFor(aEvent.originalTarget);
|
|
|
|
let [state, extState] = Utils.getStates(activatedAcc);
|
|
|
|
|
|
|
|
// Checkable objects will have a state changed event that we will use
|
|
|
|
// instead of this hackish DOMActivate. We will also know the true
|
|
|
|
// action that was taken.
|
|
|
|
if (state & Ci.nsIAccessibleStates.STATE_CHECKABLE)
|
|
|
|
return;
|
|
|
|
|
2012-12-07 10:39:17 -08:00
|
|
|
this.present(Presentation.actionInvoked(activatedAcc, 'click'));
|
2012-10-01 13:33:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'scroll':
|
|
|
|
case 'resize':
|
|
|
|
{
|
2012-10-19 10:06:08 -07:00
|
|
|
// the target could be an element, document or window
|
|
|
|
let window = null;
|
|
|
|
if (aEvent.target instanceof Ci.nsIDOMWindow)
|
|
|
|
window = aEvent.target;
|
|
|
|
else if (aEvent.target instanceof Ci.nsIDOMDocument)
|
|
|
|
window = aEvent.target.defaultView;
|
|
|
|
else if (aEvent.target instanceof Ci.nsIDOMElement)
|
|
|
|
window = aEvent.target.ownerDocument.defaultView;
|
2012-12-07 10:39:17 -08:00
|
|
|
this.present(Presentation.viewportChanged(window));
|
2012-10-01 13:33:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (x) {
|
2013-06-27 14:15:36 -07:00
|
|
|
Logger.logException(x, 'Error handling DOM event');
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleAccEvent: function handleAccEvent(aEvent) {
|
|
|
|
if (Logger.logLevel >= Logger.DEBUG)
|
|
|
|
Logger.debug('A11yEvent', Logger.eventToString(aEvent),
|
|
|
|
Logger.accessibleToString(aEvent.accessible));
|
|
|
|
|
2013-04-25 12:39:16 -07:00
|
|
|
// Don't bother with non-content events in firefox.
|
|
|
|
if (Utils.MozBuildApp == 'browser' &&
|
2013-07-01 20:50:39 -07:00
|
|
|
aEvent.eventType != EVENT_VIRTUALCURSOR_CHANGED &&
|
2013-07-03 15:02:44 -07:00
|
|
|
aEvent.accessibleDocument.docType == 'window') {
|
2013-04-25 12:39:16 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
switch (aEvent.eventType) {
|
2013-07-01 20:50:39 -07:00
|
|
|
case EVENT_VIRTUALCURSOR_CHANGED:
|
2012-10-01 13:33:26 -07:00
|
|
|
{
|
|
|
|
let pivot = aEvent.accessible.
|
2013-05-21 11:16:50 -07:00
|
|
|
QueryInterface(Ci.nsIAccessibleDocument).virtualCursor;
|
2012-10-01 13:33:26 -07:00
|
|
|
let position = pivot.position;
|
2013-07-01 20:50:39 -07:00
|
|
|
if (position && position.role == ROLE_INTERNAL_FRAME)
|
2012-10-01 13:33:26 -07:00
|
|
|
break;
|
|
|
|
let event = aEvent.
|
|
|
|
QueryInterface(Ci.nsIAccessibleVirtualCursorChangeEvent);
|
|
|
|
let reason = event.reason;
|
|
|
|
|
|
|
|
if (this.editState.editing)
|
|
|
|
aEvent.accessibleDocument.takeFocus();
|
|
|
|
|
|
|
|
this.present(
|
2012-12-07 10:39:17 -08:00
|
|
|
Presentation.pivotChanged(position, event.oldAccessible, reason));
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
break;
|
|
|
|
}
|
2013-07-01 20:50:39 -07:00
|
|
|
case EVENT_STATE_CHANGE:
|
2012-10-01 13:33:26 -07:00
|
|
|
{
|
|
|
|
let event = aEvent.QueryInterface(Ci.nsIAccessibleStateChangeEvent);
|
|
|
|
if (event.state == Ci.nsIAccessibleStates.STATE_CHECKED &&
|
2013-01-19 07:38:01 -08:00
|
|
|
!(event.isExtraState)) {
|
2012-10-01 13:33:26 -07:00
|
|
|
this.present(
|
2012-12-07 10:39:17 -08:00
|
|
|
Presentation.
|
|
|
|
actionInvoked(aEvent.accessible,
|
2013-01-19 07:38:01 -08:00
|
|
|
event.isEnabled ? 'check' : 'uncheck'));
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-01 20:50:39 -07:00
|
|
|
case EVENT_SCROLLING_START:
|
2012-10-01 13:33:26 -07:00
|
|
|
{
|
|
|
|
let vc = Utils.getVirtualCursor(aEvent.accessibleDocument);
|
|
|
|
vc.moveNext(TraversalRules.Simple, aEvent.accessible, true);
|
|
|
|
break;
|
|
|
|
}
|
2013-07-01 20:50:39 -07:00
|
|
|
case EVENT_TEXT_CARET_MOVED:
|
2012-10-01 13:33:26 -07:00
|
|
|
{
|
|
|
|
let acc = aEvent.accessible;
|
|
|
|
let characterCount = acc.
|
|
|
|
QueryInterface(Ci.nsIAccessibleText).characterCount;
|
|
|
|
let caretOffset = aEvent.
|
|
|
|
QueryInterface(Ci.nsIAccessibleCaretMoveEvent).caretOffset;
|
|
|
|
|
|
|
|
// Update editing state, both for presenter and other things
|
|
|
|
let [,extState] = Utils.getStates(acc);
|
|
|
|
let editState = {
|
|
|
|
editing: !!(extState & Ci.nsIAccessibleStates.EXT_STATE_EDITABLE),
|
|
|
|
multiline: !!(extState & Ci.nsIAccessibleStates.EXT_STATE_MULTI_LINE),
|
|
|
|
atStart: caretOffset == 0,
|
|
|
|
atEnd: caretOffset == characterCount
|
|
|
|
};
|
|
|
|
|
|
|
|
// Not interesting
|
|
|
|
if (!editState.editing && editState.editing == this.editState.editing)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (editState.editing != this.editState.editing)
|
2012-12-07 10:39:17 -08:00
|
|
|
this.present(Presentation.editingModeChanged(editState.editing));
|
2012-10-01 13:33:26 -07:00
|
|
|
|
|
|
|
if (editState.editing != this.editState.editing ||
|
|
|
|
editState.multiline != this.editState.multiline ||
|
|
|
|
editState.atEnd != this.editState.atEnd ||
|
|
|
|
editState.atStart != this.editState.atStart)
|
|
|
|
this.sendMsgFunc("AccessFu:Input", editState);
|
|
|
|
|
2013-07-11 12:55:40 -07:00
|
|
|
this.present(Presentation.textSelectionChanged(acc.getText(0,-1),
|
|
|
|
caretOffset, caretOffset, 0, 0, aEvent.isFromUserInput));
|
|
|
|
|
2012-10-01 13:33:26 -07:00
|
|
|
this.editState = editState;
|
|
|
|
break;
|
|
|
|
}
|
2013-07-01 20:50:39 -07:00
|
|
|
case EVENT_TEXT_INSERTED:
|
|
|
|
case EVENT_TEXT_REMOVED:
|
2012-10-01 13:33:26 -07:00
|
|
|
{
|
|
|
|
if (aEvent.isFromUserInput) {
|
|
|
|
// XXX support live regions as well.
|
|
|
|
let event = aEvent.QueryInterface(Ci.nsIAccessibleTextChangeEvent);
|
2013-05-08 18:54:05 -07:00
|
|
|
let isInserted = event.isInserted;
|
2012-10-01 13:33:26 -07:00
|
|
|
let txtIface = aEvent.accessible.QueryInterface(Ci.nsIAccessibleText);
|
|
|
|
|
|
|
|
let text = '';
|
|
|
|
try {
|
|
|
|
text = txtIface.
|
|
|
|
getText(0, Ci.nsIAccessibleText.TEXT_OFFSET_END_OF_TEXT);
|
|
|
|
} catch (x) {
|
|
|
|
// XXX we might have gotten an exception with of a
|
|
|
|
// zero-length text. If we did, ignore it (bug #749810).
|
|
|
|
if (txtIface.characterCount)
|
|
|
|
throw x;
|
|
|
|
}
|
2012-12-26 17:52:28 -08:00
|
|
|
this.present(Presentation.textChanged(
|
2012-12-07 10:39:17 -08:00
|
|
|
isInserted, event.start, event.length,
|
|
|
|
text, event.modifiedText));
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-01 20:50:39 -07:00
|
|
|
case EVENT_FOCUS:
|
2012-10-01 13:33:26 -07:00
|
|
|
{
|
|
|
|
// Put vc where the focus is at
|
|
|
|
let acc = aEvent.accessible;
|
|
|
|
let doc = aEvent.accessibleDocument;
|
2013-07-01 20:50:39 -07:00
|
|
|
if (acc.role != ROLE_DOCUMENT && doc.role != ROLE_CHROME_WINDOW) {
|
2012-10-01 13:33:26 -07:00
|
|
|
let vc = Utils.getVirtualCursor(doc);
|
|
|
|
vc.moveNext(TraversalRules.Simple, acc, true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-12-07 10:39:17 -08:00
|
|
|
present: function present(aPresentationData) {
|
|
|
|
this.sendMsgFunc("AccessFu:Present", aPresentationData);
|
2012-10-01 13:33:26 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
|
|
|
let tabstate = '';
|
|
|
|
|
|
|
|
let loadingState = Ci.nsIWebProgressListener.STATE_TRANSFERRING |
|
|
|
|
Ci.nsIWebProgressListener.STATE_IS_DOCUMENT;
|
|
|
|
let loadedState = Ci.nsIWebProgressListener.STATE_STOP |
|
|
|
|
Ci.nsIWebProgressListener.STATE_IS_NETWORK;
|
|
|
|
|
|
|
|
if ((aStateFlags & loadingState) == loadingState) {
|
|
|
|
tabstate = 'loading';
|
|
|
|
} else if ((aStateFlags & loadedState) == loadedState &&
|
|
|
|
!aWebProgress.isLoadingDocument) {
|
|
|
|
tabstate = 'loaded';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tabstate) {
|
|
|
|
let docAcc = Utils.AccRetrieval.getAccessibleFor(aWebProgress.DOMWindow.document);
|
2012-12-07 10:39:17 -08:00
|
|
|
this.present(Presentation.tabStateChanged(docAcc, tabstate));
|
2012-10-01 13:33:26 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onProgressChange: function onProgressChange() {},
|
|
|
|
|
|
|
|
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
|
|
|
|
let docAcc = Utils.AccRetrieval.getAccessibleFor(aWebProgress.DOMWindow.document);
|
2012-12-07 10:39:17 -08:00
|
|
|
this.present(Presentation.tabStateChanged(docAcc, 'newdoc'));
|
2012-10-01 13:33:26 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
onStatusChange: function onStatusChange() {},
|
|
|
|
|
|
|
|
onSecurityChange: function onSecurityChange() {},
|
|
|
|
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
|
|
|
Ci.nsISupportsWeakReference,
|
|
|
|
Ci.nsISupports,
|
|
|
|
Ci.nsIObserver])
|
|
|
|
};
|
2013-05-21 11:16:49 -07:00
|
|
|
|
|
|
|
const AccessibilityEventObserver = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A WeakMap containing [content, EventManager] pairs.
|
|
|
|
*/
|
|
|
|
eventManagers: new WeakMap(),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A total number of registered eventManagers.
|
|
|
|
*/
|
|
|
|
listenerCount: 0,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An indicator of an active 'accessible-event' observer.
|
|
|
|
*/
|
|
|
|
started: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start an AccessibilityEventObserver.
|
|
|
|
*/
|
|
|
|
start: function start() {
|
|
|
|
if (this.started || this.listenerCount === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Services.obs.addObserver(this, 'accessible-event', false);
|
|
|
|
this.started = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop an AccessibilityEventObserver.
|
|
|
|
*/
|
|
|
|
stop: function stop() {
|
|
|
|
if (!this.started) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Services.obs.removeObserver(this, 'accessible-event');
|
|
|
|
// Clean up all registered event managers.
|
|
|
|
this.eventManagers.clear();
|
|
|
|
this.listenerCount = 0;
|
|
|
|
this.started = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register an EventManager and start listening to the
|
|
|
|
* 'accessible-event' messages.
|
|
|
|
*
|
|
|
|
* @param aEventManager EventManager
|
|
|
|
* An EventManager object that was loaded into the specific content.
|
|
|
|
*/
|
|
|
|
addListener: function addListener(aEventManager) {
|
|
|
|
let content = aEventManager.contentScope.content;
|
|
|
|
if (!this.eventManagers.has(content)) {
|
|
|
|
this.listenerCount++;
|
|
|
|
}
|
|
|
|
this.eventManagers.set(content, aEventManager);
|
|
|
|
// Since at least one EventManager was registered, start listening.
|
|
|
|
Logger.debug('AccessibilityEventObserver.addListener. Total:',
|
|
|
|
this.listenerCount);
|
|
|
|
this.start();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister an EventManager and, optionally, stop listening to the
|
|
|
|
* 'accessible-event' messages.
|
|
|
|
*
|
|
|
|
* @param aEventManager EventManager
|
|
|
|
* An EventManager object that was stopped in the specific content.
|
|
|
|
*/
|
|
|
|
removeListener: function removeListener(aEventManager) {
|
|
|
|
let content = aEventManager.contentScope.content;
|
|
|
|
if (!this.eventManagers.delete(content)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.listenerCount--;
|
|
|
|
Logger.debug('AccessibilityEventObserver.removeListener. Total:',
|
|
|
|
this.listenerCount);
|
|
|
|
if (this.listenerCount === 0) {
|
|
|
|
// If there are no EventManagers registered at the moment, stop listening
|
|
|
|
// to the 'accessible-event' messages.
|
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup an EventManager for a specific content. If the EventManager is not
|
|
|
|
* found, walk up the hierarchy of parent windows.
|
|
|
|
* @param content Window
|
|
|
|
* A content Window used to lookup the corresponding EventManager.
|
|
|
|
*/
|
|
|
|
getListener: function getListener(content) {
|
|
|
|
let eventManager = this.eventManagers.get(content);
|
|
|
|
if (eventManager) {
|
|
|
|
return eventManager;
|
|
|
|
}
|
|
|
|
let parent = content.parent;
|
|
|
|
if (parent === content) {
|
|
|
|
// There is no parent or the parent is of a different type.
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return this.getListener(parent);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the 'accessible-event' message.
|
|
|
|
*/
|
|
|
|
observe: function observe(aSubject, aTopic, aData) {
|
|
|
|
if (aTopic !== 'accessible-event') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let event = aSubject.QueryInterface(Ci.nsIAccessibleEvent);
|
|
|
|
if (!event.accessibleDocument) {
|
|
|
|
Logger.warning(
|
|
|
|
'AccessibilityEventObserver.observe: no accessible document:',
|
|
|
|
Logger.eventToString(event), "accessible:",
|
|
|
|
Logger.accessibleToString(event.accessible));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let content = event.accessibleDocument.window;
|
|
|
|
// Match the content window to its EventManager.
|
|
|
|
let eventManager = this.getListener(content);
|
|
|
|
if (!eventManager || !eventManager._started) {
|
|
|
|
if (Utils.MozBuildApp === 'browser' &&
|
|
|
|
!(content instanceof Ci.nsIDOMChromeWindow)) {
|
|
|
|
Logger.warning(
|
|
|
|
'AccessibilityEventObserver.observe: ignored event:',
|
|
|
|
Logger.eventToString(event), "accessible:",
|
|
|
|
Logger.accessibleToString(event.accessible), "document:",
|
|
|
|
Logger.accessibleToString(event.accessibleDocument));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
eventManager.handleAccEvent(event);
|
|
|
|
} catch (x) {
|
2013-06-27 14:15:36 -07:00
|
|
|
Logger.logException(x, 'Error handing accessible event');
|
2013-05-21 11:16:49 -07:00
|
|
|
} finally {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|