Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/renderer/resources/extensions/automation/automation_tree.js

Issue 203753002: Implement actions for Automation API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial patch. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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/renderer host pair.
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 46
45 /** 47 /**
46 * Event fired when a tree update occurs. 48 * Event fired when a tree update occurs.
47 * @deprecated TODO(aboxhall/dtseng): remove this event; it should not be 49 * @deprecated TODO(aboxhall/dtseng): remove this event; it should not be
48 * exposed in the public API. Replace with EventListener style API which 50 * exposed in the public API. Replace with EventListener style API which
49 * allows listening for events in the AXEvent enum. 51 * allows listening for events in the AXEvent enum.
50 */ 52 */
51 this.onUpdate = new Event(); 53 this.onUpdate = new Event();
52 }; 54 };
53 55
54 56
55 AutomationTree.prototype = { 57 AutomationTree.prototype = {
56 /** 58 /**
57 * The root of this automation tree. 59 * The root of this automation tree.
58 * @type {Object} 60 * @type {Object}
59 */ 61 */
60 get root() { 62 get root() {
61 return privates(this).impl.root; 63 return privates(this).impl.root;
62 } 64 }
63 }; 65 };
64 66
65 67
66 var AutomationTreeImpl = function(routingId) { 68 var AutomationTreeImpl = function(processId, routingId) {
69 this.processId = processId;
67 this.routingId = routingId; 70 this.routingId = routingId;
68 71
69 /** 72 /**
70 * Our cache of the native AXTree. 73 * Our cache of the native AXTree.
71 * @type {!Object.<number, Object>} 74 * @type {!Object.<number, Object>}
72 * @private 75 * @private
73 */ 76 */
74 this.axNodeDataCache_ = {}; 77 this.axNodeDataCache_ = {};
75 }; 78 };
76 79
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 182 }
180 privates(node).impl.child_ids = new_child_ids; 183 privates(node).impl.child_ids = new_child_ids;
181 this.axNodeDataCache_[node.id] = node; 184 this.axNodeDataCache_[node.id] = node;
182 } 185 }
183 return true; 186 return true;
184 } 187 }
185 }; 188 };
186 189
187 190
188 exports.AutomationTree = AutomationTree; 191 exports.AutomationTree = AutomationTree;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698