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

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

Issue 1970153003: Completely detach removed nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 years, 7 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
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 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 var schema = requireNative('automationInternal').GetSchemaAdditions(); 192 var schema = requireNative('automationInternal').GetSchemaAdditions();
193 var utils = require('utils'); 193 var utils = require('utils');
194 194
195 /** 195 /**
196 * A single node in the Automation tree. 196 * A single node in the Automation tree.
197 * @param {AutomationRootNodeImpl} root The root of the tree. 197 * @param {AutomationRootNodeImpl} root The root of the tree.
198 * @constructor 198 * @constructor
199 */ 199 */
200 function AutomationNodeImpl(root) { 200 function AutomationNodeImpl(root) {
201 this.rootImpl = root; 201 this.rootImpl = root;
202 this.hostNode_ = null;
202 this.listeners = {__proto__: null}; 203 this.listeners = {__proto__: null};
203 } 204 }
204 205
205 AutomationNodeImpl.prototype = { 206 AutomationNodeImpl.prototype = {
206 __proto__: null, 207 __proto__: null,
207 treeID: -1, 208 treeID: -1,
208 id: -1, 209 id: -1,
209 isRootNode: false, 210 isRootNode: false,
210 211
212 detach: function() {
213 this.rootImpl = null;
214 this.hostNode_ = null;
215 this.listeners = {__proto__: null};
216 },
217
211 get root() { 218 get root() {
212 return this.rootImpl.wrapper; 219 return this.rootImpl && this.rootImpl.wrapper;
213 }, 220 },
214 221
215 get parent() { 222 get parent() {
216 if (this.hostNode_) 223 if (this.hostNode_)
217 return this.hostNode_; 224 return this.hostNode_;
218 var parentID = GetParentID(this.treeID, this.id); 225 var parentID = GetParentID(this.treeID, this.id);
219 return this.rootImpl.get(parentID); 226 return this.rootImpl.get(parentID);
220 }, 227 },
221 228
222 get state() { 229 get state() {
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 907
901 obj = new AutomationNode(this); 908 obj = new AutomationNode(this);
902 privates(obj).impl.treeID = this.treeID; 909 privates(obj).impl.treeID = this.treeID;
903 privates(obj).impl.id = id; 910 privates(obj).impl.id = id;
904 this.axNodeDataCache_[id] = obj; 911 this.axNodeDataCache_[id] = obj;
905 912
906 return obj; 913 return obj;
907 }, 914 },
908 915
909 remove: function(id) { 916 remove: function(id) {
917 if (this.axNodeDataCache_[id])
918 privates(this.axNodeDataCache_[id]).impl.detach();
910 delete this.axNodeDataCache_[id]; 919 delete this.axNodeDataCache_[id];
911 }, 920 },
912 921
913 destroy: function() { 922 destroy: function() {
914 this.dispatchEvent(schema.EventType.destroyed); 923 this.dispatchEvent(schema.EventType.destroyed);
924 for (var id in this.axNodeDataCache_)
925 this.remove(id);
926 this.detach();
915 }, 927 },
916 928
917 setHostNode(hostNode) { 929 setHostNode(hostNode) {
918 this.hostNode_ = hostNode; 930 this.hostNode_ = hostNode;
919 }, 931 },
920 932
921 onAccessibilityEvent: function(eventParams) { 933 onAccessibilityEvent: function(eventParams) {
922 var targetNode = this.get(eventParams.targetID); 934 var targetNode = this.get(eventParams.targetID);
923 if (targetNode) { 935 if (targetNode) {
924 var targetNodeImpl = privates(targetNode).impl; 936 var targetNodeImpl = privates(targetNode).impl;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) { 1021 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) {
1010 return AutomationRootNodeImpl.getOrCreate(treeID); 1022 return AutomationRootNodeImpl.getOrCreate(treeID);
1011 }); 1023 });
1012 1024
1013 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) { 1025 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) {
1014 AutomationRootNodeImpl.destroy(treeID); 1026 AutomationRootNodeImpl.destroy(treeID);
1015 }); 1027 });
1016 1028
1017 exports.$set('AutomationNode', AutomationNode); 1029 exports.$set('AutomationNode', AutomationNode);
1018 exports.$set('AutomationRootNode', AutomationRootNode); 1030 exports.$set('AutomationRootNode', AutomationRootNode);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698