| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.ARIAMetadata = class { | 7 Accessibility.ARIAMetadata = class { |
| 8 /** | 8 /** |
| 9 * @param {?Object} config | 9 * @param {?Object} config |
| 10 */ | 10 */ |
| 11 constructor(config) { | 11 constructor(config) { |
| 12 /** @type {!Map<string, !WebInspector.ARIAMetadata.Attribute>} */ | 12 /** @type {!Map<string, !Accessibility.ARIAMetadata.Attribute>} */ |
| 13 this._attributes = new Map(); | 13 this._attributes = new Map(); |
| 14 | 14 |
| 15 if (config) | 15 if (config) |
| 16 this._initialize(config); | 16 this._initialize(config); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * @param {!Object} config | 20 * @param {!Object} config |
| 21 */ | 21 */ |
| 22 _initialize(config) { | 22 _initialize(config) { |
| 23 var attributes = config['attributes']; | 23 var attributes = config['attributes']; |
| 24 | 24 |
| 25 var booleanEnum = ['true', 'false']; | 25 var booleanEnum = ['true', 'false']; |
| 26 for (var name in attributes) { | 26 for (var name in attributes) { |
| 27 var attributeConfig = attributes[name]; | 27 var attributeConfig = attributes[name]; |
| 28 if (attributeConfig.type === 'boolean') | 28 if (attributeConfig.type === 'boolean') |
| 29 attributeConfig.enum = booleanEnum; | 29 attributeConfig.enum = booleanEnum; |
| 30 this._attributes.set(name, new WebInspector.ARIAMetadata.Attribute(attribu
teConfig)); | 30 this._attributes.set(name, new Accessibility.ARIAMetadata.Attribute(attrib
uteConfig)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 /** @type {!Array<string>} */ | 33 /** @type {!Array<string>} */ |
| 34 this._roleNames = Object.keys(config['roles']); | 34 this._roleNames = Object.keys(config['roles']); |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * @param {string} property | 38 * @param {string} property |
| 39 * @return {!Array<string>} | 39 * @return {!Array<string>} |
| 40 */ | 40 */ |
| 41 valuesForProperty(property) { | 41 valuesForProperty(property) { |
| 42 if (this._attributes.has(property)) | 42 if (this._attributes.has(property)) |
| 43 return this._attributes.get(property).getEnum(); | 43 return this._attributes.get(property).getEnum(); |
| 44 | 44 |
| 45 if (property === 'role') | 45 if (property === 'role') |
| 46 return this._roleNames; | 46 return this._roleNames; |
| 47 | 47 |
| 48 return []; | 48 return []; |
| 49 } | 49 } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * @return {!WebInspector.ARIAMetadata} | 53 * @return {!Accessibility.ARIAMetadata} |
| 54 */ | 54 */ |
| 55 WebInspector.ariaMetadata = function() { | 55 Accessibility.ariaMetadata = function() { |
| 56 if (!WebInspector.ARIAMetadata._instance) | 56 if (!Accessibility.ARIAMetadata._instance) |
| 57 WebInspector.ARIAMetadata._instance = new WebInspector.ARIAMetadata(WebInspe
ctor.ARIAMetadata._config || null); | 57 Accessibility.ARIAMetadata._instance = new Accessibility.ARIAMetadata(Access
ibility.ARIAMetadata._config || null); |
| 58 return WebInspector.ARIAMetadata._instance; | 58 return Accessibility.ARIAMetadata._instance; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * @unrestricted | 62 * @unrestricted |
| 63 */ | 63 */ |
| 64 WebInspector.ARIAMetadata.Attribute = class { | 64 Accessibility.ARIAMetadata.Attribute = class { |
| 65 /** | 65 /** |
| 66 * @param {!Object} config | 66 * @param {!Object} config |
| 67 */ | 67 */ |
| 68 constructor(config) { | 68 constructor(config) { |
| 69 /** @type {!Array<string>} */ | 69 /** @type {!Array<string>} */ |
| 70 this._enum = []; | 70 this._enum = []; |
| 71 | 71 |
| 72 if ('enum' in config) | 72 if ('enum' in config) |
| 73 this._enum = config.enum; | 73 this._enum = config.enum; |
| 74 } | 74 } |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * @return {!Array<string>} | 77 * @return {!Array<string>} |
| 78 */ | 78 */ |
| 79 getEnum() { | 79 getEnum() { |
| 80 return this._enum; | 80 return this._enum; |
| 81 } | 81 } |
| 82 }; | 82 }; |
| OLD | NEW |