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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/accessibility/AXTreePane.js

Issue 2436703003: DevTools: Flesh out AccessibilityModel and use SDK objects instead of protocol objects (Closed)
Patch Set: revert accessibilityNode.css Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 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 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.AccessibilitySubPane} 7 * @extends {WebInspector.AccessibilitySubPane}
8 */ 8 */
9 WebInspector.AXTreePane = function() 9 WebInspector.AXTreePane = function()
10 { 10 {
11 WebInspector.AccessibilitySubPane.call(this, WebInspector.UIString("Accessib ility Tree")); 11 WebInspector.AccessibilitySubPane.call(this, WebInspector.UIString("Accessib ility Tree"));
12 12
13 this._treeOutline = this.createTreeOutline(); 13 this._treeOutline = this.createTreeOutline();
14 14
15 this.element.classList.add("accessibility-computed"); 15 this.element.classList.add("accessibility-computed");
16 }; 16 };
17 17
18 18
19 WebInspector.AXTreePane.prototype = { 19 WebInspector.AXTreePane.prototype = {
20 /** 20 /**
21 * @param {!Array<!AccessibilityAgent.AXNode>} nodes 21 * @param {!Array<!WebInspector.AccessibilityNode>} nodes
22 */ 22 */
23 setAXNodeAndAncestors: function(nodes) 23 setAXNodeAndAncestors: function(nodes)
24 { 24 {
25 this._nodes = nodes; 25 this._nodes = nodes;
26 26
27 var target = this.node().target(); 27 var target = this.node().target();
28 var treeOutline = this._treeOutline; 28 var treeOutline = this._treeOutline;
29 treeOutline.removeChildren(); 29 treeOutline.removeChildren();
30 treeOutline.element.classList.remove("hidden"); 30 treeOutline.element.classList.remove("hidden");
31 var previous = treeOutline.rootElement(); 31 var previous = treeOutline.rootElement();
32 while (nodes.length) { 32 while (nodes.length) {
33 var ancestor = nodes.pop(); 33 var ancestor = nodes.pop();
34 var ancestorTreeElement = new WebInspector.AXNodeTreeElement(ancesto r, target); 34 var ancestorTreeElement = new WebInspector.AXNodeTreeElement(ancesto r, target);
35 previous.appendChild(ancestorTreeElement); 35 previous.appendChild(ancestorTreeElement);
36 previous.expand(); 36 previous.expand();
37 previous = ancestorTreeElement; 37 previous = ancestorTreeElement;
38 } 38 }
39 previous.selectable = true; 39 previous.selectable = true;
40 previous.select(true /* omitFocus */); 40 previous.select(true /* omitFocus */);
41 }, 41 },
42 42
43 __proto__: WebInspector.AccessibilitySubPane.prototype 43 __proto__: WebInspector.AccessibilitySubPane.prototype
44 }; 44 };
45 45
46 /** 46 /**
47 * @constructor 47 * @constructor
48 * @extends {TreeElement} 48 * @extends {TreeElement}
49 * @param {!AccessibilityAgent.AXNode} axNode 49 * @param {!WebInspector.AccessibilityNode} axNode
50 * @param {!WebInspector.Target} target 50 * @param {!WebInspector.Target} target
51 */ 51 */
52 WebInspector.AXNodeTreeElement = function(axNode, target) 52 WebInspector.AXNodeTreeElement = function(axNode, target)
53 { 53 {
54 /** @type {!AccessibilityAgent.AXNode} */ 54 /** @type {!WebInspector.AccessibilityNode} */
55 this._axNode = axNode; 55 this._axNode = axNode;
56 56
57 /** @type {!WebInspector.Target} */ 57 /** @type {!WebInspector.Target} */
58 this._target = target; 58 this._target = target;
59 59
60 // Pass an empty title, the title gets made later in onattach. 60 // Pass an empty title, the title gets made later in onattach.
61 TreeElement.call(this, ""); 61 TreeElement.call(this, "");
62 62
63 this.selectable = false; 63 this.selectable = false;
64 }; 64 };
(...skipping 10 matching lines...) Expand all
75 */ 75 */
76 onattach: function() 76 onattach: function()
77 { 77 {
78 this._update(); 78 this._update();
79 }, 79 },
80 80
81 _update: function() 81 _update: function()
82 { 82 {
83 this.listItemElement.removeChildren(); 83 this.listItemElement.removeChildren();
84 84
85 if (this._axNode.ignored) { 85 if (this._axNode.ignored()) {
86 this._appendIgnoredNodeElement(); 86 this._appendIgnoredNodeElement();
87 } else { 87 } else {
88 this._appendRoleElement(this._axNode.role); 88 this._appendRoleElement(this._axNode.role());
89 if ("name" in this._axNode && this._axNode.name.value) { 89 if ("name" in this._axNode && this._axNode.name().value) {
90 this.listItemElement.createChild("span", "separator").textConten t = "\u00A0"; 90 this.listItemElement.createChild("span", "separator").textConten t = "\u00A0";
91 this._appendNameElement(/** @type {string} */ (this._axNode.name .value)); 91 this._appendNameElement(/** @type {string} */ (this._axNode.name ().value));
92 } 92 }
93 } 93 }
94 }, 94 },
95 95
96 /** 96 /**
97 * @param {string} name 97 * @param {string} name
98 */ 98 */
99 _appendNameElement: function(name) 99 _appendNameElement: function(name)
100 { 100 {
101 var nameElement = createElement("span"); 101 var nameElement = createElement("span");
102 nameElement.textContent = '"' + name + '"'; 102 nameElement.textContent = '"' + name + '"';
103 nameElement.classList.add("ax-readable-string"); 103 nameElement.classList.add("ax-readable-string");
104 this.listItemElement.appendChild(nameElement); 104 this.listItemElement.appendChild(nameElement);
105 }, 105 },
106 106
107 /** 107 /**
108 * @param {!AccessibilityAgent.AXValue=} role 108 * @param {?AccessibilityAgent.AXValue} role
109 */ 109 */
110 _appendRoleElement: function(role) 110 _appendRoleElement: function(role)
111 { 111 {
112 if (!role) 112 if (!role)
113 return; 113 return;
114 114
115 var roleElement = createElementWithClass("span", "monospace"); 115 var roleElement = createElementWithClass("span", "monospace");
116 roleElement.classList.add(WebInspector.AXNodeTreeElement.RoleStyles[role .type]); 116 roleElement.classList.add(WebInspector.AXNodeTreeElement.RoleStyles[role .type]);
117 roleElement.setTextContentTruncatedIfNeeded(role.value || ""); 117 roleElement.setTextContentTruncatedIfNeeded(role.value || "");
118 118
119 this.listItemElement.appendChild(roleElement); 119 this.listItemElement.appendChild(roleElement);
120 }, 120 },
121 121
122 _appendIgnoredNodeElement: function() 122 _appendIgnoredNodeElement: function()
123 { 123 {
124 var ignoredNodeElement = createElementWithClass("span", "monospace"); 124 var ignoredNodeElement = createElementWithClass("span", "monospace");
125 ignoredNodeElement.textContent = WebInspector.UIString("Ignored"); 125 ignoredNodeElement.textContent = WebInspector.UIString("Ignored");
126 ignoredNodeElement.classList.add("ax-tree-ignored-node"); 126 ignoredNodeElement.classList.add("ax-tree-ignored-node");
127 this.listItemElement.appendChild(ignoredNodeElement); 127 this.listItemElement.appendChild(ignoredNodeElement);
128 }, 128 },
129 129
130 __proto__: TreeElement.prototype 130 __proto__: TreeElement.prototype
131 }; 131 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698