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

Unified Diff: chrome/renderer/resources/extensions/automation/automation_node.js

Issue 2770713008: Automation API: Get rid of host node and get parent from C++ bindings instead
Patch Set: Rebase Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/automation/automation_node.js
diff --git a/chrome/renderer/resources/extensions/automation/automation_node.js b/chrome/renderer/resources/extensions/automation/automation_node.js
index 15b722570a53cce1a08e750c559672d4226247d3..1f9a44271be13c1e52e03600118e9f1ac07124b1 100644
--- a/chrome/renderer/resources/extensions/automation/automation_node.js
+++ b/chrome/renderer/resources/extensions/automation/automation_node.js
@@ -79,10 +79,11 @@ var GetFocusAffinity = requireNative('automationInternal').GetFocusAffinity;
/**
* @param {number} axTreeID The id of the accessibility tree.
* @param {number} nodeID The id of a node.
- * @return {?number} The id of the node's parent, or undefined if it's the
+ * @return {?Array<number>} An array containing the tree id and node id
+ * of the node's parent, or undefined if it's the
* root of its tree or if the tree or node wasn't found.
*/
-var GetParentID = requireNative('automationInternal').GetParentID;
+var GetParent = requireNative('automationInternal').GetParent;
/**
* @param {number} axTreeID The id of the accessibility tree.
@@ -242,7 +243,6 @@ var utils = require('utils');
*/
function AutomationNodeImpl(root) {
this.rootImpl = root;
- this.hostNode_ = null;
this.listeners = {__proto__: null};
}
@@ -254,7 +254,6 @@ AutomationNodeImpl.prototype = {
detach: function() {
this.rootImpl = null;
- this.hostNode_ = null;
this.listeners = {__proto__: null};
},
@@ -265,10 +264,17 @@ AutomationNodeImpl.prototype = {
get parent() {
if (!this.rootImpl)
return undefined;
- if (this.hostNode_)
- return this.hostNode_;
- var parentID = GetParentID(this.treeID, this.id);
- return this.rootImpl.get(parentID);
+ var parentTreeIDAndNodeID = GetParent(this.treeID, this.id);
+ if (!parentTreeIDAndNodeID)
+ return undefined;
+ var parentTreeID = parentTreeIDAndNodeID[0];
+ var parentNodeID = parentTreeIDAndNodeID[1];
+ if (parentTreeID == this.treeID)
+ return this.rootImpl.get(parentNodeID);
+ var tree = AutomationRootNodeImpl.get(parentTreeID);
+ if (!tree)
+ return undefined;
+ return tree.get(parentNodeID);
},
get htmlAttributes() {
@@ -495,7 +501,6 @@ AutomationNodeImpl.prototype = {
},
toString: function() {
- var parentID = GetParentID(this.treeID, this.id);
var childTreeID = GetIntAttribute(this.treeID, this.id, 'childTreeId');
var count = GetChildCount(this.treeID, this.id);
var childIDs = [];
@@ -507,13 +512,7 @@ AutomationNodeImpl.prototype = {
var result = 'node id=' + this.id +
' role=' + this.role +
' state=' + $JSON.stringify(this.state) +
- ' parentID=' + parentID +
' childIds=' + $JSON.stringify(childIDs);
- if (this.hostNode_) {
- var hostNodeImpl = privates(this.hostNode_).impl;
- result += ' host treeID=' + hostNodeImpl.treeID +
- ' host nodeID=' + hostNodeImpl.id;
- }
if (childTreeID)
result += ' childTreeID=' + childTreeID;
return result;
@@ -914,13 +913,6 @@ AutomationRootNodeImpl.prototype = {
treeID: -1,
/**
- * The parent of this node from a different tree.
- * @type {?AutomationNode}
- * @private
- */
- hostNode_: null,
-
- /**
* A map from id to AutomationNode.
* @type {Object.<number, AutomationNode>}
* @private
@@ -1030,10 +1022,6 @@ AutomationRootNodeImpl.prototype = {
this.detach();
},
- setHostNode(hostNode) {
- this.hostNode_ = hostNode;
- },
-
onAccessibilityEvent: function(eventParams) {
var targetNode = this.get(eventParams.targetID);
if (targetNode) {

Powered by Google App Engine
This is Rietveld 408576698