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

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

Issue 2479563004: automation_custom_bindings needs to handle blur events too. (Closed)
Patch Set: Only handle blur events on root Created 4 years, 1 month 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 /** 272 /**
273 * Dispatch accessibility events fired on individual nodes to its 273 * Dispatch accessibility events fired on individual nodes to its
274 * corresponding AutomationNode. Handle focus events specially 274 * corresponding AutomationNode. Handle focus events specially
275 * (see below). 275 * (see below).
276 */ 276 */
277 automationInternal.onAccessibilityEvent.addListener(function(eventParams) { 277 automationInternal.onAccessibilityEvent.addListener(function(eventParams) {
278 var id = eventParams.treeID; 278 var id = eventParams.treeID;
279 var targetTree = AutomationRootNode.getOrCreate(id); 279 var targetTree = AutomationRootNode.getOrCreate(id);
280 280
281 // Work around an issue where Chrome sends us 'blur' events on the
282 // root node when nothing has focus, we need to treat those as focus
283 // events but otherwise not handle blur events specially.
284 var isFocusEvent = false;
285 if (eventParams.eventType == schema.EventType.focus) {
286 isFocusEvent = true;
287 } else if (eventParams.eventType == schema.EventType.blur) {
288 var node = privates(targetTree).impl.get(eventParams.targetID);
289 if (node == node.root)
290 isFocusEvent = true;
291 }
292
281 // When we get a focus event, ignore the actual event target, and instead 293 // When we get a focus event, ignore the actual event target, and instead
282 // check what node has focus globally. If that represents a focus change, 294 // check what node has focus globally. If that represents a focus change,
283 // fire a focus event on the correct target. 295 // fire a focus event on the correct target.
284 if (eventParams.eventType == schema.EventType.focus) { 296 if (isFocusEvent) {
285 var previousFocusedNode = automationUtil.focusedNode; 297 var previousFocusedNode = automationUtil.focusedNode;
286 automationUtil.updateFocusedNode(); 298 automationUtil.updateFocusedNode();
287 if (automationUtil.focusedNode && 299 if (automationUtil.focusedNode &&
288 automationUtil.focusedNode == previousFocusedNode) { 300 automationUtil.focusedNode == previousFocusedNode) {
289 return; 301 return;
290 } 302 }
291 303
292 if (automationUtil.focusedNode) { 304 if (automationUtil.focusedNode) {
293 targetTree = automationUtil.focusedNode.root; 305 targetTree = automationUtil.focusedNode.root;
294 eventParams.treeID = privates(targetTree).impl.treeID; 306 eventParams.treeID = privates(targetTree).impl.treeID;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 349
338 var binding = automation.generate(); 350 var binding = automation.generate();
339 // Add additional accessibility bindings not specified in the automation IDL. 351 // Add additional accessibility bindings not specified in the automation IDL.
340 // Accessibility and automation share some APIs (see 352 // Accessibility and automation share some APIs (see
341 // ui/accessibility/ax_enums.idl). 353 // ui/accessibility/ax_enums.idl).
342 forEach(schema, function(k, v) { 354 forEach(schema, function(k, v) {
343 binding[k] = v; 355 binding[k] = v;
344 }); 356 });
345 357
346 exports.$set('binding', binding); 358 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