| 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 Event = require('event_bindings').Event; | 5 var Event = require('event_bindings').Event; |
| 6 var AutomationNode = require('automationNode').AutomationNode; | 6 var AutomationNode = require('automationNode').AutomationNode; |
| 7 | 7 |
| 8 // Maps an attribute to its default value in an invalidated node. | 8 // Maps an attribute to its default value in an invalidated node. |
| 9 // These attributes are taken directly from the Automation idl. | 9 // These attributes are taken directly from the Automation idl. |
| 10 var AutomationAttributeDefaults = { | 10 var AutomationAttributeDefaults = { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 * An AutomationTree is the javascript end of an AXTree living in the browser. | 30 * An AutomationTree is the javascript end of an AXTree living in the browser. |
| 31 * AutomationTree handles unserializing incremental updates from the source | 31 * AutomationTree handles unserializing incremental updates from the source |
| 32 * AXTree. Each update contains node data that form a complete tree after | 32 * AXTree. Each update contains node data that form a complete tree after |
| 33 * applying the update. | 33 * applying the update. |
| 34 * | 34 * |
| 35 * A brief note about ids used through this class. The source AXTree assigns | 35 * A brief note about ids used through this class. The source AXTree assigns |
| 36 * unique ids per node and we use these ids to build a hash to the actual | 36 * unique ids per node and we use these ids to build a hash to the actual |
| 37 * AutomationNode object. | 37 * AutomationNode object. |
| 38 * Thus, tree traversals amount to a lookup in our hash. | 38 * Thus, tree traversals amount to a lookup in our hash. |
| 39 * | 39 * |
| 40 * The tree itself is identified by the process id and routing id of the |
| 41 * renderer widget host. |
| 40 * @constructor | 42 * @constructor |
| 41 */ | 43 */ |
| 42 var AutomationTree = function(routingId) { | 44 var AutomationTree = function(processId, routingId) { |
| 43 privates(this).impl = new AutomationTreeImpl(routingId); | 45 privates(this).impl = new AutomationTreeImpl(processId, routingId); |
| 44 | |
| 45 /** | |
| 46 * Event fired when a tree update occurs. | |
| 47 * @deprecated TODO(aboxhall/dtseng): remove this event; it should not be | |
| 48 * exposed in the public API. Replace with EventListener style API which | |
| 49 * allows listening for events in the AXEvent enum. | |
| 50 */ | |
| 51 this.onUpdate = new Event(); | |
| 52 }; | 46 }; |
| 53 | 47 |
| 54 | 48 |
| 55 AutomationTree.prototype = { | 49 AutomationTree.prototype = { |
| 56 /** | 50 /** |
| 57 * The root of this automation tree. | 51 * The root of this automation tree. |
| 58 * @type {Object} | 52 * @type {Object} |
| 59 */ | 53 */ |
| 60 get root() { | 54 get root() { |
| 61 return privates(this).impl.root; | 55 return privates(this).impl.root; |
| 62 } | 56 } |
| 63 }; | 57 }; |
| 64 | 58 |
| 65 | 59 |
| 66 var AutomationTreeImpl = function(routingId) { | 60 var AutomationTreeImpl = function(processId, routingId) { |
| 61 this.processId = processId; |
| 67 this.routingId = routingId; | 62 this.routingId = routingId; |
| 68 | 63 |
| 69 /** | 64 /** |
| 70 * Our cache of the native AXTree. | 65 * Our cache of the native AXTree. |
| 71 * @type {!Object.<number, Object>} | 66 * @type {!Object.<number, Object>} |
| 72 * @private | 67 * @private |
| 73 */ | 68 */ |
| 74 this.axNodeDataCache_ = {}; | 69 this.axNodeDataCache_ = {}; |
| 75 }; | 70 }; |
| 76 | 71 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 attributeTypeIndex < AutomationAttributeTypes.length; | 167 attributeTypeIndex < AutomationAttributeTypes.length; |
| 173 attributeTypeIndex++) { | 168 attributeTypeIndex++) { |
| 174 var attribute_type = AutomationAttributeTypes[attributeTypeIndex]; | 169 var attribute_type = AutomationAttributeTypes[attributeTypeIndex]; |
| 175 for (var attribute_id in nodeData[attribute_type]) { | 170 for (var attribute_id in nodeData[attribute_type]) { |
| 176 node.attributes[attribute_id] = | 171 node.attributes[attribute_id] = |
| 177 nodeData[attribute_type][attribute_id]; | 172 nodeData[attribute_type][attribute_id]; |
| 178 } | 173 } |
| 179 } | 174 } |
| 180 privates(node).impl.child_ids = new_child_ids; | 175 privates(node).impl.child_ids = new_child_ids; |
| 181 this.axNodeDataCache_[node.id] = node; | 176 this.axNodeDataCache_[node.id] = node; |
| 177 privates(node).impl.notifyEventListeners(data.event_type); |
| 182 } | 178 } |
| 183 return true; | 179 return true; |
| 184 } | 180 } |
| 185 }; | 181 }; |
| 186 | 182 |
| 187 | 183 |
| 188 exports.AutomationTree = AutomationTree; | 184 exports.AutomationTree = AutomationTree; |
| OLD | NEW |