Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/accessibility/ARIAMetadata.js

Issue 2200893003: DevTools: Add autocomplete for ARIA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skip_compilation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @constructor
7 * @param {?Object} config
8 */
9 WebInspector.ARIAMetadata = function(config)
10 {
11 /** @type {!Map<string, !WebInspector.ARIAMetadata.Attribute>} */
12 this._attributes = new Map();
13
14 if (config)
15 this._initialize(config);
16 }
17
18 /**
19 * @return {!WebInspector.ARIAMetadata}
20 */
21 WebInspector.ariaMetadata = function()
22 {
23 if (!WebInspector.ARIAMetadata._instance)
24 WebInspector.ARIAMetadata._instance = new WebInspector.ARIAMetadata(WebI nspector.ARIAMetadata._config || null);
25 return WebInspector.ARIAMetadata._instance;
26 };
27
28 WebInspector.ARIAMetadata.prototype = {
29 /**
30 * @param {!Object} config
31 */
32 _initialize: function(config)
33 {
34 var attributes = config["attributes"];
35
36 var booleanEnum = ["true", "false"];
37 for (var name in attributes) {
38 var attributeConfig = attributes[name];
39 if (attributeConfig.type === "boolean")
40 attributeConfig.enum = booleanEnum;
41 this._attributes.set(name, new WebInspector.ARIAMetadata.Attribute(a ttributeConfig));
42 }
43
44 /** @type {!Array<string>} */
45 this._roleNames = Object.keys(config["roles"]);
46 },
47
48 /**
49 * @param {string} property
50 * @return {!Array<string>}
51 */
52 valuesForProperty: function(property)
53 {
54 if (this._attributes.has(property))
55 return this._attributes.get(property).enum();
56
57 if (property === "role")
58 return this._roleNames;
59
60 return [];
61 }
62 };
63
64 /**
65 * @constructor
66 * @param {!Object} config
67 */
68 WebInspector.ARIAMetadata.Attribute = function(config)
69 {
70 /** @type {!Array<string>} */
71 this._enum = [];
72
73 if ("enum" in config)
74 this._enum = config.enum;
75 };
76
77 WebInspector.ARIAMetadata.Attribute.prototype = {
78 /**
79 * @return {!Array<string>}
80 */
81 enum: function()
82 {
83 return this._enum;
84 }
85 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698