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 // TODO(dtseng): Figure out if there's any other way to get access to |
| 6 // AutomationInternal. |
| 7 var automationInternal = |
| 8 require('binding').Binding.create('automationInternal').generate(); |
5 var utils = require('utils'); | 9 var utils = require('utils'); |
6 | 10 |
7 /** | 11 /** |
8 * A single node in the Automation tree. | 12 * A single node in the Automation tree. |
9 * @param {AutomationTree} owner The owning tree. | 13 * @param {AutomationTree} owner The owning tree. |
10 * @constructor | 14 * @constructor |
11 */ | 15 */ |
12 var AutomationNodeImpl = function(owner) { | 16 var AutomationNodeImpl = function(owner) { |
13 this.owner = owner; | 17 this.owner = owner; |
14 this.child_ids = []; | 18 this.child_ids = []; |
(...skipping 30 matching lines...) Expand all Loading... |
45 return parent.children()[this.index_in_parent - 1]; | 49 return parent.children()[this.index_in_parent - 1]; |
46 return undefined; | 50 return undefined; |
47 }, | 51 }, |
48 | 52 |
49 nextSibling: function() { | 53 nextSibling: function() { |
50 var parent = this.parent(); | 54 var parent = this.parent(); |
51 if (parent && this.index_in_parent < parent.children().length) | 55 if (parent && this.index_in_parent < parent.children().length) |
52 return parent.children()[this.index_in_parent + 1]; | 56 return parent.children()[this.index_in_parent + 1]; |
53 return undefined; | 57 return undefined; |
54 }, | 58 }, |
| 59 |
| 60 doDefault: function() { |
| 61 AutomationInternal.performAction( |
| 62 'doDefault', this.owner.process_id, this.id) |
| 63 }, |
| 64 |
| 65 focus: function() { |
| 66 AutomationInternal.performAction( |
| 67 'focus', this.owner.process_id, this.id) |
| 68 }, |
| 69 |
| 70 makeVisible: function() { |
| 71 AutomationInternal.performAction( |
| 72 'makeVisible', this.owner.process_id, this.id) |
| 73 }, |
| 74 |
| 75 setSelection: function(startIndex, endIndex) { |
| 76 AutomationInternal.performAction( |
| 77 'setSelection', this.owner.process_id, this.id, [startIndex, endIndex]); |
| 78 }, |
55 }; | 79 }; |
56 | 80 |
57 | |
58 var AutomationNode = utils.expose('AutomationNode', | 81 var AutomationNode = utils.expose('AutomationNode', |
59 AutomationNodeImpl, | 82 AutomationNodeImpl, |
60 ['parent', | 83 ['parent', |
61 'firstChild', | 84 'firstChild', |
62 'lastChild', | 85 'lastChild', |
63 'children', | 86 'children', |
64 'previousSibling', | 87 'previousSibling', |
65 'nextSibling']); | 88 'nextSibling', |
| 89 'doDefault', |
| 90 'focus', |
| 91 'makeVisible', |
| 92 'setSelection']); |
66 exports.AutomationNode = AutomationNode; | 93 exports.AutomationNode = AutomationNode; |
OLD | NEW |