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

Side by Side Diff: Source/devtools/front_end/accessibility/AccessibilitySidebarView.js

Issue 1212443002: Updated styles based on user testing and UX feedback. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | Source/devtools/front_end/accessibility/AccessibilityStrings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.ThrottledWidget} 7 * @extends {WebInspector.ThrottledWidget}
8 */ 8 */
9 WebInspector.AccessibilitySidebarView = function() 9 WebInspector.AccessibilitySidebarView = function()
10 { 10 {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 /** 203 /**
204 * @constructor 204 * @constructor
205 * @extends {WebInspector.AccessibilitySubPane} 205 * @extends {WebInspector.AccessibilitySubPane}
206 */ 206 */
207 WebInspector.AXComputedTextSubPane = function() 207 WebInspector.AXComputedTextSubPane = function()
208 { 208 {
209 WebInspector.AccessibilitySubPane.call(this, WebInspector.UIString("Computed Text")); 209 WebInspector.AccessibilitySubPane.call(this, WebInspector.UIString("Computed Text"));
210 210
211 this._computedTextElement = this.element.createChild("div", "ax-computed-tex t hidden"); 211 this._computedTextElement = this.element.createChild("div", "ax-computed-tex t hidden");
212 212
213 this._noTextInfo = this.createInfo(WebInspector.UIString("No computed text") ); 213 this._noTextInfo = this.createInfo(WebInspector.UIString("Node has no text a lternative."));
214 this._noNodeInfo = this.createInfo(WebInspector.UIString("No accessibility n ode"));
215 this._treeOutline = this.createTreeOutline(); 214 this._treeOutline = this.createTreeOutline();
216 }; 215 };
217 216
218 217
219 WebInspector.AXComputedTextSubPane.prototype = { 218 WebInspector.AXComputedTextSubPane.prototype = {
220 /** 219 /**
221 * @param {?AccessibilityAgent.AXNode} axNode 220 * @param {?AccessibilityAgent.AXNode} axNode
222 * @override 221 * @override
223 */ 222 */
224 setAXNode: function(axNode) 223 setAXNode: function(axNode)
225 { 224 {
226 if (this._axNode === axNode) 225 if (this._axNode === axNode)
227 return; 226 return;
228 this._axNode = axNode; 227 this._axNode = axNode;
229 228
230 var treeOutline = this._treeOutline; 229 var treeOutline = this._treeOutline;
231 treeOutline.removeChildren(); 230 treeOutline.removeChildren();
232 var target = this.node().target(); 231 var target = this.node().target();
233 232
234 if (!axNode || axNode.ignored) { 233 if (!axNode || axNode.ignored) {
235 this._noTextInfo.classList.add("hidden");
236 this._computedTextElement.classList.add("hidden"); 234 this._computedTextElement.classList.add("hidden");
237 treeOutline.element.classList.add("hidden"); 235 treeOutline.element.classList.add("hidden");
238 236
239 this._noNodeInfo.classList.remove("hidden"); 237 this._noTextInfo.classList.remove("hidden");
240 return; 238 return;
241 } 239 }
242 this._noNodeInfo.classList.add("hidden");
243
244 this._computedTextElement.removeChildren(); 240 this._computedTextElement.removeChildren();
245 241
246 // TODO(aboxhall): include contents where appropriate (requires protocol change) 242 // TODO(aboxhall): include contents where appropriate (requires protocol change)
247 this._computedTextElement.classList.toggle("hidden", !axNode.name || !ax Node.name.value); 243 this._computedTextElement.classList.toggle("hidden", !axNode.name || !ax Node.name.value);
248 if (axNode.name && axNode.name.value) 244 if (axNode.name && axNode.name.value)
249 this._computedTextElement.createChild("div").textContent = axNode.na me.value; 245 this._computedTextElement.createChild("div").textContent = axNode.na me.value;
250 246
251 var foundProperty = false; 247 var foundProperty = false;
252 /** 248 /**
253 * @param {!AccessibilityAgent.AXProperty} property 249 * @param {!AccessibilityAgent.AXProperty} property
254 */ 250 */
255 function addProperty(property) 251 function addProperty(property)
256 { 252 {
257 foundProperty = true; 253 foundProperty = true;
258 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target)); 254 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target));
259 } 255 }
260 256
261 for (var propertyName of ["name", "description", "help"]) {
262 if (propertyName in axNode) {
263 var defaultProperty = /** @type {!AccessibilityAgent.AXProperty} */ ({name: propertyName, value: axNode[propertyName]});
264 addProperty(defaultProperty);
265 }
266 }
267
268 if ("value" in axNode && axNode.value.type === "string") 257 if ("value" in axNode && axNode.value.type === "string")
269 addProperty(/** @type {!AccessibilityAgent.AXProperty} */ ({name: "v alue", value: axNode.value})); 258 addProperty(/** @type {!AccessibilityAgent.AXProperty} */ ({name: "v alue", value: axNode.value}));
270 259
271 var propertiesArray = /** @type {!Array.<!AccessibilityAgent.AXProperty> } */ (axNode.properties); 260 var propertiesArray = /** @type {!Array.<!AccessibilityAgent.AXProperty> } */ (axNode.properties);
272 for (var property of propertiesArray) { 261 for (var property of propertiesArray) {
273 if (property.name == AccessibilityAgent.AXWidgetAttributes.Valuetext ) { 262 if (property.name == AccessibilityAgent.AXWidgetAttributes.Valuetext ) {
274 addProperty(property); 263 addProperty(property);
275 break; 264 break;
276 } 265 }
277 } 266 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 var ignoredReasons = this._ignoredReasonsTree; 304 var ignoredReasons = this._ignoredReasonsTree;
316 ignoredReasons.removeChildren(); 305 ignoredReasons.removeChildren();
317 var target = this.node().target(); 306 var target = this.node().target();
318 307
319 if (!axNode) { 308 if (!axNode) {
320 treeOutline.element.classList.add("hidden"); 309 treeOutline.element.classList.add("hidden");
321 this._ignoredInfo.classList.add("hidden"); 310 this._ignoredInfo.classList.add("hidden");
322 ignoredReasons.element.classList.add("hidden"); 311 ignoredReasons.element.classList.add("hidden");
323 312
324 this._noNodeInfo.classList.remove("hidden"); 313 this._noNodeInfo.classList.remove("hidden");
314 this.element.classList.add("ax-ignored-node-pane");
315
325 return; 316 return;
326 } else if (axNode.ignored) { 317 } else if (axNode.ignored) {
327 this._noNodeInfo.classList.add("hidden"); 318 this._noNodeInfo.classList.add("hidden");
328 treeOutline.element.classList.add("hidden"); 319 treeOutline.element.classList.add("hidden");
320 this.element.classList.add("ax-ignored-node-pane");
329 321
330 this._ignoredInfo.classList.remove("hidden"); 322 this._ignoredInfo.classList.remove("hidden");
331 ignoredReasons.element.classList.remove("hidden"); 323 ignoredReasons.element.classList.remove("hidden");
332 /** 324 /**
333 * @param {!AccessibilityAgent.AXProperty} property 325 * @param {!AccessibilityAgent.AXProperty} property
334 */ 326 */
335 function addIgnoredReason(property) 327 function addIgnoredReason(property)
336 { 328 {
337 ignoredReasons.appendChild(new WebInspector.AXNodeIgnoredReasonT reeElement(property, axNode, target)); 329 ignoredReasons.appendChild(new WebInspector.AXNodeIgnoredReasonT reeElement(property, axNode, target));
338 } 330 }
339 var ignoredReasonsArray = /** @type {!Array.<!Object>} */(axNode.ign oredReasons); 331 var ignoredReasonsArray = /** @type {!Array.<!Object>} */(axNode.ign oredReasons);
340 for (var reason of ignoredReasonsArray) 332 for (var reason of ignoredReasonsArray)
341 addIgnoredReason(reason); 333 addIgnoredReason(reason);
342 if (!ignoredReasons.firstChild()) 334 if (!ignoredReasons.firstChild())
343 ignoredReasons.element.classList.add("hidden"); 335 ignoredReasons.element.classList.add("hidden");
344 return; 336 return;
345 } 337 }
338 this.element.classList.remove("ax-ignored-node-pane");
339
346 this._ignoredInfo.classList.add("hidden"); 340 this._ignoredInfo.classList.add("hidden");
347 ignoredReasons.element.classList.add("hidden"); 341 ignoredReasons.element.classList.add("hidden");
348 this._noNodeInfo.classList.add("hidden"); 342 this._noNodeInfo.classList.add("hidden");
349 343
350 treeOutline.element.classList.remove("hidden"); 344 treeOutline.element.classList.remove("hidden");
351 345
352 /** 346 /**
353 * @param {!AccessibilityAgent.AXProperty} property 347 * @param {!AccessibilityAgent.AXProperty} property
354 */ 348 */
355 function addProperty(property) 349 function addProperty(property)
356 { 350 {
357 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target)); 351 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target));
358 } 352 }
359 353
360 var roleProperty = /** @type {!AccessibilityAgent.AXProperty} */ ({name: "role", value: axNode.role}); 354 for (var propertyName of ["name", "description", "help", "value"]) {
361 addProperty(roleProperty);
362
363 for (var propertyName of ["description", "help", "value"]) {
364 if (propertyName in axNode) { 355 if (propertyName in axNode) {
365 var defaultProperty = /** @type {!AccessibilityAgent.AXProperty} */ ({name: propertyName, value: axNode[propertyName]}); 356 var defaultProperty = /** @type {!AccessibilityAgent.AXProperty} */ ({name: propertyName, value: axNode[propertyName]});
366 addProperty(defaultProperty); 357 addProperty(defaultProperty);
367 } 358 }
368 } 359 }
369 360
361 var roleProperty = /** @type {!AccessibilityAgent.AXProperty} */ ({name: "role", value: axNode.role});
362 addProperty(roleProperty);
363
370 var propertyMap = {}; 364 var propertyMap = {};
371 var propertiesArray = /** @type {!Array.<!AccessibilityAgent.AXProperty> } */ (axNode.properties); 365 var propertiesArray = /** @type {!Array.<!AccessibilityAgent.AXProperty> } */ (axNode.properties);
372 for (var property of propertiesArray) 366 for (var property of propertiesArray)
373 propertyMap[property.name] = property; 367 propertyMap[property.name] = property;
374 368
375 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) { 369 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) {
376 for (var propertyKey in propertySet) { 370 for (var propertyKey in propertySet) {
377 var property = propertySet[propertyKey]; 371 var property = propertySet[propertyKey];
378 if (property in propertyMap) 372 if (property in propertyMap)
379 addProperty(propertyMap[property]); 373 addProperty(propertyMap[property]);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 var numNodes = relatedNodes.length; 417 var numNodes = relatedNodes.length;
424 var description = "(" + numNodes + (numNodes == 1 ? " node" : " node s") + ")"; 418 var description = "(" + numNodes + (numNodes == 1 ? " node" : " node s") + ")";
425 value.value = description; 419 value.value = description;
426 for (var i = 0; i < relatedNodes.length; i++) { 420 for (var i = 0; i < relatedNodes.length; i++) {
427 var backendId = relatedNodes[i].backendNodeId; 421 var backendId = relatedNodes[i].backendNodeId;
428 var deferredNode = new WebInspector.DeferredDOMNode(this._target , relatedNodes[i].backendNodeId); 422 var deferredNode = new WebInspector.DeferredDOMNode(this._target , relatedNodes[i].backendNodeId);
429 var child = new WebInspector.AXRelatedNodeTreeElement(deferredNo de); 423 var child = new WebInspector.AXRelatedNodeTreeElement(deferredNo de);
430 this.appendChild(child); 424 this.appendChild(child);
431 } 425 }
432 this._valueElement = WebInspector.AXNodePropertyTreeElement.createVa lueElement(value, this.listItemElement); 426 this._valueElement = WebInspector.AXNodePropertyTreeElement.createVa lueElement(value, this.listItemElement);
427 if (relatedNodes.length <= 3)
428 this.expand();
429 else
430 this.collapse();
433 } else { 431 } else {
434 this._valueElement = WebInspector.AXNodePropertyTreeElement.createVa lueElement(value, this.listItemElement); 432 this._valueElement = WebInspector.AXNodePropertyTreeElement.createVa lueElement(value, this.listItemElement);
435 } 433 }
436 434
437 var separatorElement = createElementWithClass("span", "separator"); 435 var separatorElement = createElementWithClass("span", "separator");
438 separatorElement.textContent = ": "; 436 separatorElement.textContent = ": ";
439 437
440 this.listItemElement.removeChildren(); 438 this.listItemElement.removeChildren();
441 this.listItemElement.appendChildren(this._nameElement, separatorElement, this._valueElement); 439 this.listItemElement.appendChildren(this._nameElement, separatorElement, this._valueElement);
442 }, 440 },
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 reasonElement = WebInspector.formatLocalized("Static text node is used a s name for ", [], ""); 679 reasonElement = WebInspector.formatLocalized("Static text node is used a s name for ", [], "");
682 break; 680 break;
683 case "uninteresting": 681 case "uninteresting":
684 reasonElement = WebInspector.formatLocalized("Element not interesting fo r accessibility.", [], "") 682 reasonElement = WebInspector.formatLocalized("Element not interesting fo r accessibility.", [], "")
685 break; 683 break;
686 } 684 }
687 if (reasonElement) 685 if (reasonElement)
688 reasonElement.classList.add("ax-reason"); 686 reasonElement.classList.add("ax-reason");
689 return reasonElement; 687 return reasonElement;
690 } 688 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/accessibility/AccessibilityStrings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698