OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @extends {WebInspector.AccessibilitySubPane} |
| 8 */ |
| 9 WebInspector.AXTreePane = function() |
| 10 { |
| 11 WebInspector.AccessibilitySubPane.call(this, WebInspector.UIString("Accessib
ility Tree")); |
| 12 |
| 13 this._treeOutline = this.createTreeOutline(); |
| 14 |
| 15 this.element.classList.add("accessibility-computed"); |
| 16 }; |
| 17 |
| 18 |
| 19 WebInspector.AXTreePane.prototype = { |
| 20 /** |
| 21 * @param {!Array<!AccessibilityAgent.AXNode>} nodes |
| 22 */ |
| 23 setAXNodeAndAncestors: function(nodes) |
| 24 { |
| 25 this._nodes = nodes; |
| 26 |
| 27 var target = this.node().target(); |
| 28 var treeOutline = this._treeOutline; |
| 29 treeOutline.removeChildren(); |
| 30 treeOutline.element.classList.remove("hidden"); |
| 31 var previous = treeOutline.rootElement(); |
| 32 while (nodes.length) { |
| 33 var ancestor = nodes.pop(); |
| 34 var ancestorTreeElement = new WebInspector.AXNodeTreeElement(ancesto
r, target); |
| 35 previous.appendChild(ancestorTreeElement); |
| 36 previous.expand(); |
| 37 previous = ancestorTreeElement; |
| 38 } |
| 39 previous.selectable = true; |
| 40 previous.select(true /* omitFocus */); |
| 41 }, |
| 42 |
| 43 __proto__: WebInspector.AccessibilitySubPane.prototype |
| 44 }; |
| 45 |
| 46 /** |
| 47 * @constructor |
| 48 * @extends {TreeElement} |
| 49 * @param {!AccessibilityAgent.AXNode} axNode |
| 50 * @param {!WebInspector.Target} target |
| 51 */ |
| 52 WebInspector.AXNodeTreeElement = function(axNode, target) |
| 53 { |
| 54 /** @type {!AccessibilityAgent.AXNode} */ |
| 55 this._axNode = axNode; |
| 56 |
| 57 /** @type {!WebInspector.Target} */ |
| 58 this._target = target; |
| 59 |
| 60 // Pass an empty title, the title gets made later in onattach. |
| 61 TreeElement.call(this, ""); |
| 62 |
| 63 this.selectable = false; |
| 64 }; |
| 65 |
| 66 /** @type {!Object<string, string>} */ |
| 67 WebInspector.AXNodeTreeElement.RoleStyles = { |
| 68 internalRole: "ax-internal-role", |
| 69 role: "ax-role", |
| 70 }; |
| 71 |
| 72 WebInspector.AXNodeTreeElement.prototype = { |
| 73 /** |
| 74 * @override |
| 75 */ |
| 76 onattach: function() |
| 77 { |
| 78 this._update(); |
| 79 }, |
| 80 |
| 81 _update: function() |
| 82 { |
| 83 this.listItemElement.removeChildren(); |
| 84 |
| 85 if (this._axNode.ignored) { |
| 86 this._appendIgnoredNodeElement(); |
| 87 } else { |
| 88 this._appendRoleElement(this._axNode.role); |
| 89 if ("name" in this._axNode && this._axNode.name.value) { |
| 90 this.listItemElement.createChild("span", "separator").textConten
t = "\u00A0"; |
| 91 this._appendNameElement(/** @type {string} */ (this._axNode.name
.value)); |
| 92 } |
| 93 } |
| 94 }, |
| 95 |
| 96 /** |
| 97 * @param {string} name |
| 98 */ |
| 99 _appendNameElement: function(name) |
| 100 { |
| 101 var nameElement = createElement("span"); |
| 102 nameElement.textContent = '"' + name + '"'; |
| 103 nameElement.classList.add("ax-readable-string"); |
| 104 this.listItemElement.appendChild(nameElement); |
| 105 }, |
| 106 |
| 107 /** |
| 108 * @param {!AccessibilityAgent.AXValue=} role |
| 109 */ |
| 110 _appendRoleElement: function(role) |
| 111 { |
| 112 if (!role) |
| 113 return; |
| 114 |
| 115 var roleElement = createElementWithClass("span", "monospace"); |
| 116 roleElement.classList.add(WebInspector.AXNodeTreeElement.RoleStyles[role
.type]); |
| 117 roleElement.setTextContentTruncatedIfNeeded(role.value || ""); |
| 118 |
| 119 this.listItemElement.appendChild(roleElement); |
| 120 }, |
| 121 |
| 122 _appendIgnoredNodeElement: function() |
| 123 { |
| 124 var ignoredNodeElement = createElementWithClass("span", "monospace"); |
| 125 ignoredNodeElement.textContent = WebInspector.UIString("Ignored"); |
| 126 ignoredNodeElement.classList.add("ax-tree-ignored-node"); |
| 127 this.listItemElement.appendChild(ignoredNodeElement); |
| 128 }, |
| 129 |
| 130 __proto__: TreeElement.prototype |
| 131 }; |
OLD | NEW |