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

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

Issue 1076453004: Show reasons why nodes are ignored in accessibility sidebar (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: pfeldman review comments (take 3) Created 5 years, 7 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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.ThrottledElementsSidebarView} 7 * @extends {WebInspector.ThrottledElementsSidebarView}
8 */ 8 */
9 WebInspector.AccessibilitySidebarView = function() 9 WebInspector.AccessibilitySidebarView = function()
10 { 10 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 /** 50 /**
51 * @constructor 51 * @constructor
52 * @extends {WebInspector.SidebarPane} 52 * @extends {WebInspector.SidebarPane}
53 */ 53 */
54 WebInspector.AXNodeSubPane = function() 54 WebInspector.AXNodeSubPane = function()
55 { 55 {
56 WebInspector.SidebarPane.call(this, WebInspector.UIString("Accessibility Nod e")); 56 WebInspector.SidebarPane.call(this, WebInspector.UIString("Accessibility Nod e"));
57 57
58 this.registerRequiredCSS("accessibility/accessibilityNode.css"); 58 this.registerRequiredCSS("accessibility/accessibilityNode.css");
59 59
60 this._computedNameElement = this.bodyElement.createChild("div", "ax-computed -name"); 60 this._computedNameElement = this.bodyElement.createChild("div", "ax-computed -name hidden");
61 61
62 this._infoElement = createElementWithClass("div", "info hidden"); 62 this._noNodeInfo = createElementWithClass("div", "info");
63 this._infoElement.textContent = WebInspector.UIString("No Accessibility Node "); 63 this._noNodeInfo.textContent = WebInspector.UIString("No accessibility node" );
64 this.bodyElement.appendChild(this._infoElement); 64 this.bodyElement.appendChild(this._noNodeInfo);
65
66 this._ignoredInfo = createElementWithClass("div", "ax-ignored-info hidden");
67 this._ignoredInfo.textContent = WebInspector.UIString("Accessibility node no t exposed");
68 this.bodyElement.appendChild(this._ignoredInfo);
65 69
66 this._treeOutline = new TreeOutlineInShadow('monospace'); 70 this._treeOutline = new TreeOutlineInShadow('monospace');
67 this._treeOutline.registerRequiredCSS("accessibility/accessibilityNode.css") ; 71 this._treeOutline.registerRequiredCSS("accessibility/accessibilityNode.css") ;
68 this._treeOutline.registerRequiredCSS("components/objectValue.css"); 72 this._treeOutline.registerRequiredCSS("components/objectValue.css");
73 this._treeOutline.element.classList.add("hidden");
69 this.bodyElement.appendChild(this._treeOutline.element); 74 this.bodyElement.appendChild(this._treeOutline.element);
75
76 this._ignoredReasonsTree = new TreeOutlineInShadow();
77 this._ignoredReasonsTree.element.classList.add("hidden");
78 this._ignoredReasonsTree.registerRequiredCSS("accessibility/accessibilityNod e.css");
79 this._ignoredReasonsTree.registerRequiredCSS("components/objectValue.css");
80 this.bodyElement.appendChild(this._ignoredReasonsTree.element);
70 }; 81 };
71 82
72 83
73 WebInspector.AXNodeSubPane.prototype = { 84 WebInspector.AXNodeSubPane.prototype = {
74 /** 85 /**
75 * @param {!WebInspector.Throttler.FinishCallback} callback 86 * @param {!WebInspector.Throttler.FinishCallback} callback
76 */ 87 */
77 doUpdate: function(callback) 88 doUpdate: function(callback)
78 { 89 {
79 /** 90 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 * @param {?AccessibilityAgent.AXNode} axNode 128 * @param {?AccessibilityAgent.AXNode} axNode
118 */ 129 */
119 _setAXNode: function(axNode) 130 _setAXNode: function(axNode)
120 { 131 {
121 if (this._axNode === axNode) 132 if (this._axNode === axNode)
122 return; 133 return;
123 this._axNode = axNode; 134 this._axNode = axNode;
124 135
125 var treeOutline = this._treeOutline; 136 var treeOutline = this._treeOutline;
126 treeOutline.removeChildren(); 137 treeOutline.removeChildren();
138 var ignoredReasons = this._ignoredReasonsTree;
139 ignoredReasons.removeChildren();
140
141 var target = this.parentView().parentView().node().target();
127 142
128 if (!axNode) { 143 if (!axNode) {
129 this._computedNameElement.classList.add("hidden"); 144 this._computedNameElement.classList.add("hidden");
130 treeOutline.element.classList.add("hidden"); 145 treeOutline.element.classList.add("hidden");
131 this._infoElement.classList.remove("hidden"); 146 this._ignoredInfo.classList.add("hidden");
147 ignoredReasons.element.classList.add("hidden");
148
149 this._noNodeInfo.classList.remove("hidden");
150 return;
151 } else if (axNode.ignored) {
152 this._computedNameElement.classList.add("hidden");
153 this._noNodeInfo.classList.add("hidden");
154 treeOutline.element.classList.add("hidden");
155
156 this._ignoredInfo.classList.remove("hidden");
157 ignoredReasons.element.classList.remove("hidden");
158 function addIgnoredReason(property) {
159 ignoredReasons.appendChild(new WebInspector.AXNodeIgnoredReasonT reeElement(property, target));
160 }
161 var ignoredReasonsArray = /** @type {!Array.<!Object>} */(axNode.ign oredReasons);
162 for (var reason of ignoredReasonsArray)
163 addIgnoredReason(reason);
164 if (!ignoredReasons.firstChild())
165 ignoredReasons.element.classList.add("hidden");
132 return; 166 return;
133 } 167 }
168 this._ignoredInfo.classList.add("hidden");
169 ignoredReasons.element.classList.add("hidden");
170 this._noNodeInfo.classList.add("hidden");
171
134 this._computedNameElement.classList.remove("hidden"); 172 this._computedNameElement.classList.remove("hidden");
135 treeOutline.element.classList.remove("hidden"); 173 treeOutline.element.classList.remove("hidden");
136 this._infoElement.classList.add("hidden");
137
138 var target = this.parentView().parentView().node().target();
139 174
140 this._computedNameElement.removeChildren(); 175 this._computedNameElement.removeChildren();
141 if (axNode.name && axNode.name.value) 176 if (axNode.name && axNode.name.value)
142 this._computedNameElement.textContent = axNode.name.value; 177 this._computedNameElement.textContent = axNode.name.value;
143 178
144 function addProperty(property) 179 function addProperty(property)
145 { 180 {
146 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target)); 181 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target));
147 } 182 }
148 183
149 addProperty({name: "role", value: axNode.role}); 184 addProperty({name: "role", value: axNode.role});
150 185
151 for (var propertyName of ["description", "help", "value"]) { 186 for (var propertyName of ["description", "help", "value"]) {
152 if (propertyName in axNode) 187 if (propertyName in axNode)
153 addProperty({name: propertyName, value: axNode[propertyName]}); 188 addProperty({name: propertyName, value: axNode[propertyName]});
154 } 189 }
155 190
156 var propertyMap = {}; 191 var propertyMap = {};
157 for (var property of axNode.properties) 192 var propertiesArray = /** @type {!Array.<!Object>} */ (axNode.properties );
193 for (var property of propertiesArray)
158 propertyMap[property.name] = property; 194 propertyMap[property.name] = property;
159 195
160 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) { 196 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) {
161 for (var propertyKey in propertySet) { 197 for (var propertyKey in propertySet) {
162 var property = propertySet[propertyKey]; 198 var property = propertySet[propertyKey];
163 if (property in propertyMap) 199 if (property in propertyMap)
164 addProperty(propertyMap[property]); 200 addProperty(propertyMap[property]);
165 } 201 }
166 } 202 }
167 }, 203 },
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 WebInspector.AXNodePropertyTreeElement.TypeStyles = { 396 WebInspector.AXNodePropertyTreeElement.TypeStyles = {
361 boolean: "object-value-boolean", 397 boolean: "object-value-boolean",
362 booleanOrUndefined: "object-value-boolean", 398 booleanOrUndefined: "object-value-boolean",
363 tristate: "object-value-boolean", 399 tristate: "object-value-boolean",
364 number: "object-value-number", 400 number: "object-value-number",
365 integer: "object-value-number", 401 integer: "object-value-number",
366 string: "object-value-string", 402 string: "object-value-string",
367 role: "ax-role", 403 role: "ax-role",
368 internalRole: "ax-internal-role" 404 internalRole: "ax-internal-role"
369 }; 405 };
406
407 /**
408 * @constructor
409 * @extends {TreeElement}
410 * @param {!AccessibilityAgent.AXProperty} property
411 * @param {!WebInspector.Target} target
412 */
413 WebInspector.AXNodeIgnoredReasonTreeElement = function(property, target)
414 {
415 this._property = property;
416 this._target = target;
417
418 // Pass an empty title, the title gets made later in onattach.
419 TreeElement.call(this, "");
420 this.toggleOnClick = true;
421 this.selectable = false;
422 }
423
424 WebInspector.AXNodeIgnoredReasonTreeElement.prototype = {
425 /**
426 * @override
427 */
428 onattach: function()
429 {
430 this.listItemElement.removeChildren();
431
432 this._reasonElement = WebInspector.AXNodeIgnoredReasonTreeElement.create ReasonElement(this._property.name);
433 this.listItemElement.appendChild(this._reasonElement);
434
435 var value = this._property.value;
436 if (value.type === "idref") {
437 this._valueElement = WebInspector.AXNodePropertyTreeElement.createRe lationshipValueElement(value, this._target);
438 this.listItemElement.appendChild(this._valueElement);
439 }
440 },
441
442 __proto__: TreeElement.prototype
443 };
444
445 /**
446 * @param {?string} reason
447 * @return {?Element}
448 */
449 WebInspector.AXNodeIgnoredReasonTreeElement.createReasonElement = function(reaso n)
450 {
451 var reasonElement = null;
452 switch(reason) {
453 case "activeModalDialog":
454 reasonElement = WebInspector.formatLocalized("Element is hidden by activ e modal dialog: ", [], "");
455 break;
456 case "ancestorDisallowsChild":
457 reasonElement = WebInspector.formatLocalized("Element is not permitted a s child of ", [], "");
458 break;
459 // http://www.w3.org/TR/wai-aria/roles#childrenArePresentational
460 case "ancestorIsLeafNode":
461 reasonElement = WebInspector.formatLocalized("Ancestor's children are al l presentational: ", [], "");
462 break;
463 case "ariaHidden":
464 var ariaHiddenSpan = createElement("span", "source-code").textContent = "aria-hidden";
465 reasonElement = WebInspector.formatLocalized("Element is %s.", [ ariaHid denSpan ], "");
466 break;
467 case "ariaHiddenRoot":
468 var ariaHiddenSpan = createElement("span", "source-code").textContent = "aria-hidden";
469 var trueSpan = createElement("span", "source-code").textContent = "true" ;
470 reasonElement = WebInspector.formatLocalized("%s is %s on ancestor: ", [ ariaHiddenSpan, trueSpan ], "");
471 break;
472 case "emptyAlt":
473 reasonElement = WebInspector.formatLocalized("Element has empty alt text .", [], "");
474 break;
475 case "emptyText":
476 reasonElement = WebInspector.formatLocalized("No text content.", [], "") ;
477 break;
478 case "inert":
479 reasonElement = WebInspector.formatLocalized("Element is inert.", [], "" );
480 break;
481 case "inheritsPresentation":
482 reasonElement = WebInspector.formatLocalized("Element inherits presentat ional role from ", [], "");
483 break;
484 case "labelContainer":
485 reasonElement = WebInspector.formatLocalized("Part of label element: ", [], "");
486 break;
487 case "labelFor":
488 reasonElement = WebInspector.formatLocalized("Label for ", [], "");
489 break;
490 case "notRendered":
491 reasonElement = WebInspector.formatLocalized("Element is not rendered.", [], "");
492 break;
493 case "notVisible":
494 reasonElement = WebInspector.formatLocalized("Element is not visible.", [], "");
495 break;
496 case "presentationRole":
497 var rolePresentationSpan = createElement("span", "source-code").textCont ent = "role=presentation";
498 reasonElement = WebInspector.formatLocalized("Element has %s.", [ rolePr esentationSpan ], "");
499 break;
500 case "probablyPresentational":
501 reasonElement = WebInspector.formatLocalized("Element is presentational. ", [], "");
502 break;
503 case "staticTextUsedAsNameFor":
504 reasonElement = WebInspector.formatLocalized("Static text node is used a s name for ", [], "");
505 break;
506 case "uninteresting":
507 reasonElement = WebInspector.formatLocalized("Element not interesting fo r accessibility.", [], "")
508 break;
509 }
510 if (reasonElement)
511 reasonElement.classList.add("ax-reason");
512 return reasonElement;
513 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698