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 // Custom bindings for the automation API. | 5 // Custom bindings for the automation API. |
6 var AutomationNode = require('automationNode').AutomationNode; | 6 var AutomationNode = require('automationNode').AutomationNode; |
7 var AutomationRootNode = require('automationNode').AutomationRootNode; | 7 var AutomationRootNode = require('automationNode').AutomationRootNode; |
8 var automation = require('binding').Binding.create('automation'); | 8 var automation = require('binding').Binding.create('automation'); |
9 var automationInternal = | 9 var automationInternal = |
10 require('binding').Binding.create('automationInternal').generate(); | 10 require('binding').Binding.create('automationInternal').generate(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 }); | 120 }); |
121 | 121 |
122 function addTreeChangeObserver(observer) { | 122 function addTreeChangeObserver(observer) { |
123 removeTreeChangeObserver(observer); | 123 removeTreeChangeObserver(observer); |
124 automationUtil.treeChangeObservers.push(observer); | 124 automationUtil.treeChangeObservers.push(observer); |
125 } | 125 } |
126 apiFunctions.setHandleRequest('addTreeChangeObserver', function(observer) { | 126 apiFunctions.setHandleRequest('addTreeChangeObserver', function(observer) { |
127 addTreeChangeObserver(observer); | 127 addTreeChangeObserver(observer); |
128 }); | 128 }); |
129 | 129 |
130 apiFunctions.setHandleRequest('setSelection', function(anchorNode, | |
131 anchorOffset, | |
132 focusNode, | |
133 focusOffset) { | |
134 var anchorNodeImpl = privates(anchorNode).impl; | |
135 var focusNodeImpl = privates(focusNode).impl; | |
136 if (anchorNodeImpl.treeID !== focusNodeImpl.treeID) | |
137 throw new Error('Selection anchor and focus must be in the same tree.'); | |
138 if (anchorNodeImpl.treeID === DESKTOP_TREE_ID && | |
139 (anchorNodeImpl.id !== focusNodeImpl.id)) { | |
David Tseng
2015/09/23 19:10:42
Also, forgot to add that I think this API should j
| |
140 throw new Error( | |
141 'Selections in the desktop tree must be within the same node'); | |
142 } | |
143 automationInternal.performAction({ treeID: anchorNodeImpl.treeID, | |
144 automationNodeID: anchorNodeImpl.id, | |
145 actionType: 'setSelection'}, | |
146 { focusNodeID: focusNodeImpl.id, | |
147 anchorOffset: anchorOffset, | |
148 focusOffset: focusOffset }); | |
149 }); | |
150 | |
130 }); | 151 }); |
131 | 152 |
132 automationInternal.onTreeChange.addListener(function(treeID, | 153 automationInternal.onTreeChange.addListener(function(treeID, |
133 nodeID, | 154 nodeID, |
134 changeType) { | 155 changeType) { |
135 var tree = AutomationRootNode.getOrCreate(treeID); | 156 var tree = AutomationRootNode.getOrCreate(treeID); |
136 if (!tree) | 157 if (!tree) |
137 return; | 158 return; |
138 | 159 |
139 var node = privates(tree).impl.get(nodeID); | 160 var node = privates(tree).impl.get(nodeID); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 }); | 255 }); |
235 | 256 |
236 exports.binding = automation.generate(); | 257 exports.binding = automation.generate(); |
237 | 258 |
238 // Add additional accessibility bindings not specified in the automation IDL. | 259 // Add additional accessibility bindings not specified in the automation IDL. |
239 // Accessibility and automation share some APIs (see | 260 // Accessibility and automation share some APIs (see |
240 // ui/accessibility/ax_enums.idl). | 261 // ui/accessibility/ax_enums.idl). |
241 forEach(schema, function(k, v) { | 262 forEach(schema, function(k, v) { |
242 exports.binding[k] = v; | 263 exports.binding[k] = v; |
243 }); | 264 }); |
OLD | NEW |