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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.AXNodeSubPane = class extends WebInspector.AccessibilitySubPane { 7 Accessibility.AXNodeSubPane = class extends Accessibility.AccessibilitySubPane {
8 constructor() { 8 constructor() {
9 super(WebInspector.UIString('Computed Properties')); 9 super(Common.UIString('Computed Properties'));
10 10
11 this._noNodeInfo = this.createInfo(WebInspector.UIString('No accessibility n ode')); 11 this._noNodeInfo = this.createInfo(Common.UIString('No accessibility node')) ;
12 this._ignoredInfo = 12 this._ignoredInfo =
13 this.createInfo(WebInspector.UIString('Accessibility node not exposed'), 'ax-ignored-info hidden'); 13 this.createInfo(Common.UIString('Accessibility node not exposed'), 'ax-i gnored-info hidden');
14 14
15 this._treeOutline = this.createTreeOutline(); 15 this._treeOutline = this.createTreeOutline();
16 this._ignoredReasonsTree = this.createTreeOutline(); 16 this._ignoredReasonsTree = this.createTreeOutline();
17 17
18 this.element.classList.add('accessibility-computed'); 18 this.element.classList.add('accessibility-computed');
19 } 19 }
20 20
21 /** 21 /**
22 * @param {?WebInspector.AccessibilityNode} axNode 22 * @param {?Accessibility.AccessibilityNode} axNode
23 * @override 23 * @override
24 */ 24 */
25 setAXNode(axNode) { 25 setAXNode(axNode) {
26 if (this._axNode === axNode) 26 if (this._axNode === axNode)
27 return; 27 return;
28 this._axNode = axNode; 28 this._axNode = axNode;
29 29
30 var treeOutline = this._treeOutline; 30 var treeOutline = this._treeOutline;
31 treeOutline.removeChildren(); 31 treeOutline.removeChildren();
32 var ignoredReasons = this._ignoredReasonsTree; 32 var ignoredReasons = this._ignoredReasonsTree;
(...skipping 14 matching lines...) Expand all
47 this._noNodeInfo.classList.add('hidden'); 47 this._noNodeInfo.classList.add('hidden');
48 treeOutline.element.classList.add('hidden'); 48 treeOutline.element.classList.add('hidden');
49 this.element.classList.add('ax-ignored-node-pane'); 49 this.element.classList.add('ax-ignored-node-pane');
50 50
51 this._ignoredInfo.classList.remove('hidden'); 51 this._ignoredInfo.classList.remove('hidden');
52 ignoredReasons.element.classList.remove('hidden'); 52 ignoredReasons.element.classList.remove('hidden');
53 /** 53 /**
54 * @param {!Protocol.Accessibility.AXProperty} property 54 * @param {!Protocol.Accessibility.AXProperty} property
55 */ 55 */
56 function addIgnoredReason(property) { 56 function addIgnoredReason(property) {
57 ignoredReasons.appendChild(new WebInspector.AXNodeIgnoredReasonTreeEleme nt( 57 ignoredReasons.appendChild(new Accessibility.AXNodeIgnoredReasonTreeElem ent(
58 property, /** @type {!WebInspector.AccessibilityNode} */ (axNode))); 58 property, /** @type {!Accessibility.AccessibilityNode} */ (axNode))) ;
59 } 59 }
60 var ignoredReasonsArray = /** @type {!Array<!Protocol.Accessibility.AXProp erty>} */ (axNode.ignoredReasons()); 60 var ignoredReasonsArray = /** @type {!Array<!Protocol.Accessibility.AXProp erty>} */ (axNode.ignoredReasons());
61 for (var reason of ignoredReasonsArray) 61 for (var reason of ignoredReasonsArray)
62 addIgnoredReason(reason); 62 addIgnoredReason(reason);
63 if (!ignoredReasons.firstChild()) 63 if (!ignoredReasons.firstChild())
64 ignoredReasons.element.classList.add('hidden'); 64 ignoredReasons.element.classList.add('hidden');
65 return; 65 return;
66 } 66 }
67 this.element.classList.remove('ax-ignored-node-pane'); 67 this.element.classList.remove('ax-ignored-node-pane');
68 68
69 this._ignoredInfo.classList.add('hidden'); 69 this._ignoredInfo.classList.add('hidden');
70 ignoredReasons.element.classList.add('hidden'); 70 ignoredReasons.element.classList.add('hidden');
71 this._noNodeInfo.classList.add('hidden'); 71 this._noNodeInfo.classList.add('hidden');
72 72
73 treeOutline.element.classList.remove('hidden'); 73 treeOutline.element.classList.remove('hidden');
74 74
75 /** 75 /**
76 * @param {!Protocol.Accessibility.AXProperty} property 76 * @param {!Protocol.Accessibility.AXProperty} property
77 */ 77 */
78 function addProperty(property) { 78 function addProperty(property) {
79 treeOutline.appendChild(new WebInspector.AXNodePropertyTreePropertyElement ( 79 treeOutline.appendChild(new Accessibility.AXNodePropertyTreePropertyElemen t(
80 property, /** @type {!WebInspector.AccessibilityNode} */ (axNode))); 80 property, /** @type {!Accessibility.AccessibilityNode} */ (axNode)));
81 } 81 }
82 82
83 for (var property of axNode.coreProperties()) 83 for (var property of axNode.coreProperties())
84 addProperty(property); 84 addProperty(property);
85 85
86 var roleProperty = /** @type {!Protocol.Accessibility.AXProperty} */ ({name: 'role', value: axNode.role()}); 86 var roleProperty = /** @type {!Protocol.Accessibility.AXProperty} */ ({name: 'role', value: axNode.role()});
87 addProperty(roleProperty); 87 addProperty(roleProperty);
88 88
89 var propertyMap = {}; 89 var propertyMap = {};
90 var propertiesArray = /** @type {!Array.<!Protocol.Accessibility.AXProperty> } */ (axNode.properties()); 90 var propertiesArray = /** @type {!Array.<!Protocol.Accessibility.AXProperty> } */ (axNode.properties());
91 for (var property of propertiesArray) 91 for (var property of propertiesArray)
92 propertyMap[property.name] = property; 92 propertyMap[property.name] = property;
93 93
94 for (var propertySet 94 for (var propertySet
95 of [Protocol.Accessibility.AXWidgetAttributes, Protocol.Accessibili ty.AXWidgetStates, 95 of [Protocol.Accessibility.AXWidgetAttributes, Protocol.Accessibili ty.AXWidgetStates,
96 Protocol.Accessibility.AXGlobalStates, Protocol.Accessibility.A XLiveRegionAttributes, 96 Protocol.Accessibility.AXGlobalStates, Protocol.Accessibility.A XLiveRegionAttributes,
97 Protocol.Accessibility.AXRelationshipAttributes]) { 97 Protocol.Accessibility.AXRelationshipAttributes]) {
98 for (var propertyKey in propertySet) { 98 for (var propertyKey in propertySet) {
99 var property = propertySet[propertyKey]; 99 var property = propertySet[propertyKey];
100 if (property in propertyMap) 100 if (property in propertyMap)
101 addProperty(propertyMap[property]); 101 addProperty(propertyMap[property]);
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 /** 106 /**
107 * @override 107 * @override
108 * @param {?WebInspector.DOMNode} node 108 * @param {?SDK.DOMNode} node
109 */ 109 */
110 setNode(node) { 110 setNode(node) {
111 super.setNode(node); 111 super.setNode(node);
112 this._axNode = null; 112 this._axNode = null;
113 } 113 }
114 }; 114 };
115 115
116 /** 116 /**
117 * @unrestricted 117 * @unrestricted
118 */ 118 */
119 WebInspector.AXNodePropertyTreeElement = class extends TreeElement { 119 Accessibility.AXNodePropertyTreeElement = class extends TreeElement {
120 /** 120 /**
121 * @param {!WebInspector.AccessibilityNode} axNode 121 * @param {!Accessibility.AccessibilityNode} axNode
122 */ 122 */
123 constructor(axNode) { 123 constructor(axNode) {
124 // Pass an empty title, the title gets made later in onattach. 124 // Pass an empty title, the title gets made later in onattach.
125 super(''); 125 super('');
126 this._axNode = axNode; 126 this._axNode = axNode;
127 } 127 }
128 128
129 /** 129 /**
130 * @param {?Protocol.Accessibility.AXValueType} type 130 * @param {?Protocol.Accessibility.AXValueType} type
131 * @param {string} value 131 * @param {string} value
132 * @return {!Element} 132 * @return {!Element}
133 */ 133 */
134 static createSimpleValueElement(type, value) { 134 static createSimpleValueElement(type, value) {
135 var valueElement; 135 var valueElement;
136 var AXValueType = Protocol.Accessibility.AXValueType; 136 var AXValueType = Protocol.Accessibility.AXValueType;
137 if (!type || type === AXValueType.ValueUndefined || type === AXValueType.Com putedString) 137 if (!type || type === AXValueType.ValueUndefined || type === AXValueType.Com putedString)
138 valueElement = createElement('span'); 138 valueElement = createElement('span');
139 else 139 else
140 valueElement = createElementWithClass('span', 'monospace'); 140 valueElement = createElementWithClass('span', 'monospace');
141 var valueText; 141 var valueText;
142 var isStringProperty = type && WebInspector.AXNodePropertyTreeElement.String Properties.has(type); 142 var isStringProperty = type && Accessibility.AXNodePropertyTreeElement.Strin gProperties.has(type);
143 if (isStringProperty) { 143 if (isStringProperty) {
144 // Render \n as a nice unicode cr symbol. 144 // Render \n as a nice unicode cr symbol.
145 valueText = '"' + value.replace(/\n/g, '\u21B5') + '"'; 145 valueText = '"' + value.replace(/\n/g, '\u21B5') + '"';
146 valueElement._originalTextContent = value; 146 valueElement._originalTextContent = value;
147 } else { 147 } else {
148 valueText = String(value); 148 valueText = String(value);
149 } 149 }
150 150
151 if (type && type in WebInspector.AXNodePropertyTreeElement.TypeStyles) 151 if (type && type in Accessibility.AXNodePropertyTreeElement.TypeStyles)
152 valueElement.classList.add(WebInspector.AXNodePropertyTreeElement.TypeStyl es[type]); 152 valueElement.classList.add(Accessibility.AXNodePropertyTreeElement.TypeSty les[type]);
153 153
154 valueElement.setTextContentTruncatedIfNeeded(valueText || ''); 154 valueElement.setTextContentTruncatedIfNeeded(valueText || '');
155 155
156 valueElement.title = String(value) || ''; 156 valueElement.title = String(value) || '';
157 157
158 return valueElement; 158 return valueElement;
159 } 159 }
160 160
161 /** 161 /**
162 * @param {string} tooltip 162 * @param {string} tooltip
163 * @return {!Element} 163 * @return {!Element}
164 */ 164 */
165 static createExclamationMark(tooltip) { 165 static createExclamationMark(tooltip) {
166 var exclamationElement = createElement('label', 'dt-icon-label'); 166 var exclamationElement = createElement('label', 'dt-icon-label');
167 exclamationElement.type = 'smallicon-warning'; 167 exclamationElement.type = 'smallicon-warning';
168 exclamationElement.title = tooltip; 168 exclamationElement.title = tooltip;
169 return exclamationElement; 169 return exclamationElement;
170 } 170 }
171 171
172 /** 172 /**
173 * @param {string} name 173 * @param {string} name
174 */ 174 */
175 appendNameElement(name) { 175 appendNameElement(name) {
176 var nameElement = createElement('span'); 176 var nameElement = createElement('span');
177 var AXAttributes = WebInspector.AccessibilityStrings.AXAttributes; 177 var AXAttributes = Accessibility.AccessibilityStrings.AXAttributes;
178 if (name in AXAttributes) { 178 if (name in AXAttributes) {
179 nameElement.textContent = WebInspector.UIString(AXAttributes[name].name); 179 nameElement.textContent = Common.UIString(AXAttributes[name].name);
180 nameElement.title = AXAttributes[name].description; 180 nameElement.title = AXAttributes[name].description;
181 nameElement.classList.add('ax-readable-name'); 181 nameElement.classList.add('ax-readable-name');
182 } else { 182 } else {
183 nameElement.textContent = name; 183 nameElement.textContent = name;
184 nameElement.classList.add('ax-name'); 184 nameElement.classList.add('ax-name');
185 nameElement.classList.add('monospace'); 185 nameElement.classList.add('monospace');
186 } 186 }
187 this.listItemElement.appendChild(nameElement); 187 this.listItemElement.appendChild(nameElement);
188 } 188 }
189 189
190 /** 190 /**
191 * @param {!Protocol.Accessibility.AXValue} value 191 * @param {!Protocol.Accessibility.AXValue} value
192 * @return {?Element} 192 * @return {?Element}
193 */ 193 */
194 appendValueElement(value) { 194 appendValueElement(value) {
195 var AXValueType = Protocol.Accessibility.AXValueType; 195 var AXValueType = Protocol.Accessibility.AXValueType;
196 if (value.type === AXValueType.Idref || value.type === AXValueType.Node || v alue.type === AXValueType.IdrefList || 196 if (value.type === AXValueType.Idref || value.type === AXValueType.Node || v alue.type === AXValueType.IdrefList ||
197 value.type === AXValueType.NodeList) { 197 value.type === AXValueType.NodeList) {
198 this.appendRelatedNodeListValueElement(value); 198 this.appendRelatedNodeListValueElement(value);
199 if (!value.value) 199 if (!value.value)
200 return null; 200 return null;
201 } else if (value.sources) { 201 } else if (value.sources) {
202 var sources = value.sources; 202 var sources = value.sources;
203 for (var i = 0; i < sources.length; i++) { 203 for (var i = 0; i < sources.length; i++) {
204 var source = sources[i]; 204 var source = sources[i];
205 var child = new WebInspector.AXValueSourceTreeElement(source, this._axNo de); 205 var child = new Accessibility.AXValueSourceTreeElement(source, this._axN ode);
206 this.appendChild(child); 206 this.appendChild(child);
207 } 207 }
208 this.expand(); 208 this.expand();
209 } 209 }
210 var element = WebInspector.AXNodePropertyTreeElement.createSimpleValueElemen t(value.type, String(value.value)); 210 var element = Accessibility.AXNodePropertyTreeElement.createSimpleValueEleme nt(value.type, String(value.value));
211 this.listItemElement.appendChild(element); 211 this.listItemElement.appendChild(element);
212 return element; 212 return element;
213 } 213 }
214 214
215 /** 215 /**
216 * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode 216 * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode
217 * @param {number} index 217 * @param {number} index
218 */ 218 */
219 appendRelatedNode(relatedNode, index) { 219 appendRelatedNode(relatedNode, index) {
220 var deferredNode = new WebInspector.DeferredDOMNode(this._axNode.target(), r elatedNode.backendDOMNodeId); 220 var deferredNode = new SDK.DeferredDOMNode(this._axNode.target(), relatedNod e.backendDOMNodeId);
221 var nodeTreeElement = new WebInspector.AXRelatedNodeSourceTreeElement({defer redNode: deferredNode}, relatedNode); 221 var nodeTreeElement = new Accessibility.AXRelatedNodeSourceTreeElement({defe rredNode: deferredNode}, relatedNode);
222 this.appendChild(nodeTreeElement); 222 this.appendChild(nodeTreeElement);
223 } 223 }
224 224
225 /** 225 /**
226 * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode 226 * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode
227 */ 227 */
228 appendRelatedNodeInline(relatedNode) { 228 appendRelatedNodeInline(relatedNode) {
229 var deferredNode = new WebInspector.DeferredDOMNode(this._axNode.target(), r elatedNode.backendDOMNodeId); 229 var deferredNode = new SDK.DeferredDOMNode(this._axNode.target(), relatedNod e.backendDOMNodeId);
230 var linkedNode = new WebInspector.AXRelatedNodeElement({deferredNode: deferr edNode}, relatedNode); 230 var linkedNode = new Accessibility.AXRelatedNodeElement({deferredNode: defer redNode}, relatedNode);
231 this.listItemElement.appendChild(linkedNode.render()); 231 this.listItemElement.appendChild(linkedNode.render());
232 } 232 }
233 233
234 /** 234 /**
235 * @param {!Protocol.Accessibility.AXValue} value 235 * @param {!Protocol.Accessibility.AXValue} value
236 */ 236 */
237 appendRelatedNodeListValueElement(value) { 237 appendRelatedNodeListValueElement(value) {
238 if (value.relatedNodes.length === 1 && !value.value) { 238 if (value.relatedNodes.length === 1 && !value.value) {
239 this.appendRelatedNodeInline(value.relatedNodes[0]); 239 this.appendRelatedNodeInline(value.relatedNodes[0]);
240 return; 240 return;
241 } 241 }
242 242
243 value.relatedNodes.forEach(this.appendRelatedNode, this); 243 value.relatedNodes.forEach(this.appendRelatedNode, this);
244 if (value.relatedNodes.length <= 3) 244 if (value.relatedNodes.length <= 3)
245 this.expand(); 245 this.expand();
246 else 246 else
247 this.collapse(); 247 this.collapse();
248 } 248 }
249 }; 249 };
250 250
251 251
252 /** @type {!Object<string, string>} */ 252 /** @type {!Object<string, string>} */
253 WebInspector.AXNodePropertyTreeElement.TypeStyles = { 253 Accessibility.AXNodePropertyTreeElement.TypeStyles = {
254 attribute: 'ax-value-string', 254 attribute: 'ax-value-string',
255 boolean: 'object-value-boolean', 255 boolean: 'object-value-boolean',
256 booleanOrUndefined: 'object-value-boolean', 256 booleanOrUndefined: 'object-value-boolean',
257 computedString: 'ax-readable-string', 257 computedString: 'ax-readable-string',
258 idref: 'ax-value-string', 258 idref: 'ax-value-string',
259 idrefList: 'ax-value-string', 259 idrefList: 'ax-value-string',
260 integer: 'object-value-number', 260 integer: 'object-value-number',
261 internalRole: 'ax-internal-role', 261 internalRole: 'ax-internal-role',
262 number: 'ax-value-number', 262 number: 'ax-value-number',
263 role: 'ax-role', 263 role: 'ax-role',
264 string: 'ax-value-string', 264 string: 'ax-value-string',
265 tristate: 'object-value-boolean', 265 tristate: 'object-value-boolean',
266 valueUndefined: 'ax-value-undefined' 266 valueUndefined: 'ax-value-undefined'
267 }; 267 };
268 268
269 /** @type {!Set.<!Protocol.Accessibility.AXValueType>} */ 269 /** @type {!Set.<!Protocol.Accessibility.AXValueType>} */
270 WebInspector.AXNodePropertyTreeElement.StringProperties = new Set([ 270 Accessibility.AXNodePropertyTreeElement.StringProperties = new Set([
271 Protocol.Accessibility.AXValueType.String, Protocol.Accessibility.AXValueType. ComputedString, 271 Protocol.Accessibility.AXValueType.String, Protocol.Accessibility.AXValueType. ComputedString,
272 Protocol.Accessibility.AXValueType.IdrefList, Protocol.Accessibility.AXValueTy pe.Idref 272 Protocol.Accessibility.AXValueType.IdrefList, Protocol.Accessibility.AXValueTy pe.Idref
273 ]); 273 ]);
274 274
275 /** 275 /**
276 * @unrestricted 276 * @unrestricted
277 */ 277 */
278 WebInspector.AXNodePropertyTreePropertyElement = class extends WebInspector.AXNo dePropertyTreeElement { 278 Accessibility.AXNodePropertyTreePropertyElement = class extends Accessibility.AX NodePropertyTreeElement {
279 /** 279 /**
280 * @param {!Protocol.Accessibility.AXProperty} property 280 * @param {!Protocol.Accessibility.AXProperty} property
281 * @param {!WebInspector.AccessibilityNode} axNode 281 * @param {!Accessibility.AccessibilityNode} axNode
282 */ 282 */
283 constructor(property, axNode) { 283 constructor(property, axNode) {
284 super(axNode); 284 super(axNode);
285 285
286 this._property = property; 286 this._property = property;
287 this.toggleOnClick = true; 287 this.toggleOnClick = true;
288 this.selectable = false; 288 this.selectable = false;
289 289
290 this.listItemElement.classList.add('property'); 290 this.listItemElement.classList.add('property');
291 } 291 }
(...skipping 14 matching lines...) Expand all
306 306
307 var valueElement = this.appendValueElement(this._property.value); 307 var valueElement = this.appendValueElement(this._property.value);
308 if (this._property.name === 'name') 308 if (this._property.name === 'name')
309 valueElement.classList.add('ax-computed-text'); 309 valueElement.classList.add('ax-computed-text');
310 } 310 }
311 }; 311 };
312 312
313 /** 313 /**
314 * @unrestricted 314 * @unrestricted
315 */ 315 */
316 WebInspector.AXValueSourceTreeElement = class extends WebInspector.AXNodePropert yTreeElement { 316 Accessibility.AXValueSourceTreeElement = class extends Accessibility.AXNodePrope rtyTreeElement {
317 /** 317 /**
318 * @param {!Protocol.Accessibility.AXValueSource} source 318 * @param {!Protocol.Accessibility.AXValueSource} source
319 * @param {!WebInspector.AccessibilityNode} axNode 319 * @param {!Accessibility.AccessibilityNode} axNode
320 */ 320 */
321 constructor(source, axNode) { 321 constructor(source, axNode) {
322 super(axNode); 322 super(axNode);
323 this._source = source; 323 this._source = source;
324 this.selectable = false; 324 this.selectable = false;
325 } 325 }
326 326
327 /** 327 /**
328 * @override 328 * @override
329 */ 329 */
330 onattach() { 330 onattach() {
331 this._update(); 331 this._update();
332 } 332 }
333 333
334 /** 334 /**
335 * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode 335 * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode
336 * @param {number} index 336 * @param {number} index
337 * @param {string} idref 337 * @param {string} idref
338 */ 338 */
339 appendRelatedNodeWithIdref(relatedNode, index, idref) { 339 appendRelatedNodeWithIdref(relatedNode, index, idref) {
340 var deferredNode = new WebInspector.DeferredDOMNode(this._axNode.target(), r elatedNode.backendDOMNodeId); 340 var deferredNode = new SDK.DeferredDOMNode(this._axNode.target(), relatedNod e.backendDOMNodeId);
341 var nodeTreeElement = 341 var nodeTreeElement =
342 new WebInspector.AXRelatedNodeSourceTreeElement({deferredNode: deferredN ode, idref: idref}, relatedNode); 342 new Accessibility.AXRelatedNodeSourceTreeElement({deferredNode: deferred Node, idref: idref}, relatedNode);
343 this.appendChild(nodeTreeElement); 343 this.appendChild(nodeTreeElement);
344 } 344 }
345 345
346 /** 346 /**
347 * @param {!Protocol.Accessibility.AXValue} value 347 * @param {!Protocol.Accessibility.AXValue} value
348 */ 348 */
349 appendIDRefValueElement(value) { 349 appendIDRefValueElement(value) {
350 var relatedNodes = value.relatedNodes; 350 var relatedNodes = value.relatedNodes;
351 var numNodes = relatedNodes.length; 351 var numNodes = relatedNodes.length;
352 var valueElement; 352 var valueElement;
353 353
354 var idrefs = value.value.trim().split(/\s+/); 354 var idrefs = value.value.trim().split(/\s+/);
355 if (idrefs.length === 1) { 355 if (idrefs.length === 1) {
356 var idref = idrefs[0]; 356 var idref = idrefs[0];
357 var matchingNode = relatedNodes.find(node => node.idref === idref); 357 var matchingNode = relatedNodes.find(node => node.idref === idref);
358 if (matchingNode) { 358 if (matchingNode) {
359 this.appendRelatedNodeWithIdref(matchingNode, 0, idref); 359 this.appendRelatedNodeWithIdref(matchingNode, 0, idref);
360 } else { 360 } else {
361 this.listItemElement.appendChild(new WebInspector.AXRelatedNodeElement({ idref: idref}).render()); 361 this.listItemElement.appendChild(new Accessibility.AXRelatedNodeElement( {idref: idref}).render());
362 } 362 }
363 } else { 363 } else {
364 // TODO(aboxhall): exclamation mark if not idreflist type 364 // TODO(aboxhall): exclamation mark if not idreflist type
365 for (var i = 0; i < idrefs.length; ++i) { 365 for (var i = 0; i < idrefs.length; ++i) {
366 var idref = idrefs[i]; 366 var idref = idrefs[i];
367 var matchingNode = relatedNodes.find(node => node.idref === idref); 367 var matchingNode = relatedNodes.find(node => node.idref === idref);
368 if (matchingNode) { 368 if (matchingNode) {
369 this.appendRelatedNodeWithIdref(matchingNode, i, idref); 369 this.appendRelatedNodeWithIdref(matchingNode, i, idref);
370 } else { 370 } else {
371 this.appendChild(new WebInspector.AXRelatedNodeSourceTreeElement({idre f: idref})); 371 this.appendChild(new Accessibility.AXRelatedNodeSourceTreeElement({idr ef: idref}));
372 } 372 }
373 } 373 }
374 } 374 }
375 } 375 }
376 376
377 /** 377 /**
378 * @param {!Protocol.Accessibility.AXValue} value 378 * @param {!Protocol.Accessibility.AXValue} value
379 * @override 379 * @override
380 */ 380 */
381 appendRelatedNodeListValueElement(value) { 381 appendRelatedNodeListValueElement(value) {
(...skipping 19 matching lines...) Expand all
401 appendSourceNameElement(source) { 401 appendSourceNameElement(source) {
402 var nameElement = createElement('span'); 402 var nameElement = createElement('span');
403 var AXValueSourceType = Protocol.Accessibility.AXValueSourceType; 403 var AXValueSourceType = Protocol.Accessibility.AXValueSourceType;
404 var type = source.type; 404 var type = source.type;
405 var name; 405 var name;
406 switch (type) { 406 switch (type) {
407 case AXValueSourceType.Attribute: 407 case AXValueSourceType.Attribute:
408 case AXValueSourceType.Placeholder: 408 case AXValueSourceType.Placeholder:
409 case AXValueSourceType.RelatedElement: 409 case AXValueSourceType.RelatedElement:
410 if (source.nativeSource) { 410 if (source.nativeSource) {
411 var AXNativeSourceTypes = WebInspector.AccessibilityStrings.AXNativeSo urceTypes; 411 var AXNativeSourceTypes = Accessibility.AccessibilityStrings.AXNativeS ourceTypes;
412 var nativeSource = source.nativeSource; 412 var nativeSource = source.nativeSource;
413 nameElement.textContent = WebInspector.UIString(AXNativeSourceTypes[na tiveSource].name); 413 nameElement.textContent = Common.UIString(AXNativeSourceTypes[nativeSo urce].name);
414 nameElement.title = WebInspector.UIString(AXNativeSourceTypes[nativeSo urce].description); 414 nameElement.title = Common.UIString(AXNativeSourceTypes[nativeSource]. description);
415 nameElement.classList.add('ax-readable-name'); 415 nameElement.classList.add('ax-readable-name');
416 break; 416 break;
417 } 417 }
418 nameElement.textContent = source.attribute; 418 nameElement.textContent = source.attribute;
419 nameElement.classList.add('ax-name'); 419 nameElement.classList.add('ax-name');
420 nameElement.classList.add('monospace'); 420 nameElement.classList.add('monospace');
421 break; 421 break;
422 default: 422 default:
423 var AXSourceTypes = WebInspector.AccessibilityStrings.AXSourceTypes; 423 var AXSourceTypes = Accessibility.AccessibilityStrings.AXSourceTypes;
424 if (type in AXSourceTypes) { 424 if (type in AXSourceTypes) {
425 nameElement.textContent = WebInspector.UIString(AXSourceTypes[type].na me); 425 nameElement.textContent = Common.UIString(AXSourceTypes[type].name);
426 nameElement.title = WebInspector.UIString(AXSourceTypes[type].descript ion); 426 nameElement.title = Common.UIString(AXSourceTypes[type].description);
427 nameElement.classList.add('ax-readable-name'); 427 nameElement.classList.add('ax-readable-name');
428 } else { 428 } else {
429 console.warn(type, 'not in AXSourceTypes'); 429 console.warn(type, 'not in AXSourceTypes');
430 nameElement.textContent = WebInspector.UIString(type); 430 nameElement.textContent = Common.UIString(type);
431 } 431 }
432 } 432 }
433 this.listItemElement.appendChild(nameElement); 433 this.listItemElement.appendChild(nameElement);
434 } 434 }
435 435
436 _update() { 436 _update() {
437 this.listItemElement.removeChildren(); 437 this.listItemElement.removeChildren();
438 438
439 if (this._source.invalid) { 439 if (this._source.invalid) {
440 var exclamationMark = 440 var exclamationMark =
441 WebInspector.AXNodePropertyTreeElement.createExclamationMark(WebInspec tor.UIString('Invalid source.')); 441 Accessibility.AXNodePropertyTreeElement.createExclamationMark(Common.U IString('Invalid source.'));
442 this.listItemElement.appendChild(exclamationMark); 442 this.listItemElement.appendChild(exclamationMark);
443 this.listItemElement.classList.add('ax-value-source-invalid'); 443 this.listItemElement.classList.add('ax-value-source-invalid');
444 } else if (this._source.superseded) { 444 } else if (this._source.superseded) {
445 this.listItemElement.classList.add('ax-value-source-unused'); 445 this.listItemElement.classList.add('ax-value-source-unused');
446 } 446 }
447 447
448 this.appendSourceNameElement(this._source); 448 this.appendSourceNameElement(this._source);
449 449
450 this.listItemElement.createChild('span', 'separator').textContent = ':\u00a0 '; 450 this.listItemElement.createChild('span', 'separator').textContent = ':\u00a0 ';
451 451
452 if (this._source.attributeValue) { 452 if (this._source.attributeValue) {
453 this.appendValueElement(this._source.attributeValue); 453 this.appendValueElement(this._source.attributeValue);
454 this.listItemElement.createTextChild('\u00a0'); 454 this.listItemElement.createTextChild('\u00a0');
455 } else if (this._source.nativeSourceValue) { 455 } else if (this._source.nativeSourceValue) {
456 this.appendValueElement(this._source.nativeSourceValue); 456 this.appendValueElement(this._source.nativeSourceValue);
457 this.listItemElement.createTextChild('\u00a0'); 457 this.listItemElement.createTextChild('\u00a0');
458 } else if (this._source.value) { 458 } else if (this._source.value) {
459 this.appendValueElement(this._source.value); 459 this.appendValueElement(this._source.value);
460 } else { 460 } else {
461 var valueElement = WebInspector.AXNodePropertyTreeElement.createSimpleValu eElement( 461 var valueElement = Accessibility.AXNodePropertyTreeElement.createSimpleVal ueElement(
462 Protocol.Accessibility.AXValueType.ValueUndefined, WebInspector.UIStri ng('Not specified')); 462 Protocol.Accessibility.AXValueType.ValueUndefined, Common.UIString('No t specified'));
463 this.listItemElement.appendChild(valueElement); 463 this.listItemElement.appendChild(valueElement);
464 this.listItemElement.classList.add('ax-value-source-unused'); 464 this.listItemElement.classList.add('ax-value-source-unused');
465 } 465 }
466 466
467 if (this._source.value && this._source.superseded) 467 if (this._source.value && this._source.superseded)
468 this.listItemElement.classList.add('ax-value-source-superseded'); 468 this.listItemElement.classList.add('ax-value-source-superseded');
469 } 469 }
470 470
471 /** 471 /**
472 * @param {!Protocol.Accessibility.AXValue} value 472 * @param {!Protocol.Accessibility.AXValue} value
473 * @return {!Element} 473 * @return {!Element}
474 * @override 474 * @override
475 */ 475 */
476 appendValueElement(value) { 476 appendValueElement(value) {
477 var element = super.appendValueElement(value); 477 var element = super.appendValueElement(value);
478 if (!element) { 478 if (!element) {
479 element = WebInspector.AXNodePropertyTreeElement.createSimpleValueElement( value.type, String(value.value)); 479 element = Accessibility.AXNodePropertyTreeElement.createSimpleValueElement (value.type, String(value.value));
480 this.listItemElement.appendChild(element); 480 this.listItemElement.appendChild(element);
481 } 481 }
482 return element; 482 return element;
483 } 483 }
484 }; 484 };
485 485
486 /** 486 /**
487 * @unrestricted 487 * @unrestricted
488 */ 488 */
489 WebInspector.AXRelatedNodeSourceTreeElement = class extends TreeElement { 489 Accessibility.AXRelatedNodeSourceTreeElement = class extends TreeElement {
490 /** 490 /**
491 * @param {{deferredNode: (!WebInspector.DeferredDOMNode|undefined), idref: (s tring|undefined)}} node 491 * @param {{deferredNode: (!SDK.DeferredDOMNode|undefined), idref: (string|und efined)}} node
492 * @param {!Protocol.Accessibility.AXRelatedNode=} value 492 * @param {!Protocol.Accessibility.AXRelatedNode=} value
493 */ 493 */
494 constructor(node, value) { 494 constructor(node, value) {
495 super(''); 495 super('');
496 496
497 this._value = value; 497 this._value = value;
498 this._axRelatedNodeElement = new WebInspector.AXRelatedNodeElement(node, val ue); 498 this._axRelatedNodeElement = new Accessibility.AXRelatedNodeElement(node, va lue);
499 this.selectable = false; 499 this.selectable = false;
500 } 500 }
501 501
502 /** 502 /**
503 * @override 503 * @override
504 */ 504 */
505 onattach() { 505 onattach() {
506 this.listItemElement.appendChild(this._axRelatedNodeElement.render()); 506 this.listItemElement.appendChild(this._axRelatedNodeElement.render());
507 if (!this._value) 507 if (!this._value)
508 return; 508 return;
509 509
510 if (this._value.text) 510 if (this._value.text)
511 this.listItemElement.appendChild(WebInspector.AXNodePropertyTreeElement.cr eateSimpleValueElement( 511 this.listItemElement.appendChild(Accessibility.AXNodePropertyTreeElement.c reateSimpleValueElement(
512 Protocol.Accessibility.AXValueType.ComputedString, this._value.text)); 512 Protocol.Accessibility.AXValueType.ComputedString, this._value.text));
513 } 513 }
514 }; 514 };
515 515
516 /** 516 /**
517 * @unrestricted 517 * @unrestricted
518 */ 518 */
519 WebInspector.AXRelatedNodeElement = class { 519 Accessibility.AXRelatedNodeElement = class {
520 /** 520 /**
521 * @param {{deferredNode: (!WebInspector.DeferredDOMNode|undefined), idref: (s tring|undefined)}} node 521 * @param {{deferredNode: (!SDK.DeferredDOMNode|undefined), idref: (string|und efined)}} node
522 * @param {!Protocol.Accessibility.AXRelatedNode=} value 522 * @param {!Protocol.Accessibility.AXRelatedNode=} value
523 */ 523 */
524 constructor(node, value) { 524 constructor(node, value) {
525 this._deferredNode = node.deferredNode; 525 this._deferredNode = node.deferredNode;
526 this._idref = node.idref; 526 this._idref = node.idref;
527 this._value = value; 527 this._value = value;
528 } 528 }
529 529
530 /** 530 /**
531 * @return {!Element} 531 * @return {!Element}
532 */ 532 */
533 render() { 533 render() {
534 var element = createElement('span'); 534 var element = createElement('span');
535 var valueElement; 535 var valueElement;
536 536
537 /** 537 /**
538 * @param {?WebInspector.DOMNode} node 538 * @param {?SDK.DOMNode} node
539 * @this {!WebInspector.AXRelatedNodeElement} 539 * @this {!Accessibility.AXRelatedNodeElement}
540 */ 540 */
541 function onNodeResolved(node) { 541 function onNodeResolved(node) {
542 valueElement.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeRefe rence(node, this._idref)); 542 valueElement.appendChild(Components.DOMPresentationUtils.linkifyNodeRefere nce(node, this._idref));
543 } 543 }
544 544
545 if (this._deferredNode) { 545 if (this._deferredNode) {
546 valueElement = createElement('span'); 546 valueElement = createElement('span');
547 element.appendChild(valueElement); 547 element.appendChild(valueElement);
548 this._deferredNode.resolve(onNodeResolved.bind(this)); 548 this._deferredNode.resolve(onNodeResolved.bind(this));
549 } else if (this._idref) { 549 } else if (this._idref) {
550 element.classList.add('invalid'); 550 element.classList.add('invalid');
551 valueElement = 551 valueElement =
552 WebInspector.AXNodePropertyTreeElement.createExclamationMark(WebInspec tor.UIString('No node with this ID.')); 552 Accessibility.AXNodePropertyTreeElement.createExclamationMark(Common.U IString('No node with this ID.'));
553 valueElement.createTextChild(this._idref); 553 valueElement.createTextChild(this._idref);
554 element.appendChild(valueElement); 554 element.appendChild(valueElement);
555 } 555 }
556 556
557 return element; 557 return element;
558 } 558 }
559 }; 559 };
560 560
561 /** 561 /**
562 * @unrestricted 562 * @unrestricted
563 */ 563 */
564 WebInspector.AXNodeIgnoredReasonTreeElement = class extends WebInspector.AXNodeP ropertyTreeElement { 564 Accessibility.AXNodeIgnoredReasonTreeElement = class extends Accessibility.AXNod ePropertyTreeElement {
565 /** 565 /**
566 * @param {!Protocol.Accessibility.AXProperty} property 566 * @param {!Protocol.Accessibility.AXProperty} property
567 * @param {!WebInspector.AccessibilityNode} axNode 567 * @param {!Accessibility.AccessibilityNode} axNode
568 */ 568 */
569 constructor(property, axNode) { 569 constructor(property, axNode) {
570 super(axNode); 570 super(axNode);
571 this._property = property; 571 this._property = property;
572 this._axNode = axNode; 572 this._axNode = axNode;
573 this.toggleOnClick = true; 573 this.toggleOnClick = true;
574 this.selectable = false; 574 this.selectable = false;
575 } 575 }
576 576
577 /** 577 /**
578 * @param {?string} reason 578 * @param {?string} reason
579 * @param {?WebInspector.AccessibilityNode} axNode 579 * @param {?Accessibility.AccessibilityNode} axNode
580 * @return {?Element} 580 * @return {?Element}
581 */ 581 */
582 static createReasonElement(reason, axNode) { 582 static createReasonElement(reason, axNode) {
583 var reasonElement = null; 583 var reasonElement = null;
584 switch (reason) { 584 switch (reason) {
585 case 'activeModalDialog': 585 case 'activeModalDialog':
586 reasonElement = WebInspector.formatLocalized('Element is hidden by activ e modal dialog:\u00a0', []); 586 reasonElement = UI.formatLocalized('Element is hidden by active modal di alog:\u00a0', []);
587 break; 587 break;
588 case 'ancestorDisallowsChild': 588 case 'ancestorDisallowsChild':
589 reasonElement = WebInspector.formatLocalized('Element is not permitted a s child of ', []); 589 reasonElement = UI.formatLocalized('Element is not permitted as child of ', []);
590 break; 590 break;
591 // http://www.w3.org/TR/wai-aria/roles#childrenArePresentational 591 // http://www.w3.org/TR/wai-aria/roles#childrenArePresentational
592 case 'ancestorIsLeafNode': 592 case 'ancestorIsLeafNode':
593 reasonElement = WebInspector.formatLocalized('Ancestor\'s children are a ll presentational:\u00a0', []); 593 reasonElement = UI.formatLocalized('Ancestor\'s children are all present ational:\u00a0', []);
594 break; 594 break;
595 case 'ariaHidden': 595 case 'ariaHidden':
596 var ariaHiddenSpan = createElement('span', 'source-code').textContent = 'aria-hidden'; 596 var ariaHiddenSpan = createElement('span', 'source-code').textContent = 'aria-hidden';
597 reasonElement = WebInspector.formatLocalized('Element is %s.', [ariaHidd enSpan]); 597 reasonElement = UI.formatLocalized('Element is %s.', [ariaHiddenSpan]);
598 break; 598 break;
599 case 'ariaHiddenRoot': 599 case 'ariaHiddenRoot':
600 var ariaHiddenSpan = createElement('span', 'source-code').textContent = 'aria-hidden'; 600 var ariaHiddenSpan = createElement('span', 'source-code').textContent = 'aria-hidden';
601 var trueSpan = createElement('span', 'source-code').textContent = 'true' ; 601 var trueSpan = createElement('span', 'source-code').textContent = 'true' ;
602 reasonElement = WebInspector.formatLocalized('%s is %s on ancestor:\u00a 0', [ariaHiddenSpan, trueSpan]); 602 reasonElement = UI.formatLocalized('%s is %s on ancestor:\u00a0', [ariaH iddenSpan, trueSpan]);
603 break; 603 break;
604 case 'emptyAlt': 604 case 'emptyAlt':
605 reasonElement = WebInspector.formatLocalized('Element has empty alt text .', []); 605 reasonElement = UI.formatLocalized('Element has empty alt text.', []);
606 break; 606 break;
607 case 'emptyText': 607 case 'emptyText':
608 reasonElement = WebInspector.formatLocalized('No text content.', []); 608 reasonElement = UI.formatLocalized('No text content.', []);
609 break; 609 break;
610 case 'inert': 610 case 'inert':
611 reasonElement = WebInspector.formatLocalized('Element is inert.', []); 611 reasonElement = UI.formatLocalized('Element is inert.', []);
612 break; 612 break;
613 case 'inheritsPresentation': 613 case 'inheritsPresentation':
614 reasonElement = WebInspector.formatLocalized('Element inherits presentat ional role from\u00a0', []); 614 reasonElement = UI.formatLocalized('Element inherits presentational role from\u00a0', []);
615 break; 615 break;
616 case 'labelContainer': 616 case 'labelContainer':
617 reasonElement = WebInspector.formatLocalized('Part of label element:\u00 a0', []); 617 reasonElement = UI.formatLocalized('Part of label element:\u00a0', []);
618 break; 618 break;
619 case 'labelFor': 619 case 'labelFor':
620 reasonElement = WebInspector.formatLocalized('Label for\u00a0', []); 620 reasonElement = UI.formatLocalized('Label for\u00a0', []);
621 break; 621 break;
622 case 'notRendered': 622 case 'notRendered':
623 reasonElement = WebInspector.formatLocalized('Element is not rendered.', []); 623 reasonElement = UI.formatLocalized('Element is not rendered.', []);
624 break; 624 break;
625 case 'notVisible': 625 case 'notVisible':
626 reasonElement = WebInspector.formatLocalized('Element is not visible.', []); 626 reasonElement = UI.formatLocalized('Element is not visible.', []);
627 break; 627 break;
628 case 'presentationalRole': 628 case 'presentationalRole':
629 var rolePresentationSpan = createElement('span', 'source-code').textCont ent = 'role=' + axNode.role().value; 629 var rolePresentationSpan = createElement('span', 'source-code').textCont ent = 'role=' + axNode.role().value;
630 reasonElement = WebInspector.formatLocalized('Element has %s.', [rolePre sentationSpan]); 630 reasonElement = UI.formatLocalized('Element has %s.', [rolePresentationS pan]);
631 break; 631 break;
632 case 'probablyPresentational': 632 case 'probablyPresentational':
633 reasonElement = WebInspector.formatLocalized('Element is presentational. ', []); 633 reasonElement = UI.formatLocalized('Element is presentational.', []);
634 break; 634 break;
635 case 'staticTextUsedAsNameFor': 635 case 'staticTextUsedAsNameFor':
636 reasonElement = WebInspector.formatLocalized('Static text node is used a s name for\u00a0', []); 636 reasonElement = UI.formatLocalized('Static text node is used as name for \u00a0', []);
637 break; 637 break;
638 case 'uninteresting': 638 case 'uninteresting':
639 reasonElement = WebInspector.formatLocalized('Element not interesting fo r accessibility.', []); 639 reasonElement = UI.formatLocalized('Element not interesting for accessib ility.', []);
640 break; 640 break;
641 } 641 }
642 if (reasonElement) 642 if (reasonElement)
643 reasonElement.classList.add('ax-reason'); 643 reasonElement.classList.add('ax-reason');
644 return reasonElement; 644 return reasonElement;
645 } 645 }
646 646
647 /** 647 /**
648 * @override 648 * @override
649 */ 649 */
650 onattach() { 650 onattach() {
651 this.listItemElement.removeChildren(); 651 this.listItemElement.removeChildren();
652 652
653 this._reasonElement = 653 this._reasonElement =
654 WebInspector.AXNodeIgnoredReasonTreeElement.createReasonElement(this._pr operty.name, this._axNode); 654 Accessibility.AXNodeIgnoredReasonTreeElement.createReasonElement(this._p roperty.name, this._axNode);
655 this.listItemElement.appendChild(this._reasonElement); 655 this.listItemElement.appendChild(this._reasonElement);
656 656
657 var value = this._property.value; 657 var value = this._property.value;
658 if (value.type === Protocol.Accessibility.AXValueType.Idref) 658 if (value.type === Protocol.Accessibility.AXValueType.Idref)
659 this.appendRelatedNodeListValueElement(value); 659 this.appendRelatedNodeListValueElement(value);
660 } 660 }
661 }; 661 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698