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 exceptionHandler = require('uncaught_exception_handler'); | 8 var exceptionHandler = require('uncaught_exception_handler'); |
9 var IsInteractPermitted = | 9 var IsInteractPermitted = |
10 requireNative('automationInternal').IsInteractPermitted; | 10 requireNative('automationInternal').IsInteractPermitted; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 402 } |
403 }, | 403 }, |
404 | 404 |
405 toJSON: function() { | 405 toJSON: function() { |
406 return { treeID: this.treeID, | 406 return { treeID: this.treeID, |
407 id: this.id, | 407 id: this.id, |
408 role: this.role, | 408 role: this.role, |
409 attributes: this.attributes }; | 409 attributes: this.attributes }; |
410 }, | 410 }, |
411 | 411 |
412 dispatchEvent: function(eventType) { | 412 dispatchEvent: function(eventType, eventFrom) { |
413 var path = []; | 413 var path = []; |
414 var parent = this.parent; | 414 var parent = this.parent; |
415 while (parent) { | 415 while (parent) { |
416 $Array.push(path, parent); | 416 $Array.push(path, parent); |
417 parent = parent.parent; | 417 parent = parent.parent; |
418 } | 418 } |
419 var event = new AutomationEvent(eventType, this.wrapper); | 419 var event = new AutomationEvent(eventType, this.wrapper, eventFrom); |
420 | 420 |
421 // Dispatch the event through the propagation path in three phases: | 421 // Dispatch the event through the propagation path in three phases: |
422 // - capturing: starting from the root and going down to the target's parent | 422 // - capturing: starting from the root and going down to the target's parent |
423 // - targeting: dispatching the event on the target itself | 423 // - targeting: dispatching the event on the target itself |
424 // - bubbling: starting from the target's parent, going back up to the root. | 424 // - bubbling: starting from the target's parent, going back up to the root. |
425 // At any stage, a listener may call stopPropagation() on the event, which | 425 // At any stage, a listener may call stopPropagation() on the event, which |
426 // will immediately stop event propagation through this path. | 426 // will immediately stop event propagation through this path. |
427 if (this.dispatchEventAtCapturing_(event, path)) { | 427 if (this.dispatchEventAtCapturing_(event, path)) { |
428 if (this.dispatchEventAtTargeting_(event, path)) | 428 if (this.dispatchEventAtTargeting_(event, path)) |
429 this.dispatchEventAtBubbling_(event, path); | 429 this.dispatchEventAtBubbling_(event, path); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 return obj; | 956 return obj; |
957 }, | 957 }, |
958 | 958 |
959 remove: function(id) { | 959 remove: function(id) { |
960 if (this.axNodeDataCache_[id]) | 960 if (this.axNodeDataCache_[id]) |
961 privates(this.axNodeDataCache_[id]).impl.detach(); | 961 privates(this.axNodeDataCache_[id]).impl.detach(); |
962 delete this.axNodeDataCache_[id]; | 962 delete this.axNodeDataCache_[id]; |
963 }, | 963 }, |
964 | 964 |
965 destroy: function() { | 965 destroy: function() { |
966 this.dispatchEvent(schema.EventType.destroyed); | 966 this.dispatchEvent(schema.EventType.destroyed, 'none'); |
967 for (var id in this.axNodeDataCache_) | 967 for (var id in this.axNodeDataCache_) |
968 this.remove(id); | 968 this.remove(id); |
969 this.detach(); | 969 this.detach(); |
970 }, | 970 }, |
971 | 971 |
972 setHostNode(hostNode) { | 972 setHostNode(hostNode) { |
973 this.hostNode_ = hostNode; | 973 this.hostNode_ = hostNode; |
974 }, | 974 }, |
975 | 975 |
976 onAccessibilityEvent: function(eventParams) { | 976 onAccessibilityEvent: function(eventParams) { |
977 var targetNode = this.get(eventParams.targetID); | 977 var targetNode = this.get(eventParams.targetID); |
978 if (targetNode) { | 978 if (targetNode) { |
979 var targetNodeImpl = privates(targetNode).impl; | 979 var targetNodeImpl = privates(targetNode).impl; |
980 targetNodeImpl.dispatchEvent(eventParams.eventType); | 980 targetNodeImpl.dispatchEvent( |
| 981 eventParams.eventType, eventParams.eventFrom); |
981 } else { | 982 } else { |
982 logging.WARNING('Got ' + eventParams.eventType + | 983 logging.WARNING('Got ' + eventParams.eventType + |
983 ' event on unknown node: ' + eventParams.targetID + | 984 ' event on unknown node: ' + eventParams.targetID + |
984 '; this: ' + this.id); | 985 '; this: ' + this.id); |
985 } | 986 } |
986 return true; | 987 return true; |
987 }, | 988 }, |
988 | 989 |
989 toString: function() { | 990 toString: function() { |
990 function toStringInternal(nodeImpl, indent) { | 991 function toStringInternal(nodeImpl, indent) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) { | 1066 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) { |
1066 return AutomationRootNodeImpl.getOrCreate(treeID); | 1067 return AutomationRootNodeImpl.getOrCreate(treeID); |
1067 }); | 1068 }); |
1068 | 1069 |
1069 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) { | 1070 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) { |
1070 AutomationRootNodeImpl.destroy(treeID); | 1071 AutomationRootNodeImpl.destroy(treeID); |
1071 }); | 1072 }); |
1072 | 1073 |
1073 exports.$set('AutomationNode', AutomationNode); | 1074 exports.$set('AutomationNode', AutomationNode); |
1074 exports.$set('AutomationRootNode', AutomationRootNode); | 1075 exports.$set('AutomationRootNode', AutomationRootNode); |
OLD | NEW |