2013-11-19 10:17:43 -08:00
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
|
|
|
|
2014-04-16 22:02:40 -07:00
|
|
|
this.EXPORTED_SYMBOLS = ['Roles', 'Events', 'Relations',
|
|
|
|
'Filters', 'States', 'Prefilters'];
|
2013-11-19 10:17:43 -08:00
|
|
|
|
2014-01-27 16:35:13 -08:00
|
|
|
function ConstantsMap (aObject, aPrefix, aMap = {}, aModifier = null) {
|
2013-11-19 10:17:43 -08:00
|
|
|
let offset = aPrefix.length;
|
|
|
|
for (var name in aObject) {
|
|
|
|
if (name.indexOf(aPrefix) === 0) {
|
2014-01-27 16:35:13 -08:00
|
|
|
aMap[name.slice(offset)] = aModifier ?
|
|
|
|
aModifier(aObject[name]) : aObject[name];
|
2013-11-19 10:17:43 -08:00
|
|
|
}
|
|
|
|
}
|
2014-01-27 16:35:13 -08:00
|
|
|
|
|
|
|
return aMap;
|
2013-11-19 10:17:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(
|
|
|
|
this, 'Roles',
|
|
|
|
function() {
|
2014-01-27 16:35:13 -08:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleRole, 'ROLE_');
|
2013-11-19 10:17:43 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(
|
|
|
|
this, 'Events',
|
|
|
|
function() {
|
2014-01-27 16:35:13 -08:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleEvent, 'EVENT_');
|
2013-11-19 10:17:43 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(
|
|
|
|
this, 'Relations',
|
|
|
|
function() {
|
2014-01-27 16:35:13 -08:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleRelation, 'RELATION_');
|
2013-11-19 10:17:43 -08:00
|
|
|
});
|
|
|
|
|
2014-04-16 22:02:40 -07:00
|
|
|
XPCOMUtils.defineLazyGetter(
|
|
|
|
this, 'Prefilters',
|
|
|
|
function() {
|
|
|
|
return ConstantsMap(Ci.nsIAccessibleTraversalRule, 'PREFILTER_');
|
|
|
|
});
|
|
|
|
|
2013-11-19 10:17:43 -08:00
|
|
|
XPCOMUtils.defineLazyGetter(
|
|
|
|
this, 'Filters',
|
|
|
|
function() {
|
2014-01-27 16:35:13 -08:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleTraversalRule, 'FILTER_');
|
|
|
|
});
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(
|
|
|
|
this, 'States',
|
|
|
|
function() {
|
|
|
|
let statesMap = ConstantsMap(Ci.nsIAccessibleStates, 'STATE_', {},
|
|
|
|
(val) => { return { base: val, extended: 0 }; });
|
|
|
|
ConstantsMap(Ci.nsIAccessibleStates, 'EXT_STATE_', statesMap,
|
|
|
|
(val) => { return { base: 0, extended: val }; });
|
|
|
|
return statesMap;
|
2013-11-19 10:17:43 -08:00
|
|
|
});
|