зеркало из https://github.com/mozilla/gecko-dev.git
Bug 775657 - Added initial B2G support and speech presenter. r=davidb
This commit is contained in:
Родитель
fe6d6bc2c2
Коммит
a1ae890b1e
|
@ -63,8 +63,10 @@ var AccessFu = {
|
|||
this.addPresenter(new VisualPresenter());
|
||||
|
||||
// Implicitly add the Android presenter on Android.
|
||||
if (Utils.OS == 'Android')
|
||||
if (Utils.MozBuildApp == 'mobile/android')
|
||||
this.addPresenter(new AndroidPresenter());
|
||||
else if (Utils.MozBuildApp == 'b2g')
|
||||
this.addPresenter(new SpeechPresenter());
|
||||
|
||||
VirtualCursorController.attach(this.chromeWin);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ Cu.import('resource://gre/modules/accessibility/UtteranceGenerator.jsm');
|
|||
var EXPORTED_SYMBOLS = ['VisualPresenter',
|
||||
'AndroidPresenter',
|
||||
'DummyAndroidPresenter',
|
||||
'SpeechPresenter',
|
||||
'PresenterContext'];
|
||||
|
||||
/**
|
||||
|
@ -396,6 +397,41 @@ DummyAndroidPresenter.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A speech presenter for direct TTS output
|
||||
*/
|
||||
|
||||
function SpeechPresenter() {}
|
||||
|
||||
SpeechPresenter.prototype = {
|
||||
__proto__: Presenter.prototype,
|
||||
|
||||
|
||||
pivotChanged: function SpeechPresenter_pivotChanged(aContext, aReason) {
|
||||
if (!aContext.accessible)
|
||||
return;
|
||||
|
||||
let output = [];
|
||||
|
||||
aContext.newAncestry.forEach(
|
||||
function(acc) {
|
||||
output.push.apply(output, UtteranceGenerator.genForObject(acc));
|
||||
}
|
||||
);
|
||||
|
||||
output.push.apply(output,
|
||||
UtteranceGenerator.genForObject(aContext.accessible));
|
||||
|
||||
aContext.subtreePreorder.forEach(
|
||||
function(acc) {
|
||||
output.push.apply(output, UtteranceGenerator.genForObject(acc));
|
||||
}
|
||||
);
|
||||
|
||||
Logger.info('SPEAK', '"' + output.join(' ') + '"');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PresenterContext: An object that generates and caches context information
|
||||
* for a given accessible and its relationship with another accessible.
|
||||
|
|
|
@ -16,6 +16,19 @@ var gAccRetrieval = Cc['@mozilla.org/accessibleRetrieval;1'].
|
|||
getService(Ci.nsIAccessibleRetrieval);
|
||||
|
||||
var Utils = {
|
||||
_buildAppMap: {
|
||||
'{3c2e2abc-06d4-11e1-ac3b-374f68613e61}': 'b2g',
|
||||
'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': 'browser',
|
||||
'{aa3c5121-dab2-40e2-81ca-7ea25febc110}': 'mobile/android',
|
||||
'{a23983c0-fd0e-11dc-95ff-0800200c9a66}': 'mobile/xul'
|
||||
},
|
||||
|
||||
get MozBuildApp() {
|
||||
if (!this._buildApp)
|
||||
this._buildApp = this._buildAppMap[Services.appinfo.ID];
|
||||
return this._buildApp;
|
||||
},
|
||||
|
||||
get OS() {
|
||||
if (!this._OS)
|
||||
this._OS = Services.appinfo.OS;
|
||||
|
@ -40,21 +53,27 @@ var Utils = {
|
|||
},
|
||||
|
||||
getBrowserApp: function getBrowserApp(aWindow) {
|
||||
switch (this.OS) {
|
||||
case 'Android':
|
||||
switch (this.MozBuildApp) {
|
||||
case 'mobile/android':
|
||||
return aWindow.BrowserApp;
|
||||
default:
|
||||
case 'browser':
|
||||
return aWindow.gBrowser;
|
||||
case 'b2g':
|
||||
return aWindow.shell;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
getCurrentContentDoc: function getCurrentContentDoc(aWindow) {
|
||||
if (this.MozBuildApp == "b2g")
|
||||
return this.getBrowserApp(aWindow).contentBrowser.contentDocument;
|
||||
return this.getBrowserApp(aWindow).selectedBrowser.contentDocument;
|
||||
},
|
||||
|
||||
getViewport: function getViewport(aWindow) {
|
||||
switch (this.OS) {
|
||||
case 'Android':
|
||||
switch (this.MozBuildApp) {
|
||||
case 'mobile/android':
|
||||
return aWindow.BrowserApp.selectedTab.getViewport();
|
||||
default:
|
||||
return null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче