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

Unified Diff: chrome/renderer/resources/extensions/automation_custom_bindings.js

Issue 2446263002: Fix bad focus state tracking (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/automation_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/automation_custom_bindings.js b/chrome/renderer/resources/extensions/automation_custom_bindings.js
index 76971bdd695f5525d4b649886a4c2be635d8b386..6071abf7cec66c50e48bd34ea5225033a15c1ed5 100644
--- a/chrome/renderer/resources/extensions/automation_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/automation_custom_bindings.js
@@ -25,7 +25,7 @@ var StartCachingAccessibilityTrees =
var AddTreeChangeObserver = nativeAutomationInternal.AddTreeChangeObserver;
var RemoveTreeChangeObserver =
nativeAutomationInternal.RemoveTreeChangeObserver;
-var GetFocus = nativeAutomationInternal.GetFocus;
+var GetFocusNative = nativeAutomationInternal.GetFocus;
var schema = GetSchemaAdditions();
/**
@@ -74,18 +74,23 @@ automationUtil.nextTreeChangeObserverId = 1;
automationUtil.focusedNode = null;
/**
- * Update automationUtil.focusedNode to be the node that currently has focus.
+ * Gets the currently focused AutomationNode.
+ * @return {AutomationNode}
*/
-automationUtil.updateFocusedNode = function() {
- automationUtil.focusedNode = null;
- var focusedNodeInfo = GetFocus(DESKTOP_TREE_ID);
+automationUtil.getFocus = function() {
+ var focusedNodeInfo = GetFocusNative(DESKTOP_TREE_ID);
if (!focusedNodeInfo)
- return;
+ return null;
var tree = AutomationRootNode.getOrCreate(focusedNodeInfo.treeId);
- if (tree) {
- automationUtil.focusedNode =
- privates(tree).impl.get(focusedNodeInfo.nodeId);
- }
+ if (tree)
+ return privates(tree).impl.get(focusedNodeInfo.nodeId);
+};
+
+/**
+ * Update automationUtil.focusedNode to be the node that currently has focus.
+ */
+automationUtil.updateFocusedNode = function() {
+ automationUtil.focusedNode = automationUtil.getFocus();
};
automation.registerCustomHook(function(bindingsAPI) {
@@ -141,8 +146,7 @@ automation.registerCustomHook(function(bindingsAPI) {
});
apiFunctions.setHandleRequest('getFocus', function(callback) {
- automationUtil.updateFocusedNode();
- callback(automationUtil.focusedNode);
+ callback(automationUtil.getFocus());
});
function removeTreeChangeObserver(observer) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698