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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/accessibility/ARIAAttributesView.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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.AccessibilitySubPane} 7 * @extends {WebInspector.AccessibilitySubPane}
8 */ 8 */
9 WebInspector.ARIAAttributesPane = function() 9 WebInspector.ARIAAttributesPane = function()
10 { 10 {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 * @param {string} previousContent 127 * @param {string} previousContent
128 * @param {!Event} event 128 * @param {!Event} event
129 * @this {WebInspector.ARIAAttributesTreeElement} 129 * @this {WebInspector.ARIAAttributesTreeElement}
130 */ 130 */
131 function blurListener(previousContent, event) 131 function blurListener(previousContent, event)
132 { 132 {
133 var text = event.target.textContent; 133 var text = event.target.textContent;
134 this._editingCommitted(text, previousContent); 134 this._editingCommitted(text, previousContent);
135 } 135 }
136 136
137 this._prompt = new WebInspector.ARIAAttributesPane.ARIAAttributePrompt(t his); 137 this._prompt = new WebInspector.ARIAAttributesPane.ARIAAttributePrompt(W ebInspector.ariaMetadata().valuesForProperty(this._nameElement.textContent), thi s);
138 this._prompt.setAutocompletionTimeout(0); 138 this._prompt.setAutocompletionTimeout(0);
139 var proxyElement = this._prompt.attachAndStartEditing(valueElement, blur Listener.bind(this, previousContent)); 139 var proxyElement = this._prompt.attachAndStartEditing(valueElement, blur Listener.bind(this, previousContent));
140 140
141 proxyElement.addEventListener("keydown", this._editingValueKeyDown.bind( this, previousContent), false); 141 proxyElement.addEventListener("keydown", this._editingValueKeyDown.bind( this, previousContent), false);
142 142
143 valueElement.getComponentSelection().setBaseAndExtent(valueElement, 0, v alueElement, 1); 143 valueElement.getComponentSelection().setBaseAndExtent(valueElement, 0, v alueElement, 1);
144 }, 144 },
145 145
146 _removePrompt: function() 146 _removePrompt: function()
147 { 147 {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 WebInspector.ARIAAttributesTreeElement.createARIAValueElement = function(value) 202 WebInspector.ARIAAttributesTreeElement.createARIAValueElement = function(value)
203 { 203 {
204 var valueElement = createElementWithClass("span", "monospace"); 204 var valueElement = createElementWithClass("span", "monospace");
205 // TODO(aboxhall): quotation marks? 205 // TODO(aboxhall): quotation marks?
206 valueElement.setTextContentTruncatedIfNeeded(value || ""); 206 valueElement.setTextContentTruncatedIfNeeded(value || "");
207 return valueElement; 207 return valueElement;
208 }; 208 };
209 209
210 /** 210 /**
211 * @constructor 211 * @constructor
212 * TODO: completions; see StylesSidebarPane.js
213 * @extends {WebInspector.TextPrompt} 212 * @extends {WebInspector.TextPrompt}
213 * @param {!Array<string>} ariaCompletions
214 * @param {!WebInspector.ARIAAttributesTreeElement} treeElement 214 * @param {!WebInspector.ARIAAttributesTreeElement} treeElement
215 */ 215 */
216 WebInspector.ARIAAttributesPane.ARIAAttributePrompt = function(treeElement) 216 WebInspector.ARIAAttributesPane.ARIAAttributePrompt = function(ariaCompletions, treeElement)
217 { 217 {
218 WebInspector.TextPrompt.call(this, this._buildPropertyCompletions.bind(this) ); 218 WebInspector.TextPrompt.call(this, this._buildPropertyCompletions.bind(this) );
219 219
220 this.setSuggestBoxEnabled(true);
221
222 this._ariaCompletions = ariaCompletions;
220 this._treeElement = treeElement; 223 this._treeElement = treeElement;
221 }; 224 };
222 225
223 WebInspector.ARIAAttributesPane.ARIAAttributePrompt.prototype = { 226 WebInspector.ARIAAttributesPane.ARIAAttributePrompt.prototype = {
224 /** 227 /**
225 * @param {!Element} proxyElement 228 * @param {!Element} proxyElement
226 * @param {!Range} wordRange 229 * @param {!Range} wordRange
227 * @param {boolean} force 230 * @param {boolean} force
228 * @param {function(!Array.<string>, number=)} completionsReadyCallback 231 * @param {function(!Array.<string>, number=)} completionsReadyCallback
229 */ 232 */
230 _buildPropertyCompletions: function(proxyElement, wordRange, force, completi onsReadyCallback) 233 _buildPropertyCompletions: function(proxyElement, wordRange, force, completi onsReadyCallback)
231 { 234 {
232 // TODO(aboxhall): replace placeholder implementation with real implemen tation 235 var prefix = wordRange.toString().toLowerCase();
233 completionsReadyCallback([], 0); 236 if (!prefix && !force && (this._isEditingName || proxyElement.textConten t.length)) {
237 completionsReadyCallback([]);
238 return;
239 }
240
241 var results = this._ariaCompletions.filter((value) => value.startsWith(p refix));
242
243 completionsReadyCallback(results, 0);
234 }, 244 },
235 245
236 __proto__: WebInspector.TextPrompt.prototype 246 __proto__: WebInspector.TextPrompt.prototype
237 } 247 }
238 248
239 249
240 WebInspector.ARIAAttributesPane._attributes = [ 250 WebInspector.ARIAAttributesPane._attributes = [
241 "role", 251 "role",
242 "aria-busy", 252 "aria-busy",
243 "aria-checked", 253 "aria-checked",
(...skipping 24 matching lines...) Expand all
268 "aria-readonly", 278 "aria-readonly",
269 "aria-relevant", 279 "aria-relevant",
270 "aria-required", 280 "aria-required",
271 "aria-setsize", 281 "aria-setsize",
272 "aria-sort", 282 "aria-sort",
273 "aria-valuemax", 283 "aria-valuemax",
274 "aria-valuemin", 284 "aria-valuemin",
275 "aria-valuenow", 285 "aria-valuenow",
276 "aria-valuetext", 286 "aria-valuetext",
277 ]; 287 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698