accessible/src/jsat/Constants.jsm

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 const Ci = Components.interfaces;
michael@0 2 const Cu = Components.utils;
michael@0 3
michael@0 4 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
michael@0 5
michael@0 6 this.EXPORTED_SYMBOLS = ['Roles', 'Events', 'Relations',
michael@0 7 'Filters', 'States', 'Prefilters'];
michael@0 8
michael@0 9 function ConstantsMap (aObject, aPrefix, aMap = {}, aModifier = null) {
michael@0 10 let offset = aPrefix.length;
michael@0 11 for (var name in aObject) {
michael@0 12 if (name.indexOf(aPrefix) === 0) {
michael@0 13 aMap[name.slice(offset)] = aModifier ?
michael@0 14 aModifier(aObject[name]) : aObject[name];
michael@0 15 }
michael@0 16 }
michael@0 17
michael@0 18 return aMap;
michael@0 19 }
michael@0 20
michael@0 21 XPCOMUtils.defineLazyGetter(
michael@0 22 this, 'Roles',
michael@0 23 function() {
michael@0 24 return ConstantsMap(Ci.nsIAccessibleRole, 'ROLE_');
michael@0 25 });
michael@0 26
michael@0 27 XPCOMUtils.defineLazyGetter(
michael@0 28 this, 'Events',
michael@0 29 function() {
michael@0 30 return ConstantsMap(Ci.nsIAccessibleEvent, 'EVENT_');
michael@0 31 });
michael@0 32
michael@0 33 XPCOMUtils.defineLazyGetter(
michael@0 34 this, 'Relations',
michael@0 35 function() {
michael@0 36 return ConstantsMap(Ci.nsIAccessibleRelation, 'RELATION_');
michael@0 37 });
michael@0 38
michael@0 39 XPCOMUtils.defineLazyGetter(
michael@0 40 this, 'Prefilters',
michael@0 41 function() {
michael@0 42 return ConstantsMap(Ci.nsIAccessibleTraversalRule, 'PREFILTER_');
michael@0 43 });
michael@0 44
michael@0 45 XPCOMUtils.defineLazyGetter(
michael@0 46 this, 'Filters',
michael@0 47 function() {
michael@0 48 return ConstantsMap(Ci.nsIAccessibleTraversalRule, 'FILTER_');
michael@0 49 });
michael@0 50
michael@0 51 XPCOMUtils.defineLazyGetter(
michael@0 52 this, 'States',
michael@0 53 function() {
michael@0 54 let statesMap = ConstantsMap(Ci.nsIAccessibleStates, 'STATE_', {},
michael@0 55 (val) => { return { base: val, extended: 0 }; });
michael@0 56 ConstantsMap(Ci.nsIAccessibleStates, 'EXT_STATE_', statesMap,
michael@0 57 (val) => { return { base: 0, extended: val }; });
michael@0 58 return statesMap;
michael@0 59 });

mercurial