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.

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

mercurial