| 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('setDocumentSelection', function(params) { |
| 131 var anchorNodeImpl = privates(params.anchorObject).impl; |
| 132 var focusNodeImpl = privates(params.focusObject).impl; |
| 133 if (anchorNodeImpl.treeID !== focusNodeImpl.treeID) |
| 134 throw new Error('Selection anchor and focus must be in the same tree.'); |
| 135 if (anchorNodeImpl.treeID === DESKTOP_TREE_ID) { |
| 136 throw new Error('Use AutomationNode.setSelection to set the selection ' + |
| 137 'in the desktop tree.'); |
| 138 } |
| 139 automationInternal.performAction({ treeID: anchorNodeImpl.treeID, |
| 140 automationNodeID: anchorNodeImpl.id, |
| 141 actionType: 'setSelection'}, |
| 142 { focusNodeID: focusNodeImpl.id, |
| 143 anchorOffset: params.anchorOffset, |
| 144 focusOffset: params.focusOffset }); |
| 145 }); |
| 146 |
| 130 }); | 147 }); |
| 131 | 148 |
| 132 automationInternal.onTreeChange.addListener(function(treeID, | 149 automationInternal.onTreeChange.addListener(function(treeID, |
| 133 nodeID, | 150 nodeID, |
| 134 changeType) { | 151 changeType) { |
| 135 var tree = AutomationRootNode.getOrCreate(treeID); | 152 var tree = AutomationRootNode.getOrCreate(treeID); |
| 136 if (!tree) | 153 if (!tree) |
| 137 return; | 154 return; |
| 138 | 155 |
| 139 var node = privates(tree).impl.get(nodeID); | 156 var node = privates(tree).impl.get(nodeID); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 }); | 251 }); |
| 235 | 252 |
| 236 exports.binding = automation.generate(); | 253 exports.binding = automation.generate(); |
| 237 | 254 |
| 238 // Add additional accessibility bindings not specified in the automation IDL. | 255 // Add additional accessibility bindings not specified in the automation IDL. |
| 239 // Accessibility and automation share some APIs (see | 256 // Accessibility and automation share some APIs (see |
| 240 // ui/accessibility/ax_enums.idl). | 257 // ui/accessibility/ax_enums.idl). |
| 241 forEach(schema, function(k, v) { | 258 forEach(schema, function(k, v) { |
| 242 exports.binding[k] = v; | 259 exports.binding[k] = v; |
| 243 }); | 260 }); |
| OLD | NEW |