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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/accessibility/ARIAMetadata.js
diff --git a/third_party/WebKit/Source/devtools/front_end/accessibility/ARIAMetadata.js b/third_party/WebKit/Source/devtools/front_end/accessibility/ARIAMetadata.js
new file mode 100644
index 0000000000000000000000000000000000000000..1451eee64aad9bb9999984593fc6377b30c249e3
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/accessibility/ARIAMetadata.js
@@ -0,0 +1,85 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @constructor
+ * @param {?Object} config
+ */
+WebInspector.ARIAMetadata = function(config)
+{
+ /** @type {!Map<string, !WebInspector.ARIAMetadata.Attribute>} */
+ this._attributes = new Map();
+
+ if (config)
+ this._initialize(config);
+}
+
+/**
+ * @return {!WebInspector.ARIAMetadata}
+ */
+WebInspector.ariaMetadata = function()
+{
+ if (!WebInspector.ARIAMetadata._instance)
+ WebInspector.ARIAMetadata._instance = new WebInspector.ARIAMetadata(WebInspector.ARIAMetadata._config || null);
+ return WebInspector.ARIAMetadata._instance;
+};
+
+WebInspector.ARIAMetadata.prototype = {
+ /**
+ * @param {!Object} config
+ */
+ _initialize: function(config)
+ {
+ var attributes = config["attributes"];
+
+ var booleanEnum = ["true", "false"];
+ for (var name in attributes) {
+ var attributeConfig = attributes[name];
+ if (attributeConfig.type === "boolean")
+ attributeConfig.enum = booleanEnum;
+ this._attributes.set(name, new WebInspector.ARIAMetadata.Attribute(attributeConfig));
+ }
+
+ /** @type {!Array<string>} */
+ this._roleNames = Object.keys(config["roles"]);
+ },
+
+ /**
+ * @param {string} property
+ * @return {!Array<string>}
+ */
+ valuesForProperty: function(property)
+ {
+ if (this._attributes.has(property))
+ return this._attributes.get(property).enum();
+
+ if (property === "role")
+ return this._roleNames;
+
+ return [];
+ }
+};
+
+/**
+ * @constructor
+ * @param {!Object} config
+ */
+WebInspector.ARIAMetadata.Attribute = function(config)
+{
+ /** @type {!Array<string>} */
+ this._enum = [];
+
+ if ("enum" in config)
+ this._enum = config.enum;
+};
+
+WebInspector.ARIAMetadata.Attribute.prototype = {
+ /**
+ * @return {!Array<string>}
+ */
+ enum: function()
+ {
+ return this._enum;
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698