Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 console.log('ignored node:', axNode); | |
| 153 this._computedNameElement.classList.add("hidden"); | |
| 154 this._noNodeInfo.classList.add("hidden"); | |
| 155 treeOutline.element.classList.add("hidden"); | |
| 156 | |
| 157 this._ignoredInfo.classList.remove("hidden"); | |
| 158 ignoredReasons.element.classList.remove("hidden"); | |
| 159 function addIgnoredReason(property) { | |
| 160 ignoredReasons.appendChild(new WebInspector.AXNodeIgnoredReasonT reeElement(property, target)); | |
| 161 } | |
| 162 var ignoredReasonsArray = /** @type {!Array.<!Object>} */(axNode.ign oredReasons); | |
| 163 for (var reason of ignoredReasonsArray) { | |
| 164 console.log("ignoredReason: ", reason); | |
| 165 addIgnoredReason(reason); | |
| 166 } | |
| 167 if (!ignoredReasons.firstChild()) | |
| 168 ignoredReasons.element.classList.add("hidden"); | |
| 132 return; | 169 return; |
| 133 } | 170 } |
| 171 this._ignoredInfo.classList.add("hidden"); | |
| 172 ignoredReasons.element.classList.add("hidden"); | |
| 173 this._noNodeInfo.classList.add("hidden"); | |
| 174 | |
| 134 this._computedNameElement.classList.remove("hidden"); | 175 this._computedNameElement.classList.remove("hidden"); |
| 135 treeOutline.element.classList.remove("hidden"); | 176 treeOutline.element.classList.remove("hidden"); |
| 136 this._infoElement.classList.add("hidden"); | |
| 137 | |
| 138 var target = this.parentView().parentView().node().target(); | |
| 139 | 177 |
| 140 this._computedNameElement.removeChildren(); | 178 this._computedNameElement.removeChildren(); |
| 141 if (axNode.name && axNode.name.value) | 179 if (axNode.name && axNode.name.value) |
| 142 this._computedNameElement.textContent = axNode.name.value; | 180 this._computedNameElement.textContent = axNode.name.value; |
| 143 | 181 |
| 144 function addProperty(property) | 182 function addProperty(property) |
| 145 { | 183 { |
| 146 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target)); | 184 treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(p roperty, target)); |
| 147 } | 185 } |
| 148 | 186 |
| 149 addProperty({name: "role", value: axNode.role}); | 187 addProperty({name: "role", value: axNode.role}); |
| 150 | 188 |
| 151 for (var propertyName of ["description", "help", "value"]) { | 189 for (var propertyName of ["description", "help", "value"]) { |
| 152 if (propertyName in axNode) | 190 if (propertyName in axNode) |
| 153 addProperty({name: propertyName, value: axNode[propertyName]}); | 191 addProperty({name: propertyName, value: axNode[propertyName]}); |
| 154 } | 192 } |
| 155 | 193 |
| 156 var propertyMap = {}; | 194 var propertyMap = {}; |
| 157 for (var property of axNode.properties) | 195 var propertiesArray = /** @type {!Array.<!Object>} */ (axNode.properties ); |
| 196 for (var property of propertiesArray) | |
| 158 propertyMap[property.name] = property; | 197 propertyMap[property.name] = property; |
| 159 | 198 |
| 160 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) { | 199 for (var propertySet of [AccessibilityAgent.AXWidgetAttributes, Accessib ilityAgent.AXWidgetStates, AccessibilityAgent.AXGlobalStates, AccessibilityAgent .AXLiveRegionAttributes, AccessibilityAgent.AXRelationshipAttributes]) { |
| 161 for (var propertyKey in propertySet) { | 200 for (var propertyKey in propertySet) { |
| 162 var property = propertySet[propertyKey]; | 201 var property = propertySet[propertyKey]; |
| 163 if (property in propertyMap) | 202 if (property in propertyMap) |
| 164 addProperty(propertyMap[property]); | 203 addProperty(propertyMap[property]); |
| 165 } | 204 } |
| 166 } | 205 } |
| 167 }, | 206 }, |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 WebInspector.AXNodePropertyTreeElement.TypeStyles = { | 399 WebInspector.AXNodePropertyTreeElement.TypeStyles = { |
| 361 boolean: "object-value-boolean", | 400 boolean: "object-value-boolean", |
| 362 booleanOrUndefined: "object-value-boolean", | 401 booleanOrUndefined: "object-value-boolean", |
| 363 tristate: "object-value-boolean", | 402 tristate: "object-value-boolean", |
| 364 number: "object-value-number", | 403 number: "object-value-number", |
| 365 integer: "object-value-number", | 404 integer: "object-value-number", |
| 366 string: "object-value-string", | 405 string: "object-value-string", |
| 367 role: "ax-role", | 406 role: "ax-role", |
| 368 internalRole: "ax-internal-role" | 407 internalRole: "ax-internal-role" |
| 369 }; | 408 }; |
| 409 | |
| 410 /** | |
| 411 * @constructor | |
| 412 * @extends {TreeElement} | |
| 413 * @param {!AccessibilityAgent.AXProperty} property | |
| 414 * @param {!WebInspector.Target} target | |
| 415 */ | |
| 416 WebInspector.AXNodeIgnoredReasonTreeElement = function(property, target) | |
| 417 { | |
| 418 this._property = property; | |
| 419 this._target = target; | |
| 420 | |
| 421 // Pass an empty title, the title gets made later in onattach. | |
| 422 TreeElement.call(this, ""); | |
| 423 this.toggleOnClick = true; | |
| 424 this.selectable = false; | |
| 425 } | |
| 426 | |
| 427 WebInspector.AXNodeIgnoredReasonTreeElement.prototype = { | |
| 428 /** | |
| 429 * @override | |
| 430 */ | |
| 431 onattach: function() | |
| 432 { | |
| 433 this._update(); | |
|
pfeldman
2015/04/29 13:59:22
Inline this method?
aboxhall
2015/04/29 19:08:11
Done.
| |
| 434 }, | |
| 435 | |
| 436 | |
| 437 _update: function() | |
| 438 { | |
| 439 this.listItemElement.removeChildren(); | |
| 440 | |
| 441 this._reasonElement = WebInspector.AXNodeIgnoredReasonTreeElement.create ReasonElement(this._property.name); | |
| 442 this.listItemElement.appendChild(this._reasonElement); | |
| 443 | |
| 444 var value = this._property.value; | |
| 445 if (value.type === "idref") { | |
| 446 this._valueElement = WebInspector.AXNodePropertyTreeElement.createRe lationshipValueElement(value, this._target); | |
| 447 this.listItemElement.appendChild(this._valueElement); | |
| 448 } | |
| 449 }, | |
| 450 | |
| 451 __proto__: TreeElement.prototype | |
| 452 }; | |
| 453 | |
| 454 /** | |
| 455 * @param {?string} reason | |
| 456 * @return {!Element} | |
| 457 */ | |
| 458 WebInspector.AXNodeIgnoredReasonTreeElement.createReasonElement = function(reaso n) | |
| 459 { | |
| 460 var reasonElement = createElementWithClass("span", "ax-reason"); | |
| 461 switch(reason) { | |
| 462 case "activeModalDialog": | |
| 463 reasonElement.innerHTML = "Element is hidden by active modal dialog: "; | |
|
pfeldman
2015/04/29 13:59:22
Never ever ever ever use innerHTML =, should be te
aboxhall
2015/04/29 19:08:11
Done.
| |
| 464 break; | |
| 465 case "ancestorDisallowsChild": | |
| 466 reasonElement.innerHTML = "Element is not permitted as child of "; | |
| 467 break; | |
| 468 // http://www.w3.org/TR/wai-aria/roles#childrenArePresentational | |
| 469 case "ancestorIsLeafNode": | |
| 470 reasonElement.innerHTML = "Ancestor's children are all presentational: " | |
| 471 break; | |
| 472 case "ariaHidden": | |
| 473 reasonElement.innerHTML = "Element is <span class='source-code'>aria-hid den</span>." | |
| 474 break; | |
| 475 case "ariaHiddenRoot": | |
| 476 reasonElement.innerHTML = "<span class='source-code'>aria-hidden</span> is <span class='source-code'>true</span> on ancestor: " | |
| 477 break; | |
| 478 case "emptyAlt": | |
| 479 reasonElement.innerHTML = "Element has empty alt text." | |
| 480 break; | |
| 481 case "emptyText": | |
| 482 reasonElement.innerHTML = "No text content."; | |
| 483 break; | |
| 484 case "inert": | |
| 485 reasonElement.innerHTML = "Element is inert."; | |
| 486 break; | |
| 487 case "inheritsPresentation": | |
| 488 reasonElement.innerHTML = "Element inherits presentational role from "; | |
| 489 break; | |
| 490 case "labelContainer": | |
| 491 reasonElement.innerHTML = "Part of label element: "; | |
| 492 break; | |
| 493 case "labelFor": | |
| 494 reasonElement.innerHTML = "Label for "; | |
| 495 break; | |
| 496 case "notRendered": | |
| 497 reasonElement.innerHTML = "Element is not rendered."; | |
| 498 break; | |
| 499 case "notVisible": | |
| 500 reasonElement.innerHTML = "Element is not visible."; | |
| 501 break; | |
| 502 case "presentationRole": | |
| 503 reasonElement.innerHTML = "Element has <span clas=\"source-code\">role=p resentation</span>."; | |
| 504 break; | |
| 505 case "probablyPresentational": | |
| 506 reasonElement.innerHTML = "Element is presentational."; | |
| 507 break; | |
| 508 case "staticTextUsedAsNameFor": | |
| 509 reasonElement.innerHTML = "Static text node is used as name for "; | |
| 510 break; | |
| 511 case "uninteresting": | |
| 512 reasonElement.innerHTML = "Element not interesting for accessibility." | |
| 513 break; | |
| 514 } | |
| 515 | |
| 516 return reasonElement; | |
| 517 } | |
| OLD | NEW |