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

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: lushinkov review comments 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);
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 if (!("roles" in config))
lushnikov 2016/08/26 23:00:16 why do we check for "roles" existence? AFAIU it co
aboxhall 2016/08/26 23:18:36 Done.
45 return;
46
47 var roles = config["roles"];
48
49 /** @type {!Array<string>} */
50 WebInspector.ARIAMetadata.Roles = Object.keys(roles);
lushnikov 2016/08/26 23:00:16 May we have this._roleNames for now? As far as we'
aboxhall 2016/08/26 23:18:36 Done.
51 },
52
53 /**
54 * @param {string} property
55 * @return {!Array<string>}
56 */
57 valueSetForProperty: function(property)
lushnikov 2016/08/26 23:00:16 There's no such thing as a valueSet anymore; let's
aboxhall 2016/08/26 23:18:36 Done - valuesForProperty?
58 {
59 if (this._attributes.has(property))
60 return this._attributes.get(property).enum();
61
62 if (property === "role")
63 return WebInspector.ARIAMetadata.Roles;
64
65 return [];
66 }
67 };
68
69 /**
70 * @constructor
71 * @param {!Object} config
72 */
73 WebInspector.ARIAMetadata.Attribute = function(config)
74 {
75 /** @type {?string} */
76 this._default = null;
lushnikov 2016/08/26 23:00:16 this seems to be a leftover
aboxhall 2016/08/26 23:18:36 Done.
77
78 /** @type {!Array<string>} */
79 this._enum = [];
80
81 if ("enum" in config)
82 this._enum = config.enum;
83 };
84
85 WebInspector.ARIAMetadata.Attribute.prototype = {
86 /**
87 * @return {!Array<string>}
88 */
89 enum: function()
90 {
91 return this._enum;
92 }
93 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698