| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 Accessibility.AccessibilityNode = class extends SDK.SDKObject { | 7 Accessibility.AccessibilityNode = class extends SDK.SDKObject { |
| 8 /** | 8 /** |
| 9 * @param {!Accessibility.AccessibilityModel} accessibilityModel | 9 * @param {!Accessibility.AccessibilityModel} accessibilityModel |
| 10 * @param {!Protocol.Accessibility.AXNode} payload | 10 * @param {!Protocol.Accessibility.AXNode} payload |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return this._backendDOMNodeId; | 132 return this._backendDOMNodeId; |
| 133 } | 133 } |
| 134 | 134 |
| 135 /** | 135 /** |
| 136 * @return {?SDK.DeferredDOMNode} | 136 * @return {?SDK.DeferredDOMNode} |
| 137 */ | 137 */ |
| 138 deferredDOMNode() { | 138 deferredDOMNode() { |
| 139 return this._deferredDOMNode; | 139 return this._deferredDOMNode; |
| 140 } | 140 } |
| 141 | 141 |
| 142 highlightDOMNode() { | |
| 143 if (!this.isDOMNode()) | |
| 144 return; | |
| 145 this.deferredDOMNode().resolvePromise().then(node => { | |
| 146 SDK.DOMModel.fromTarget(this.target()).nodeHighlightRequested(node.id); | |
| 147 }); | |
| 148 } | |
| 149 | |
| 150 /** | 142 /** |
| 151 * @return {!Array<!Accessibility.AccessibilityNode>} | 143 * @return {!Array<!Accessibility.AccessibilityNode>} |
| 152 */ | 144 */ |
| 153 children() { | 145 children() { |
| 154 var children = []; | 146 var children = []; |
| 155 if (!this._childIds) | 147 if (!this._childIds) |
| 156 return children; | 148 return children; |
| 157 | 149 |
| 158 for (var childId of this._childIds) { | 150 for (var childId of this._childIds) { |
| 159 var child = this._accessibilityModel.axNodeForId(childId); | 151 var child = this._accessibilityModel.axNodeForId(childId); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 */ | 208 */ |
| 217 constructor(target) { | 209 constructor(target) { |
| 218 super(target); | 210 super(target); |
| 219 this._agent = target.accessibilityAgent(); | 211 this._agent = target.accessibilityAgent(); |
| 220 | 212 |
| 221 /** @type {!Map<string, !Accessibility.AccessibilityNode>} */ | 213 /** @type {!Map<string, !Accessibility.AccessibilityNode>} */ |
| 222 this._axIdToAXNode = new Map(); | 214 this._axIdToAXNode = new Map(); |
| 223 this._backendDOMNodeIdToAXNode = new Map(); | 215 this._backendDOMNodeIdToAXNode = new Map(); |
| 224 } | 216 } |
| 225 | 217 |
| 226 /** | |
| 227 * @param {!SDK.Target} target | |
| 228 * @return {?Accessibility.AccessibilityModel} | |
| 229 */ | |
| 230 static fromTarget(target) { | |
| 231 return target.model(Accessibility.AccessibilityModel); | |
| 232 } | |
| 233 | |
| 234 clear() { | 218 clear() { |
| 235 this._axIdToAXNode.clear(); | 219 this._axIdToAXNode.clear(); |
| 236 } | 220 } |
| 237 | 221 |
| 238 /** | 222 /** |
| 239 * @param {!SDK.DOMNode} node | 223 * @param {!SDK.DOMNode} node |
| 240 * @return {!Promise} | 224 * @return {!Promise} |
| 241 */ | 225 */ |
| 242 requestPartialAXTree(node) { | 226 requestPartialAXTree(node) { |
| 243 /** | 227 /** |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 */ | 289 */ |
| 306 logTree(inspectedNode) { | 290 logTree(inspectedNode) { |
| 307 var rootNode = inspectedNode; | 291 var rootNode = inspectedNode; |
| 308 while (rootNode.parentNode()) | 292 while (rootNode.parentNode()) |
| 309 rootNode = rootNode.parentNode(); | 293 rootNode = rootNode.parentNode(); |
| 310 console.log(rootNode.printSelfAndChildren(inspectedNode)); // eslint-disabl
e-line no-console | 294 console.log(rootNode.printSelfAndChildren(inspectedNode)); // eslint-disabl
e-line no-console |
| 311 } | 295 } |
| 312 }; | 296 }; |
| 313 | 297 |
| 314 SDK.SDKModel.register(Accessibility.AccessibilityModel, SDK.Target.Capability.DO
M, false); | 298 SDK.SDKModel.register(Accessibility.AccessibilityModel, SDK.Target.Capability.DO
M, false); |
| OLD | NEW |