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

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: Created 5 years, 8 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 hidden");
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.registerRequiredCSS("accessibility/accessibilityNod e.css");
78 this._ignoredReasonsTree.registerRequiredCSS("components/objectValue.css");
79 this.bodyElement.appendChild(this._ignoredReasonsTree.element);
70 }; 80 };
71 81
72 82
73 WebInspector.AXNodeSubPane.prototype = { 83 WebInspector.AXNodeSubPane.prototype = {
74 /** 84 /**
75 * @param {!WebInspector.Throttler.FinishCallback} callback 85 * @param {!WebInspector.Throttler.FinishCallback} callback
76 */ 86 */
77 doUpdate: function(callback) 87 doUpdate: function(callback)
78 { 88 {
79 /** 89 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 * @param {?AccessibilityAgent.AXNode} axNode 127 * @param {?AccessibilityAgent.AXNode} axNode
118 */ 128 */
119 _setAXNode: function(axNode) 129 _setAXNode: function(axNode)
120 { 130 {
121 if (this._axNode === axNode) 131 if (this._axNode === axNode)
122 return; 132 return;
123 this._axNode = axNode; 133 this._axNode = axNode;
124 134
125 var treeOutline = this._treeOutline; 135 var treeOutline = this._treeOutline;
126 treeOutline.removeChildren(); 136 treeOutline.removeChildren();
137 var ignoredReasons = this._ignoredReasonsTree;
138 ignoredReasons.removeChildren();
139
140 var target = this.parentView().parentView().node().target();
127 141
128 if (!axNode) { 142 if (!axNode) {
129 this._computedNameElement.classList.add("hidden"); 143 this._computedNameElement.classList.add("hidden");
130 treeOutline.element.classList.add("hidden"); 144 treeOutline.element.classList.add("hidden");
131 this._infoElement.classList.remove("hidden"); 145 this._ignoredInfo.classList.add("hidden");
146 ignoredReasons.element.classList.add("hidden");
147
148 this._noNodeInfo.classList.remove("hidden");
149 return;
150 } else if (axNode.ignored) {
151 console.log('ignored node:', axNode);
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 console.log("ignoredReason: ", reason);
164 addIgnoredReason(reason);
165 }
166 if (!ignoredReasons.firstChild())
167 ignoredReasons.element.classList.add("hidden");
132 return; 168 return;
133 } 169 }
170 this._ignoredInfo.classList.add("hidden");
171 ignoredReasons.element.classList.add("hidden");
172 this._noNodeInfo.classList.add("hidden");
173
134 this._computedNameElement.classList.remove("hidden"); 174 this._computedNameElement.classList.remove("hidden");
135 treeOutline.element.classList.remove("hidden"); 175 treeOutline.element.classList.remove("hidden");
136 this._infoElement.classList.add("hidden");
137
138 var target = this.parentView().parentView().node().target();
139 176
140 this._computedNameElement.removeChildren(); 177 this._computedNameElement.removeChildren();
141 if (axNode.name && axNode.name.value) 178 if (axNode.name && axNode.name.value)
142 this._computedNameElement.textContent = axNode.name.value; 179 this._computedNameElement.textContent = axNode.name.value;
143 180
144 function addProperty(property) 181 function addProperty(property)
145 { 182 {
146 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target)); 183 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target));
147 } 184 }
148 185
149 addProperty({name: "role", value: axNode.role}); 186 addProperty({name: "role", value: axNode.role});
150 187
151 for (var propertyName of ["description", "help", "value"]) { 188 for (var propertyName of ["description", "help", "value"]) {
152 if (propertyName in axNode) 189 if (propertyName in axNode)
153 addProperty({name: propertyName, value: axNode[propertyName]}); 190 addProperty({name: propertyName, value: axNode[propertyName]});
154 } 191 }
155 192
156 var propertyMap = {}; 193 var propertyMap = {};
157 for (var property of axNode.properties) 194 var propertiesArray = /** @type {!Array.<!Object>} */ (axNode.properties );
195 for (var property of propertiesArray)
158 propertyMap[property.name] = property; 196 propertyMap[property.name] = property;
159 197
160 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) { 198 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) {
161 for (var propertyKey in propertySet) { 199 for (var propertyKey in propertySet) {
162 var property = propertySet[propertyKey]; 200 var property = propertySet[propertyKey];
163 if (property in propertyMap) 201 if (property in propertyMap)
164 addProperty(propertyMap[property]); 202 addProperty(propertyMap[property]);
165 } 203 }
166 } 204 }
167 }, 205 },
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 WebInspector.AXNodePropertyTreeElement.TypeStyles = { 398 WebInspector.AXNodePropertyTreeElement.TypeStyles = {
361 boolean: "object-value-boolean", 399 boolean: "object-value-boolean",
362 booleanOrUndefined: "object-value-boolean", 400 booleanOrUndefined: "object-value-boolean",
363 tristate: "object-value-boolean", 401 tristate: "object-value-boolean",
364 number: "object-value-number", 402 number: "object-value-number",
365 integer: "object-value-number", 403 integer: "object-value-number",
366 string: "object-value-string", 404 string: "object-value-string",
367 role: "ax-role", 405 role: "ax-role",
368 internalRole: "ax-internal-role" 406 internalRole: "ax-internal-role"
369 }; 407 };
408
409 /**
410 * @constructor
411 * @extends {TreeElement}
412 * @param {!AccessibilityAgent.AXProperty} property
413 * @param {!WebInspector.Target} target
414 */
415 WebInspector.AXNodeIgnoredReasonTreeElement = function(property, target)
416 {
417 this._property = property;
418 this._target = target;
419
420 // Pass an empty title, the title gets made later in onattach.
421 TreeElement.call(this, "");
422 this.toggleOnClick = true;
423 this.selectable = false;
424 }
425
426 WebInspector.AXNodeIgnoredReasonTreeElement.prototype = {
427 /**
428 * @override
429 */
430 onattach: function()
431 {
432 this._update();
433 },
434
435
436 _update: function()
437 {
438 this.listItemElement.removeChildren();
439
440 this._reasonElement = WebInspector.AXNodeIgnoredReasonTreeElement.create ReasonElement(this._property.name);
441 this.listItemElement.appendChild(this._reasonElement);
442
443 var value = this._property.value;
444 if (value.type === "idref") {
445 this._valueElement = WebInspector.AXNodePropertyTreeElement.createRe lationshipValueElement(value, this._target);
446 this.listItemElement.appendChild(this._valueElement);
447 }
448 },
449
450 __proto__: TreeElement.prototype
451 };
452
453 /**
454 * @param {?string} reason
455 * @return {!Element}
456 */
457 WebInspector.AXNodeIgnoredReasonTreeElement.createReasonElement = function(reaso n)
458 {
459 var reasonElement = createElementWithClass("span", "ax-reason");
460 switch(reason) {
461 case AccessibilityAgent.AXIgnoredReasons.AriaHidden:
462 reasonElement.innerHTML = "This element is <span class='source-code'>ari a-hidden</span>"
463 break;
464 case AccessibilityAgent.AXIgnoredReasons.AriaHiddenRoot:
465 reasonElement.innerHTML = "<span class='source-code'>aria-hidden</span> is <span class='source-code'>true</span> on ancestor: "
466 break;
467 case AccessibilityAgent.AXIgnoredReasons.ActiveModalDialog:
468 reasonElement.innerHTML = "Hidden by active modal dialog: ";
469 break;
470 }
471 return reasonElement;
472 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/accessibility/accessibilityNode.css » ('j') | Source/devtools/protocol.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698