| 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 AutomationEvent = require('automationEvent').AutomationEvent; | 5 var AutomationEvent = require('automationEvent').AutomationEvent; |
| 6 var automationInternal = | 6 var automationInternal = |
| 7 require('binding').Binding.create('automationInternal').generate(); | 7 require('binding').Binding.create('automationInternal').generate(); |
| 8 var IsInteractPermitted = | 8 var IsInteractPermitted = |
| 9 requireNative('automationInternal').IsInteractPermitted; | 9 requireNative('automationInternal').IsInteractPermitted; |
| 10 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (this.listeners[eventType]) { | 107 if (this.listeners[eventType]) { |
| 108 var listeners = this.listeners[eventType]; | 108 var listeners = this.listeners[eventType]; |
| 109 for (var i = 0; i < listeners.length; i++) { | 109 for (var i = 0; i < listeners.length; i++) { |
| 110 if (callback === listeners[i].callback) | 110 if (callback === listeners[i].callback) |
| 111 listeners.splice(i, 1); | 111 listeners.splice(i, 1); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 }, | 114 }, |
| 115 | 115 |
| 116 dispatchEvent: function(eventType) { | 116 dispatchEvent: function(eventType) { |
| 117 logging.LOG('dispatching ' + eventType + ' on ' + this.id); | |
| 118 var path = []; | 117 var path = []; |
| 119 var parent = this.parent(); | 118 var parent = this.parent(); |
| 120 while (parent) { | 119 while (parent) { |
| 121 path.push(parent); | 120 path.push(parent); |
| 122 // TODO(aboxhall/dtseng): handle unloaded parent node | 121 // TODO(aboxhall/dtseng): handle unloaded parent node |
| 123 parent = parent.parent(); | 122 parent = parent.parent(); |
| 124 } | 123 } |
| 125 var event = new AutomationEvent(eventType, this.wrapper); | 124 var event = new AutomationEvent(eventType, this.wrapper); |
| 126 | 125 |
| 127 // Dispatch the event through the propagation path in three phases: | 126 // Dispatch the event through the propagation path in three phases: |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 * unique ids per node and we use these ids to build a hash to the actual | 275 * unique ids per node and we use these ids to build a hash to the actual |
| 277 * AutomationNode object. | 276 * AutomationNode object. |
| 278 * Thus, tree traversals amount to a lookup in our hash. | 277 * Thus, tree traversals amount to a lookup in our hash. |
| 279 * | 278 * |
| 280 * The tree itself is identified by the process id and routing id of the | 279 * The tree itself is identified by the process id and routing id of the |
| 281 * renderer widget host. | 280 * renderer widget host. |
| 282 * @constructor | 281 * @constructor |
| 283 */ | 282 */ |
| 284 function AutomationRootNodeImpl(processID, routingID) { | 283 function AutomationRootNodeImpl(processID, routingID) { |
| 285 AutomationNodeImpl.call(this, this); | 284 AutomationNodeImpl.call(this, this); |
| 286 logging.LOG('AutomationRootNodeImpl constructor: processID=' + processID + | |
| 287 '; routingID=' + routingID + '; this.id=' + this.id); | |
| 288 this.processID = processID; | 285 this.processID = processID; |
| 289 this.routingID = routingID; | 286 this.routingID = routingID; |
| 290 this.axNodeDataCache_ = {}; | 287 this.axNodeDataCache_ = {}; |
| 291 } | 288 } |
| 292 | 289 |
| 293 AutomationRootNodeImpl.prototype = { | 290 AutomationRootNodeImpl.prototype = { |
| 294 __proto__: AutomationNodeImpl.prototype, | 291 __proto__: AutomationNodeImpl.prototype, |
| 295 | 292 |
| 296 isRootNode: true, | 293 isRootNode: true, |
| 297 | 294 |
| 298 get: function(id) { | 295 get: function(id) { |
| 299 if (id == undefined) | 296 if (id == undefined) |
| 300 return undefined; | 297 return undefined; |
| 301 | 298 |
| 302 return this.axNodeDataCache_[id]; | 299 return this.axNodeDataCache_[id]; |
| 303 }, | 300 }, |
| 304 | 301 |
| 305 unserialize: function(update) { | 302 unserialize: function(update) { |
| 306 var updateState = { pendingNodes: {}, newNodes: {} }; | 303 var updateState = { pendingNodes: {}, newNodes: {} }; |
| 304 var oldRootId = this.id; |
| 307 | 305 |
| 308 if (update.nodeIdToClear < 0) { | 306 if (update.nodeIdToClear < 0) { |
| 309 logging.WARNING('Bad nodeIdToClear: ' + update.nodeIdToClear); | 307 logging.WARNING('Bad nodeIdToClear: ' + update.nodeIdToClear); |
| 310 lastError.set('automation', | 308 lastError.set('automation', |
| 311 'Bad update received on automation tree', | 309 'Bad update received on automation tree', |
| 312 null, | 310 null, |
| 313 chrome); | 311 chrome); |
| 314 return false; | 312 return false; |
| 315 } else if (update.nodeIdToClear > 0) { | 313 } else if (update.nodeIdToClear > 0) { |
| 316 var nodeToClear = this.axNodeDataCache_[update.nodeIdToClear]; | 314 var nodeToClear = this.axNodeDataCache_[update.nodeIdToClear]; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 privates(childNode).impl.indexInParent = i; | 485 privates(childNode).impl.indexInParent = i; |
| 488 privates(childNode).impl.parentID = node.id; | 486 privates(childNode).impl.parentID = node.id; |
| 489 } | 487 } |
| 490 | 488 |
| 491 return success; | 489 return success; |
| 492 }, | 490 }, |
| 493 | 491 |
| 494 setData_: function(node, nodeData) { | 492 setData_: function(node, nodeData) { |
| 495 var nodeImpl = privates(node).impl; | 493 var nodeImpl = privates(node).impl; |
| 496 for (var key in AutomationAttributeDefaults) { | 494 for (var key in AutomationAttributeDefaults) { |
| 497 if (key in nodeData) { | 495 if (key in nodeData) |
| 498 if (key == 'id' && nodeImpl[key] != nodeData[key]) { | |
| 499 logging.LOG('Changing ID of node from ' + nodeImpl[key] + ' to ' + | |
| 500 nodeData[key]); | |
| 501 } | |
| 502 nodeImpl[key] = nodeData[key]; | 496 nodeImpl[key] = nodeData[key]; |
| 503 } else { | 497 else |
| 504 nodeImpl[key] = AutomationAttributeDefaults[key]; | 498 nodeImpl[key] = AutomationAttributeDefaults[key]; |
| 505 } | |
| 506 } | 499 } |
| 507 for (var i = 0; i < AutomationAttributeTypes.length; i++) { | 500 for (var i = 0; i < AutomationAttributeTypes.length; i++) { |
| 508 var attributeType = AutomationAttributeTypes[i]; | 501 var attributeType = AutomationAttributeTypes[i]; |
| 509 for (var attributeName in nodeData[attributeType]) { | 502 for (var attributeName in nodeData[attributeType]) { |
| 510 nodeImpl.attributesInternal[attributeName] = | 503 nodeImpl.attributesInternal[attributeName] = |
| 511 nodeData[attributeType][attributeName]; | 504 nodeData[attributeType][attributeName]; |
| 512 if (ATTRIBUTE_BLACKLIST.hasOwnProperty(attributeName) || | 505 if (ATTRIBUTE_BLACKLIST.hasOwnProperty(attributeName) || |
| 513 nodeImpl.attributes.hasOwnProperty(attributeName)) { | 506 nodeImpl.attributes.hasOwnProperty(attributeName)) { |
| 514 continue; | 507 continue; |
| 515 } else if ( | 508 } else if ( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 'toString'] }); | 607 'toString'] }); |
| 615 | 608 |
| 616 var AutomationRootNode = utils.expose('AutomationRootNode', | 609 var AutomationRootNode = utils.expose('AutomationRootNode', |
| 617 AutomationRootNodeImpl, | 610 AutomationRootNodeImpl, |
| 618 { superclass: AutomationNode, | 611 { superclass: AutomationNode, |
| 619 functions: ['load'], | 612 functions: ['load'], |
| 620 readonly: ['loaded'] }); | 613 readonly: ['loaded'] }); |
| 621 | 614 |
| 622 exports.AutomationNode = AutomationNode; | 615 exports.AutomationNode = AutomationNode; |
| 623 exports.AutomationRootNode = AutomationRootNode; | 616 exports.AutomationRootNode = AutomationRootNode; |
| OLD | NEW |