OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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 var AutomationEvent = require('automationEvent').AutomationEvent; | 5 var AutomationEvent = require('automationEvent').AutomationEvent; |
6 var automationInternal = | 6 var automationInternal = |
7 require('binding').Binding.create('automationInternal').generate(); | 7 require('binding').Binding.create('automationInternal').generate(); |
8 var utils = require('utils'); | 8 var utils = require('utils'); |
9 var IsInteractPermitted = | 9 var IsInteractPermitted = |
10 requireNative('automationInternal').IsInteractPermitted; | 10 requireNative('automationInternal').IsInteractPermitted; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 var parent = this.parent(); | 65 var parent = this.parent(); |
66 if (parent && this.indexInParent < parent.children().length) | 66 if (parent && this.indexInParent < parent.children().length) |
67 return parent.children()[this.indexInParent + 1]; | 67 return parent.children()[this.indexInParent + 1]; |
68 return undefined; | 68 return undefined; |
69 }, | 69 }, |
70 | 70 |
71 doDefault: function() { | 71 doDefault: function() { |
72 this.performAction_('doDefault'); | 72 this.performAction_('doDefault'); |
73 }, | 73 }, |
74 | 74 |
75 focus: function(opt_callback) { | 75 focus: function() { |
76 this.performAction_('focus'); | 76 this.performAction_('focus'); |
77 }, | 77 }, |
78 | 78 |
79 makeVisible: function(opt_callback) { | 79 makeVisible: function() { |
80 this.performAction_('makeVisible'); | 80 this.performAction_('makeVisible'); |
81 }, | 81 }, |
82 | 82 |
83 setSelection: function(startIndex, endIndex, opt_callback) { | 83 setSelection: function(startIndex, endIndex) { |
84 this.performAction_('setSelection', | 84 this.performAction_('setSelection', |
85 { startIndex: startIndex, | 85 { startIndex: startIndex, |
86 endIndex: endIndex }); | 86 endIndex: endIndex }); |
87 }, | 87 }, |
88 | 88 |
89 addEventListener: function(eventType, callback, capture) { | 89 addEventListener: function(eventType, callback, capture) { |
90 this.removeEventListener(eventType, callback); | 90 this.removeEventListener(eventType, callback); |
91 if (!this.listeners[eventType]) | 91 if (!this.listeners[eventType]) |
92 this.listeners[eventType] = []; | 92 this.listeners[eventType] = []; |
93 this.listeners[eventType].push({callback: callback, capture: !!capture}); | 93 this.listeners[eventType].push({callback: callback, capture: !!capture}); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 var nodeImpl = privates(node).impl; | 272 var nodeImpl = privates(node).impl; |
273 var id = node.id; | 273 var id = node.id; |
274 for (var key in AutomationAttributeDefaults) { | 274 for (var key in AutomationAttributeDefaults) { |
275 nodeImpl[key] = AutomationAttributeDefaults[key]; | 275 nodeImpl[key] = AutomationAttributeDefaults[key]; |
276 } | 276 } |
277 nodeImpl.loaded = false; | 277 nodeImpl.loaded = false; |
278 nodeImpl.id = id; | 278 nodeImpl.id = id; |
279 this.axNodeDataCache_[id] = undefined; | 279 this.axNodeDataCache_[id] = undefined; |
280 }, | 280 }, |
281 | 281 |
282 load: function(callback) { | |
283 // TODO(dtseng/aboxhall): Implement. | |
284 if (!this.loaded) | |
285 throw 'Unsupported state: root node is not loaded.'; | |
286 | |
287 callback(); | |
aboxhall
2014/07/07 17:24:24
Remember that we need to schedule the callback rat
| |
288 }, | |
289 | |
282 update: function(data) { | 290 update: function(data) { |
283 var didUpdateRoot = false; | 291 var didUpdateRoot = false; |
284 | 292 |
285 if (data.nodes.length == 0) | 293 if (data.nodes.length == 0) |
286 return false; | 294 return false; |
287 | 295 |
288 for (var i = 0; i < data.nodes.length; i++) { | 296 for (var i = 0; i < data.nodes.length; i++) { |
289 var nodeData = data.nodes[i]; | 297 var nodeData = data.nodes[i]; |
290 var node = this.axNodeDataCache_[nodeData.id]; | 298 var node = this.axNodeDataCache_[nodeData.id]; |
291 if (!node) { | 299 if (!node) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 'attributes'] }); | 399 'attributes'] }); |
392 | 400 |
393 var AutomationRootNode = utils.expose('AutomationRootNode', | 401 var AutomationRootNode = utils.expose('AutomationRootNode', |
394 AutomationRootNodeImpl, | 402 AutomationRootNodeImpl, |
395 { superclass: AutomationNode, | 403 { superclass: AutomationNode, |
396 functions: ['load'], | 404 functions: ['load'], |
397 readonly: ['loaded'] }); | 405 readonly: ['loaded'] }); |
398 | 406 |
399 exports.AutomationNode = AutomationNode; | 407 exports.AutomationNode = AutomationNode; |
400 exports.AutomationRootNode = AutomationRootNode; | 408 exports.AutomationRootNode = AutomationRootNode; |
OLD | NEW |