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

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: remove test 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 var roles = config["roles"];
lushnikov 2016/08/26 23:32:20 nit: inlining this would be nice
45
46 /** @type {!Array<string>} */
47 this._roleNames = Object.keys(roles);
48 },
49
50 /**
51 * @param {string} property
52 * @return {!Array<string>}
53 */
54 valuesForProperty: function(property)
lushnikov 2016/08/26 23:32:20 Feels a little weird that we call it values here a
aboxhall 2016/08/26 23:43:58 I can see that. It's kind of an implementation det
55 {
56 if (this._attributes.has(property))
57 return this._attributes.get(property).enum();
58
59 if (property === "role")
60 return this._roleNames;
61
62 return [];
63 }
64 };
65
66 /**
67 * @constructor
68 * @param {!Object} config
69 */
70 WebInspector.ARIAMetadata.Attribute = function(config)
71 {
72 /** @type {!Array<string>} */
73 this._enum = [];
74
75 if ("enum" in config)
76 this._enum = config.enum;
77 };
78
79 WebInspector.ARIAMetadata.Attribute.prototype = {
80 /**
81 * @return {!Array<string>}
82 */
83 enum: function()
84 {
85 return this._enum;
86 }
87 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698