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.listItemElement.removeChildren(); | |
| 434 | |
| 435 this._reasonElement = WebInspector.AXNodeIgnoredReasonTreeElement.create ReasonElement(this._property.name); | |
| 436 this.listItemElement.appendChild(this._reasonElement); | |
| 437 | |
| 438 var value = this._property.value; | |
| 439 if (value.type === "idref") { | |
| 440 this._valueElement = WebInspector.AXNodePropertyTreeElement.createRe lationshipValueElement(value, this._target); | |
| 441 this.listItemElement.appendChild(this._valueElement); | |
| 442 } | |
| 443 }, | |
| 444 | |
| 445 __proto__: TreeElement.prototype | |
| 446 }; | |
| 447 | |
| 448 /** | |
| 449 * @param {?string} reason | |
| 450 * @return {!Element} | |
| 451 */ | |
| 452 WebInspector.AXNodeIgnoredReasonTreeElement.createReasonElement = function(reaso n) | |
| 453 { | |
| 454 var reasonElement = createElementWithClass("span", "ax-reason"); | |
| 455 switch(reason) { | |
| 456 case "activeModalDialog": | |
| 457 reasonElement.createTextChild("Element is hidden by active modal dialog: "); | |
|
pfeldman
2015/04/29 19:38:46
Wrap these with WebInspector.UIString()
aboxhall
2015/04/29 21:03:32
Done.
| |
| 458 break; | |
| 459 case "ancestorDisallowsChild": | |
| 460 reasonElement.createTextChild("Element is not permitted as child of "); | |
| 461 break; | |
| 462 // http://www.w3.org/TR/wai-aria/roles#childrenArePresentational | |
| 463 case "ancestorIsLeafNode": | |
| 464 reasonElement.createTextChild("Ancestor's children are all presentationa l: "); | |
| 465 break; | |
| 466 case "ariaHidden": | |
| 467 reasonElement.createTextChild("Element is "); | |
| 468 reasonElement.createChild("span", "source-code").textContent = "aria-hid den"; | |
| 469 reasonElement.createTextChild("."); | |
| 470 break; | |
| 471 case "ariaHiddenRoot": | |
| 472 reasonElement.createChild("span", "source-code").textContent = "aria-hid den"; | |
| 473 reasonElement.createTextChild(" is "); | |
| 474 reasonElement.createChild("span", "source-code").textContent = "true"; | |
| 475 reasonElement.createTextChild(" on ancestor: "); | |
| 476 break; | |
| 477 case "emptyAlt": | |
| 478 reasonElement.createTextChild("Element has empty alt text."); | |
| 479 break; | |
| 480 case "emptyText": | |
| 481 reasonElement.createTextChild("No text content."); | |
| 482 break; | |
| 483 case "inert": | |
| 484 reasonElement.createTextChild("Element is inert."); | |
| 485 break; | |
| 486 case "inheritsPresentation": | |
| 487 reasonElement.createTextChild("Element inherits presentational role from "); | |
| 488 break; | |
| 489 case "labelContainer": | |
| 490 reasonElement.createTextChild("Part of label element: "); | |
| 491 break; | |
| 492 case "labelFor": | |
| 493 reasonElement.createTextChild("Label for "); | |
| 494 break; | |
| 495 case "notRendered": | |
| 496 reasonElement.createTextChild("Element is not rendered."); | |
| 497 break; | |
| 498 case "notVisible": | |
| 499 reasonElement.createTextChild("Element is not visible."); | |
| 500 break; | |
| 501 case "presentationRole": | |
| 502 reasonElement.createTextChild("Element has ") | |
| 503 reasonElement.createChild("span", "source-code").textContent = "role=pre sentation"; | |
| 504 reasonElement.createTextChild("."); | |
| 505 break; | |
| 506 case "probablyPresentational": | |
| 507 reasonElement.createTextChild("Element is presentational."); | |
| 508 break; | |
| 509 case "staticTextUsedAsNameFor": | |
| 510 reasonElement.createTextChild("Static text node is used as name for "); | |
| 511 break; | |
| 512 case "uninteresting": | |
| 513 reasonElement.createTextChild("Element not interesting for accessibility .") | |
| 514 break; | |
| 515 } | |
| 516 return reasonElement; | |
| 517 } | |
| OLD | NEW |