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

Side by Side Diff: chrome/renderer/resources/extensions/automation_custom_bindings.js

Issue 2575233002: Always retarget blur events to the root of the focused node (Closed)
Patch Set: Fix test. Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Custom bindings for the automation API. 5 // Custom bindings for the automation API.
6 var AutomationNode = require('automationNode').AutomationNode; 6 var AutomationNode = require('automationNode').AutomationNode;
7 var AutomationRootNode = require('automationNode').AutomationRootNode; 7 var AutomationRootNode = require('automationNode').AutomationRootNode;
8 var automation = require('binding').Binding.create('automation'); 8 var automation = require('binding').Binding.create('automation');
9 var automationInternal = 9 var automationInternal =
10 require('binding').Binding.create('automationInternal').generate(); 10 require('binding').Binding.create('automationInternal').generate();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return privates(tree).impl.get(focusedNodeInfo.nodeId); 86 return privates(tree).impl.get(focusedNodeInfo.nodeId);
87 }; 87 };
88 88
89 /** 89 /**
90 * Update automationUtil.focusedNode to be the node that currently has focus. 90 * Update automationUtil.focusedNode to be the node that currently has focus.
91 */ 91 */
92 automationUtil.updateFocusedNode = function() { 92 automationUtil.updateFocusedNode = function() {
93 automationUtil.focusedNode = automationUtil.getFocus(); 93 automationUtil.focusedNode = automationUtil.getFocus();
94 }; 94 };
95 95
96 /**
97 * Updates the focus on blur.
98 */
99 automationUtil.updateFocusedNodeOnBlur = function() {
100 var focus = automationUtil.getFocus();
101 automationUtil.focusedNode = focus ? focus.root : null;
102 };
103
96 automation.registerCustomHook(function(bindingsAPI) { 104 automation.registerCustomHook(function(bindingsAPI) {
97 var apiFunctions = bindingsAPI.apiFunctions; 105 var apiFunctions = bindingsAPI.apiFunctions;
98 106
99 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj. 107 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj.
100 apiFunctions.setHandleRequest('getTree', function getTree(tabID, callback) { 108 apiFunctions.setHandleRequest('getTree', function getTree(tabID, callback) {
101 var routingID = GetRoutingID(); 109 var routingID = GetRoutingID();
102 StartCachingAccessibilityTrees(); 110 StartCachingAccessibilityTrees();
103 111
104 // enableTab() ensures the renderer for the active or specified tab has 112 // enableTab() ensures the renderer for the active or specified tab has
105 // accessibility enabled, and fetches its ax tree id to use as 113 // accessibility enabled, and fetches its ax tree id to use as
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 288
281 var isFocusEvent = false; 289 var isFocusEvent = false;
282 if (eventParams.eventType == schema.EventType.focus) { 290 if (eventParams.eventType == schema.EventType.focus) {
283 isFocusEvent = true; 291 isFocusEvent = true;
284 } else if (eventParams.eventType == schema.EventType.blur) { 292 } else if (eventParams.eventType == schema.EventType.blur) {
285 // Work around an issue where Chrome sends us 'blur' events on the 293 // Work around an issue where Chrome sends us 'blur' events on the
286 // root node when nothing has focus, we need to treat those as focus 294 // root node when nothing has focus, we need to treat those as focus
287 // events but otherwise not handle blur events specially. 295 // events but otherwise not handle blur events specially.
288 var node = privates(targetTree).impl.get(eventParams.targetID); 296 var node = privates(targetTree).impl.get(eventParams.targetID);
289 if (node == node.root) 297 if (node == node.root)
290 isFocusEvent = true; 298 automationUtil.updateFocusedNodeOnBlur();
291 } else if (eventParams.eventType == schema.EventType.mediaStartedPlaying || 299 } else if (eventParams.eventType == schema.EventType.mediaStartedPlaying ||
292 eventParams.eventType == schema.EventType.mediaStoppedPlaying) { 300 eventParams.eventType == schema.EventType.mediaStoppedPlaying) {
293 // These events are global to the tree. 301 // These events are global to the tree.
294 eventParams.targetID = privates(targetTree).impl.id; 302 eventParams.targetID = privates(targetTree).impl.id;
295 } 303 }
296 304
297 // When we get a focus event, ignore the actual event target, and instead 305 // When we get a focus event, ignore the actual event target, and instead
298 // check what node has focus globally. If that represents a focus change, 306 // check what node has focus globally. If that represents a focus change,
299 // fire a focus event on the correct target. 307 // fire a focus event on the correct target.
300 if (isFocusEvent) { 308 if (isFocusEvent) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 366
359 var binding = automation.generate(); 367 var binding = automation.generate();
360 // Add additional accessibility bindings not specified in the automation IDL. 368 // Add additional accessibility bindings not specified in the automation IDL.
361 // Accessibility and automation share some APIs (see 369 // Accessibility and automation share some APIs (see
362 // ui/accessibility/ax_enums.idl). 370 // ui/accessibility/ax_enums.idl).
363 forEach(schema, function(k, v) { 371 forEach(schema, function(k, v) {
364 binding[k] = v; 372 binding[k] = v;
365 }); 373 });
366 374
367 exports.$set('binding', binding); 375 exports.$set('binding', binding);
OLDNEW
« 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