--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -43,24 +43,24 @@ var AccessFu = {
this.prefsBranch.addObserver('accessfu', this, false);
let accessPref = ACCESSFU_DISABLE;
try {
accessPref = this.prefsBranch.getIntPref('accessfu');
} catch (x) {
}
- this.processPreferences(accessPref);
+ this._processPreferences(accessPref);
},
/**
* Start AccessFu mode, this primarily means controlling the virtual cursor
* with arrow keys.
*/
- enable: function enable() {
+ _enable: function _enable() {
if (this._enabled)
return;
this._enabled = true;
dump('AccessFu enable');
this.addPresenter(new VisualPresenter());
// Implicitly add the Android presenter on Android.
@@ -74,17 +74,17 @@ var AccessFu = {
this.chromeWin.addEventListener('resize', this, true);
this.chromeWin.addEventListener('scroll', this, true);
this.chromeWin.addEventListener('TabOpen', this, true);
},
/**
* Disable AccessFu and return to default interaction mode.
*/
- disable: function disable() {
+ _disable: function _disable() {
if (!this._enabled)
return;
this._enabled = false;
dump('AccessFu disable');
this.presenters.forEach(function(p) { p.detach(); });
this.presenters = [];
@@ -93,17 +93,17 @@ var AccessFu = {
Services.obs.removeObserver(this, 'accessible-event');
this.chromeWin.removeEventListener('DOMActivate', this, true);
this.chromeWin.removeEventListener('resize', this, true);
this.chromeWin.removeEventListener('scroll', this, true);
this.chromeWin.removeEventListener('TabOpen', this, true);
},
- processPreferences: function processPreferences(aPref) {
+ _processPreferences: function _processPreferences(aPref) {
if (Services.appinfo.OS == 'Android') {
if (aPref == ACCESSFU_AUTO) {
if (!this._observingSystemSettings) {
Services.obs.addObserver(this, 'Accessibility:Settings', false);
this._observingSystemSettings = true;
}
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(
@@ -113,19 +113,19 @@ var AccessFu = {
if (this._observingSystemSettings) {
Services.obs.removeObserver(this, 'Accessibility:Settings');
this._observingSystemSettings = false;
}
}
if (aPref == ACCESSFU_ENABLE)
- this.enable();
+ this._enable();
else
- this.disable();
+ this._disable();
},
addPresenter: function addPresenter(presenter) {
this.presenters.push(presenter);
presenter.attach(this.chromeWin);
},
handleEvent: function handleEvent(aEvent) {
@@ -166,37 +166,37 @@ var AccessFu = {
}
}
},
observe: function observe(aSubject, aTopic, aData) {
switch (aTopic) {
case 'Accessibility:Settings':
if (JSON.parse(aData).enabled)
- this.enable();
+ this._enable();
else
- this.disable();
+ this._disable();
break;
case 'nsPref:changed':
if (aData == 'accessfu')
- this.processPreferences(this.prefsBranch.getIntPref('accessfu'));
+ this._processPreferences(this.prefsBranch.getIntPref('accessfu'));
break;
case 'accessible-event':
let event;
try {
event = aSubject.QueryInterface(Ci.nsIAccessibleEvent);
- this.handleAccEvent(event);
+ this._handleAccEvent(event);
} catch (ex) {
dump(ex);
return;
}
}
},
- handleAccEvent: function handleAccEvent(aEvent) {
+ _handleAccEvent: function _handleAccEvent(aEvent) {
switch (aEvent.eventType) {
case Ci.nsIAccessibleEvent.EVENT_VIRTUALCURSOR_CHANGED:
{
let pivot = aEvent.accessible.
QueryInterface(Ci.nsIAccessibleCursorable).virtualCursor;
let event = aEvent.
QueryInterface(Ci.nsIAccessibleVirtualCursorChangeEvent);
@@ -246,33 +246,33 @@ var AccessFu = {
// in a BUSY state (i.e. loading), and inform presenters.
// We need to do this because a state change event will not be
// fired when an object is created with the BUSY state.
// If this is not a new tab, don't bother because we sent 'loading'
// when the previous doc changed its state to BUSY.
let state = {};
docAcc.getState(state, {});
if (state.value & Ci.nsIAccessibleStates.STATE_BUSY &&
- this.isNotChromeDoc(docAcc))
+ this._isNotChromeDoc(docAcc))
this.presenters.forEach(
function(p) { p.tabStateChanged(docAcc, 'loading'); }
);
delete this._pendingDocuments[aEvent.DOMNode];
}
- if (this.isBrowserDoc(docAcc))
+ if (this._isBrowserDoc(docAcc))
// A new top-level content document has been attached
this.presenters.forEach(
function(p) { p.tabStateChanged(docAcc, 'newdoc'); }
);
}
break;
}
case Ci.nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE:
{
- if (this.isNotChromeDoc(aEvent.accessible)) {
+ if (this._isNotChromeDoc(aEvent.accessible)) {
this.presenters.forEach(
function(p) {
p.tabStateChanged(aEvent.accessible, 'loaded');
}
);
}
break;
}
@@ -291,17 +291,17 @@ var AccessFu = {
function(p) {
p.tabStateChanged(aEvent.accessible, 'reload');
}
);
break;
}
case Ci.nsIAccessibleEvent.EVENT_FOCUS:
{
- if (this.isBrowserDoc(aEvent.accessible)) {
+ if (this._isBrowserDoc(aEvent.accessible)) {
// The document recieved focus, call tabSelected to present current tab.
this.presenters.forEach(
function(p) { p.tabSelected(aEvent.accessible); });
}
break;
}
case Ci.nsIAccessibleEvent.EVENT_TEXT_INSERTED:
case Ci.nsIAccessibleEvent.EVENT_TEXT_REMOVED:
@@ -337,17 +337,17 @@ var AccessFu = {
},
/**
* Check if accessible is a top-level content document (i.e. a child of a XUL
* browser node).
* @param {nsIAccessible} aDocAcc the accessible to check.
* @return {boolean} true if this is a top-level content document.
*/
- isBrowserDoc: function isBrowserDoc(aDocAcc) {
+ _isBrowserDoc: function _isBrowserDoc(aDocAcc) {
let parent = aDocAcc.parent;
if (!parent)
return false;
let domNode = parent.DOMNode;
if (!domNode)
return false;
@@ -355,17 +355,17 @@ var AccessFu = {
return (domNode.localName == 'browser' && domNode.namespaceURI == ns);
},
/**
* Check if document is not a local "chrome" document, like about:home.
* @param {nsIDOMDocument} aDocument the document to check.
* @return {boolean} true if this is not a chrome document.
*/
- isNotChromeDoc: function isNotChromeDoc(aDocument) {
+ _isNotChromeDoc: function _isNotChromeDoc(aDocument) {
let location = aDocument.DOMNode.location;
if (!location)
return false;
return location.protocol != "about:";
},
getNewContext: function getNewContext(aOldObject, aNewObject) {
--- a/accessible/src/jsat/Presenters.jsm
+++ b/accessible/src/jsat/Presenters.jsm
@@ -47,17 +47,19 @@ Presenter.prototype = {
* @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.
*/
- textChanged: function textChanged(aIsInserted, aStartOffset, aLength, aText, aModifiedText) {},
+ textChanged: function textChanged(aIsInserted, aStartOffset,
+ aLength, aText,
+ aModifiedText) {},
/**
* Text selection has changed. TODO.
*/
textSelectionChanged: function textSelectionChanged() {},
/**
* Selection has changed. TODO.
@@ -90,243 +92,253 @@ Presenter.prototype = {
};
/**
* Visual presenter. Draws a box around the virtual cursor's position.
*/
function VisualPresenter() {}
-VisualPresenter.prototype = new Presenter();
+VisualPresenter.prototype = {
+ __proto__: Presenter.prototype,
-/**
- * The padding in pixels between the object and the highlight border.
- */
-VisualPresenter.prototype.BORDER_PADDING = 2;
+ /**
+ * The padding in pixels between the object and the highlight border.
+ */
+ BORDER_PADDING: 2,
-VisualPresenter.prototype.attach = function(aWindow) {
- this.chromeWin = aWindow;
+ 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 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 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';
+ // 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);
-};
+ this.highlightBox.appendChild(inset);
+ },
-VisualPresenter.prototype.detach = function() {
- this.chromeWin.document.removeChild(this.stylesheet);
- this.highlightBox.parentNode.removeChild(this.highlightBox);
- this.highlightBox = this.stylesheet = null;
-};
+ detach: function VisualPresenter_detach() {
+ this.chromeWin.document.removeChild(this.stylesheet);
+ this.highlightBox.parentNode.removeChild(this.highlightBox);
+ this.highlightBox = this.stylesheet = null;
+ },
-VisualPresenter.prototype.viewportChanged = function() {
- if (this._currentObject)
- this.highlight(this._currentObject);
-};
+ viewportChanged: function VisualPresenter_viewportChanged() {
+ if (this._currentObject)
+ this._highlight(this._currentObject);
+ },
-VisualPresenter.prototype.pivotChanged = function(aObject, aNewContext) {
- this._currentObject = aObject;
+ pivotChanged: function VisualPresenter_pivotChanged(aObject, aNewContext) {
+ this._currentObject = aObject;
- if (!aObject) {
- this.hide();
- return;
- }
+ if (!aObject) {
+ this._hide();
+ return;
+ }
- try {
- aObject.scrollTo(Ci.nsIAccessibleScrollType.SCROLL_TYPE_ANYWHERE);
- this.highlight(aObject);
- } catch (e) {
- dump('Error getting bounds: ' + e);
- return;
- }
-};
+ try {
+ aObject.scrollTo(Ci.nsIAccessibleScrollType.SCROLL_TYPE_ANYWHERE);
+ this._highlight(aObject);
+ } catch (e) {
+ dump('Error getting bounds: ' + e);
+ return;
+ }
+ },
-VisualPresenter.prototype.tabSelected = function(aDocObj) {
- let vcPos = aDocObj ?
- aDocObj.QueryInterface(Ci.nsIAccessibleCursorable).virtualCursor.position :
- null;
+ tabSelected: function VisualPresenter_tabSelected(aDocObj) {
+ let vcPos = aDocObj ? aDocObj.QueryInterface(Ci.nsIAccessibleCursorable).
+ virtualCursor.position : null;
- this.pivotChanged(vcPos);
-};
+ this.pivotChanged(vcPos);
+ },
-VisualPresenter.prototype.tabStateChanged = function(aDocObj, aPageState) {
- if (aPageState == "newdoc")
- this.pivotChanged(null);
-};
+ tabStateChanged: function VisualPresenter_tabStateChanged(aDocObj,
+ aPageState) {
+ if (aPageState == 'newdoc')
+ this.pivotChanged(null);
+ },
-// Internals
+ // Internals
-VisualPresenter.prototype.hide = function hide() {
- this.highlightBox.style.display = 'none';
-};
+ _hide: function _hide() {
+ this.highlightBox.style.display = 'none';
+ },
-VisualPresenter.prototype.highlight = function(aObject) {
- let vp = (Services.appinfo.OS == 'Android') ?
- this.chromeWin.BrowserApp.selectedTab.getViewport() :
- { zoom: 1.0, offsetY: 0 };
+ _highlight: function _highlight(aObject) {
+ let vp = (Services.appinfo.OS == 'Android') ?
+ this.chromeWin.BrowserApp.selectedTab.getViewport() :
+ { zoom: 1.0, offsetY: 0 };
- let bounds = this.getBounds(aObject, vp.zoom);
+ let bounds = this._getBounds(aObject, vp.zoom);
- // 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';
-};
+ // 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';
+ },
+
+ _getBounds: function _getBounds(aObject, aZoom, aStart, aEnd) {
+ let objX = {}, objY = {}, objW = {}, objH = {};
-VisualPresenter.prototype.getBounds = function(aObject, aZoom, aStart, aEnd) {
- let objX = {}, objY = {}, objW = {}, objH = {};
+ 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.
+ }
+
+ aObject.getBounds(objX, objY, objW, objH);
- 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.
+ // 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, {}, {});
+
+ 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)
+ };
+
+ return rv;
}
-
- aObject.getBounds(objX, objY, objW, objH);
-
- // 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, {}, {});
-
- 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)
- };
-
- return rv;
};
/**
* Android presenter. Fires Android a11y events.
*/
-const ANDROID_TYPE_VIEW_CLICKED = 0x01;
-const ANDROID_TYPE_VIEW_LONG_CLICKED = 0x02;
-const ANDROID_TYPE_VIEW_SELECTED = 0x04;
-const ANDROID_TYPE_VIEW_FOCUSED = 0x08;
-const ANDROID_TYPE_VIEW_TEXT_CHANGED = 0x10;
-const ANDROID_TYPE_WINDOW_STATE_CHANGED = 0x20;
-
function AndroidPresenter() {}
-AndroidPresenter.prototype = new Presenter();
-
-AndroidPresenter.prototype.pivotChanged = function(aObject, aNewContext) {
- let output = [];
- for (let i in aNewContext)
- output.push.apply(output,
- UtteranceGenerator.genForObject(aNewContext[i]));
+AndroidPresenter.prototype = {
+ __proto__: Presenter.prototype,
- output.push.apply(output,
- UtteranceGenerator.genForObject(aObject, true));
+ // 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,
- this.sendMessageToJava({
- gecko: {
- type: 'Accessibility:Event',
- eventType: ANDROID_TYPE_VIEW_FOCUSED,
- text: output
- }
- });
-};
+ pivotChanged: function AndroidPresenter_pivotChanged(aObject, aNewContext) {
+ let output = [];
+ for (let i in aNewContext)
+ output.push.apply(output,
+ UtteranceGenerator.genForObject(aNewContext[i]));
+
+ output.push.apply(output,
+ UtteranceGenerator.genForObject(aObject, true));
-AndroidPresenter.prototype.actionInvoked = function(aObject, aActionName) {
- this.sendMessageToJava({
- gecko: {
- type: 'Accessibility:Event',
- eventType: ANDROID_TYPE_VIEW_CLICKED,
- text: UtteranceGenerator.genForAction(aObject, aActionName)
- }
- });
-};
+ this.sendMessageToJava({
+ gecko: {
+ type: 'Accessibility:Event',
+ eventType: this.ANDROID_VIEW_FOCUSED,
+ text: output
+ }
+ });
+ },
-AndroidPresenter.prototype.tabSelected = function(aDocObj) {
- // Send a pivot change message with the full context utterance for this doc.
- let vcDoc = aDocObj.QueryInterface(Ci.nsIAccessibleCursorable);
- let context = [];
+ actionInvoked: function AndroidPresenter_actionInvoked(aObject, aActionName) {
+ this.sendMessageToJava({
+ gecko: {
+ type: 'Accessibility:Event',
+ eventType: this.ANDROID_VIEW_CLICKED,
+ text: UtteranceGenerator.genForAction(aObject, aActionName)
+ }
+ });
+ },
- let parent = vcDoc.virtualCursor.position || aDocObj;
- while ((parent = parent.parent)) {
- context.push(parent);
- if (parent == aDocObj)
- break;
- }
+ tabSelected: function AndroidPresenter_tabSelected(aDocObj) {
+ // Send a pivot change message with the full context utterance for this doc.
+ let vcDoc = aDocObj.QueryInterface(Ci.nsIAccessibleCursorable);
+ let context = [];
- context.reverse();
+ let parent = vcDoc.virtualCursor.position || aDocObj;
+ while ((parent = parent.parent)) {
+ context.push(parent);
+ if (parent == aDocObj)
+ break;
+ }
- this.pivotChanged(vcDoc.virtualCursor.position || aDocObj, context);
-};
+ context.reverse();
+
+ this.pivotChanged(vcDoc.virtualCursor.position || aDocObj, context);
+ },
-AndroidPresenter.prototype.tabStateChanged = function(aDocObj, aPageState) {
- let stateUtterance = UtteranceGenerator.
- genForTabStateChange(aDocObj, aPageState);
-
- if (!stateUtterance.length)
- return;
+ tabStateChanged: function AndroidPresenter_tabStateChanged(aDocObj,
+ aPageState) {
+ let stateUtterance = UtteranceGenerator.
+ genForTabStateChange(aDocObj, aPageState);
- this.sendMessageToJava({
- gecko: {
- type: 'Accessibility:Event',
- eventType: ANDROID_TYPE_VIEW_TEXT_CHANGED,
- text: stateUtterance,
- addedCount: stateUtterance.join(' ').length,
- removedCount: 0,
- fromIndex: 0
- }
- });
-};
+ 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
+ }
+ });
+ },
-AndroidPresenter.prototype.textChanged = function(aIsInserted, aStart, aLength, aText, aModifiedText) {
- let androidEvent = {
- type: 'Accessibility:Event',
- eventType: ANDROID_TYPE_VIEW_TEXT_CHANGED,
- text: [aText],
- fromIndex: aStart
- };
+ textChanged: function AndroidPresenter_textChanged(aIsInserted, aStart,
+ aLength, aText,
+ aModifiedText) {
+ let androidEvent = {
+ type: 'Accessibility:Event',
+ eventType: this.ANDROID_VIEW_TEXT_CHANGED,
+ text: [aText],
+ fromIndex: aStart
+ };
- 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);
+ 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);
+ }
+
+ this.sendMessageToJava({gecko: androidEvent});
+ },
+
+ sendMessageToJava: function AndroidPresenter_sendMessageTojava(aMessage) {
+ return Cc['@mozilla.org/android/bridge;1'].
+ getService(Ci.nsIAndroidBridge).
+ handleGeckoMessage(JSON.stringify(aMessage));
}
-
- this.sendMessageToJava({gecko: androidEvent});
-};
-
-AndroidPresenter.prototype.sendMessageToJava = function(aMessage) {
- return Cc['@mozilla.org/android/bridge;1'].
- getService(Ci.nsIAndroidBridge).
- handleGeckoMessage(JSON.stringify(aMessage));
};
/**
* A dummy Android presenter for desktop testing
*/
function DummyAndroidPresenter() {}
-DummyAndroidPresenter.prototype = new AndroidPresenter();
+DummyAndroidPresenter.prototype = {
+ __proto__: AndroidPresenter.prototype,
-DummyAndroidPresenter.prototype.sendMessageToJava = function(aMessage) {
- dump(JSON.stringify(aMessage, null, 2) + '\n');
+ sendMessageToJava: function DummyAndroidPresenter_sendMessageToJava(aMsg) {
+ dump(JSON.stringify(aMsg, null, 2) + '\n');
+ }
};
--- a/accessible/src/jsat/UtteranceGenerator.jsm
+++ b/accessible/src/jsat/UtteranceGenerator.jsm
@@ -60,20 +60,20 @@ var UtteranceGenerator = {
* Generates an utterance for an object.
* @param {nsIAccessible} aAccessible accessible object to generate utterance
* for.
* @param {boolean} aForceName include the object's name in the utterance
* even if this object type does not usually have it's name uttered.
* @return {Array} Two string array. The first string describes the object
* and its states. The second string is the object's name. Some object
* types may have the description or name omitted, instead an empty string
- * is returned as a placeholder. Whether the object's description or it's role
- * is included is determined by {@link verbosityRoleMap}.
+ * is returned as a placeholder. Whether the object's description or it's
+ * role is included is determined by {@link verbosityRoleMap}.
*/
- genForObject: function(aAccessible, aForceName) {
+ genForObject: function genForObject(aAccessible, aForceName) {
let roleString = gAccRetrieval.getStringRole(aAccessible.role);
let func = this.objectUtteranceFunctions[roleString] ||
this.objectUtteranceFunctions.defaultFunc;
let flags = this.verbosityRoleMap[roleString] || 0;
if (aForceName)
@@ -86,29 +86,29 @@ var UtteranceGenerator = {
* Generates an utterance for an action performed.
* TODO: May become more verbose in the future.
* @param {nsIAccessible} aAccessible accessible object that the action was
* invoked in.
* @param {string} aActionName the name of the action, one of the keys in
* {@link gActionMap}.
* @return {Array} A one string array with the action.
*/
- genForAction: function(aObject, aActionName) {
+ genForAction: function genForAction(aObject, aActionName) {
return [gStringBundle.GetStringFromName(this.gActionMap[aActionName])];
},
/**
* Generates an utterance for a tab state change.
* @param {nsIAccessible} aAccessible accessible object of the tab's attached
* document.
* @param {string} aTabState the tab state name, see
* {@link Presenter.tabStateChanged}.
* @return {Array} The tab state utterace.
*/
- genForTabStateChange: function (aObject, aTabState) {
+ genForTabStateChange: function genForTabStateChange(aObject, aTabState) {
switch (aTabState) {
case 'newtab':
return [gStringBundle.GetStringFromName('tabNew')];
case 'loading':
return [gStringBundle.GetStringFromName('tabLoading')];
case 'loaded':
return [aObject.name || '',
gStringBundle.GetStringFromName('tabLoaded')];
@@ -172,17 +172,18 @@ var UtteranceGenerator = {
'combobox option': INCLUDE_ROLE,
'image map': INCLUDE_ROLE,
'option': INCLUDE_ROLE,
'listbox': INCLUDE_ROLE},
objectUtteranceFunctions: {
defaultFunc: function defaultFunc(aAccessible, aRoleStr, aFlags) {
let name = (aFlags & INCLUDE_NAME) ? (aAccessible.name || '') : '';
- let desc = (aFlags & INCLUDE_ROLE) ? this._getLocalizedRole(aRoleStr) : '';
+ let desc = (aFlags & INCLUDE_ROLE) ?
+ this._getLocalizedRole(aRoleStr) : '';
let utterance = [];
if (desc) {
let state = {};
let extState = {};
aAccessible.getState(state, extState);
@@ -202,30 +203,30 @@ var UtteranceGenerator = {
}
if (name)
utterance.push(name);
return utterance;
},
- heading: function(aAccessible, aRoleStr, aFlags) {
+ heading: function heading(aAccessible, aRoleStr, aFlags) {
let name = (aFlags & INCLUDE_NAME) ? (aAccessible.name || '') : '';
let level = {};
aAccessible.groupPosition(level, {}, {});
let utterance =
[gStringBundle.formatStringFromName('headingLevel', [level.value], 1)];
if (name)
utterance.push(name);
return utterance;
},
- listitem: function(aAccessible, aRoleStr, aFlags) {
+ listitem: function listitem(aAccessible, aRoleStr, aFlags) {
let name = (aFlags & INCLUDE_NAME) ? (aAccessible.name || '') : '';
let localizedRole = this._getLocalizedRole(aRoleStr);
let itemno = {};
let itemof = {};
aAccessible.groupPosition({}, itemof, itemno);
let utterance =
[gStringBundle.formatStringFromName(
'objItemOf', [localizedRole, itemno.value, itemof.value], 3)];
--- a/accessible/src/jsat/VirtualCursorController.jsm
+++ b/accessible/src/jsat/VirtualCursorController.jsm
@@ -15,34 +15,35 @@ Cu.import('resource://gre/modules/XPCOMU
Cu.import('resource://gre/modules/Services.jsm');
var gAccRetrieval = Cc['@mozilla.org/accessibleRetrieval;1'].
getService(Ci.nsIAccessibleRetrieval);
var VirtualCursorController = {
attach: function attach(aWindow) {
this.chromeWin = aWindow;
- this.chromeWin.document.addEventListener('keypress', this.onkeypress, true);
+ this.chromeWin.document.addEventListener('keypress', this._onkeypress, true);
},
detach: function detach() {
- this.chromeWin.document.removeEventListener('keypress', this.onkeypress, true);
+ this.chromeWin.document.removeEventListener('keypress', this._onkeypress,
+ true);
},
- getBrowserApp: function getBrowserApp() {
+ _getBrowserApp: function _getBrowserApp() {
switch (Services.appinfo.OS) {
case 'Android':
return this.chromeWin.BrowserApp;
default:
return this.chromeWin.gBrowser;
}
},
- onkeypress: function onkeypress(aEvent) {
- let document = VirtualCursorController.getBrowserApp().
+ _onkeypress: function _onkeypress(aEvent) {
+ let document = VirtualCursorController._getBrowserApp().
selectedBrowser.contentDocument;
dump('keypress ' + aEvent.keyCode + '\n');
switch (aEvent.keyCode) {
case aEvent.DOM_VK_END:
VirtualCursorController.moveForward(document, true);
break;
@@ -52,17 +53,17 @@ var VirtualCursorController = {
case aEvent.DOM_VK_RIGHT:
VirtualCursorController.moveForward(document, aEvent.shiftKey);
break;
case aEvent.DOM_VK_LEFT:
VirtualCursorController.moveBackward(document, aEvent.shiftKey);
break;
case aEvent.DOM_VK_UP:
if (Services.appinfo.OS == 'Android')
- // Return focus to browser chrome, which in Android is a native widget.
+ // Return focus to native Android browser chrome.
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(
JSON.stringify({ gecko: { type: 'ToggleChrome:Focus' } }));
break;
case aEvent.DOM_VK_RETURN:
// XXX: It is true that desktop does not map the keypad enter key to
// DOM_VK_ENTER. So for desktop we require a ctrl+return instead.
if (Services.appinfo.OS == 'Android' || !aEvent.ctrlKey)
@@ -105,25 +106,25 @@ var VirtualCursorController = {
},
getVirtualCursor: function getVirtualCursor(document) {
return gAccRetrieval.getAccessibleFor(document).
QueryInterface(Ci.nsIAccessibleCursorable).virtualCursor;
},
SimpleTraversalRule: {
- getMatchRoles: function(aRules) {
+ getMatchRoles: function SimpleTraversalRule_getmatchRoles(aRules) {
aRules.value = this._matchRoles;
return this._matchRoles.length;
},
preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
- match: function(aAccessible) {
+ match: function SimpleTraversalRule_match(aAccessible) {
switch (aAccessible.role) {
case Ci.nsIAccessibleRole.ROLE_COMBOBOX:
// We don't want to ignore the subtree because this is often
// where the list box hangs out.
return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
case Ci.nsIAccessibleRole.ROLE_TEXT_LEAF:
{
// Nameless text leaves are boring, skip them.