2019-01-17 18:18:31 +00:00
|
|
|
const { XPCOMUtils } = ChromeUtils.import(
|
|
|
|
"resource://gre/modules/XPCOMUtils.jsm"
|
|
|
|
);
|
2013-11-19 18:17:43 +00:00
|
|
|
|
2018-04-24 11:43:00 +00:00
|
|
|
const AndroidEvents = {
|
2018-05-07 14:37:00 +00:00
|
|
|
VIEW_CLICKED: 0x01,
|
|
|
|
VIEW_LONG_CLICKED: 0x02,
|
|
|
|
VIEW_SELECTED: 0x04,
|
|
|
|
VIEW_FOCUSED: 0x08,
|
|
|
|
VIEW_TEXT_CHANGED: 0x10,
|
|
|
|
WINDOW_STATE_CHANGED: 0x20,
|
|
|
|
VIEW_HOVER_ENTER: 0x80,
|
|
|
|
VIEW_HOVER_EXIT: 0x100,
|
2018-07-10 14:31:00 +00:00
|
|
|
WINDOW_CONTENT_CHANGED: 0x800,
|
2018-05-07 14:37:00 +00:00
|
|
|
VIEW_SCROLLED: 0x1000,
|
|
|
|
VIEW_TEXT_SELECTION_CHANGED: 0x2000,
|
|
|
|
ANNOUNCEMENT: 0x4000,
|
|
|
|
VIEW_ACCESSIBILITY_FOCUSED: 0x8000,
|
|
|
|
VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY: 0x20000,
|
2018-04-24 11:43:00 +00:00
|
|
|
};
|
2013-11-19 18:17:43 +00:00
|
|
|
|
2017-08-01 16:15:51 +00:00
|
|
|
function ConstantsMap(aObject, aPrefix, aMap = {}, aModifier = null) {
|
2013-11-19 18:17:43 +00:00
|
|
|
let offset = aPrefix.length;
|
|
|
|
for (var name in aObject) {
|
|
|
|
if (name.indexOf(aPrefix) === 0) {
|
2014-01-28 00:35:13 +00:00
|
|
|
aMap[name.slice(offset)] = aModifier
|
|
|
|
? aModifier(aObject[name])
|
|
|
|
: aObject[name];
|
2013-11-19 18:17:43 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-28 00:35:13 +00:00
|
|
|
|
|
|
|
return aMap;
|
2013-11-19 18:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(this, "Roles", function() {
|
2017-08-01 16:13:27 +00:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleRole, "ROLE_");
|
2013-11-19 18:17:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(this, "Events", function() {
|
2017-08-01 16:13:27 +00:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleEvent, "EVENT_");
|
2013-11-19 18:17:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(this, "Relations", function() {
|
2017-08-01 16:13:27 +00:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleRelation, "RELATION_");
|
2013-11-19 18:17:43 +00:00
|
|
|
});
|
|
|
|
|
2014-04-17 05:02:40 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "Prefilters", function() {
|
2017-08-01 16:13:27 +00:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleTraversalRule, "PREFILTER_");
|
2014-04-17 05:02:40 +00:00
|
|
|
});
|
|
|
|
|
2013-11-19 18:17:43 +00:00
|
|
|
XPCOMUtils.defineLazyGetter(this, "Filters", function() {
|
2017-08-01 16:13:27 +00:00
|
|
|
return ConstantsMap(Ci.nsIAccessibleTraversalRule, "FILTER_");
|
2014-01-28 00:35:13 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(this, "States", function() {
|
2017-08-01 16:13:27 +00:00
|
|
|
let statesMap = ConstantsMap(Ci.nsIAccessibleStates, "STATE_", {}, val => {
|
2014-01-28 00:35:13 +00:00
|
|
|
return { base: val, extended: 0 };
|
|
|
|
});
|
2017-08-01 16:13:27 +00:00
|
|
|
ConstantsMap(Ci.nsIAccessibleStates, "EXT_STATE_", statesMap, val => {
|
2014-01-28 00:35:13 +00:00
|
|
|
return { base: 0, extended: val };
|
2013-11-19 18:17:43 +00:00
|
|
|
});
|
2014-01-28 00:35:13 +00:00
|
|
|
return statesMap;
|
2019-07-05 07:45:34 +00:00
|
|
|
});
|
2018-04-25 03:18:09 +00:00
|
|
|
|
|
|
|
var EXPORTED_SYMBOLS = [
|
|
|
|
"Roles",
|
|
|
|
"Events",
|
|
|
|
"Relations",
|
|
|
|
"Filters",
|
|
|
|
"States",
|
|
|
|
"Prefilters",
|
|
|
|
"AndroidEvents",
|
|
|
|
];
|