| OLD | NEW |
| 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 Loading... |
| 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; | 281 var isFocusEvent = false; |
| 285 if (eventParams.eventType == schema.EventType.focus) { | 282 if (eventParams.eventType == schema.EventType.focus) { |
| 286 isFocusEvent = true; | 283 isFocusEvent = true; |
| 287 } else if (eventParams.eventType == schema.EventType.blur) { | 284 } else if (eventParams.eventType == schema.EventType.blur) { |
| 285 // 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 |
| 287 // events but otherwise not handle blur events specially. |
| 288 var node = privates(targetTree).impl.get(eventParams.targetID); | 288 var node = privates(targetTree).impl.get(eventParams.targetID); |
| 289 if (node == node.root) | 289 if (node == node.root) |
| 290 isFocusEvent = true; | 290 isFocusEvent = true; |
| 291 } else if (eventParams.eventType == schema.EventType.mediaStartedPlaying || |
| 292 eventParams.eventType == schema.EventType.mediaStoppedPlaying) { |
| 293 // These events are global to the tree. |
| 294 eventParams.targetID = privates(targetTree).impl.id; |
| 291 } | 295 } |
| 292 | 296 |
| 293 // When we get a focus event, ignore the actual event target, and instead | 297 // When we get a focus event, ignore the actual event target, and instead |
| 294 // check what node has focus globally. If that represents a focus change, | 298 // check what node has focus globally. If that represents a focus change, |
| 295 // fire a focus event on the correct target. | 299 // fire a focus event on the correct target. |
| 296 if (isFocusEvent) { | 300 if (isFocusEvent) { |
| 297 var previousFocusedNode = automationUtil.focusedNode; | 301 var previousFocusedNode = automationUtil.focusedNode; |
| 298 automationUtil.updateFocusedNode(); | 302 automationUtil.updateFocusedNode(); |
| 299 if (automationUtil.focusedNode && | 303 if (automationUtil.focusedNode && |
| 300 automationUtil.focusedNode == previousFocusedNode) { | 304 automationUtil.focusedNode == previousFocusedNode) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 358 |
| 355 var binding = automation.generate(); | 359 var binding = automation.generate(); |
| 356 // Add additional accessibility bindings not specified in the automation IDL. | 360 // Add additional accessibility bindings not specified in the automation IDL. |
| 357 // Accessibility and automation share some APIs (see | 361 // Accessibility and automation share some APIs (see |
| 358 // ui/accessibility/ax_enums.idl). | 362 // ui/accessibility/ax_enums.idl). |
| 359 forEach(schema, function(k, v) { | 363 forEach(schema, function(k, v) { |
| 360 binding[k] = v; | 364 binding[k] = v; |
| 361 }); | 365 }); |
| 362 | 366 |
| 363 exports.$set('binding', binding); | 367 exports.$set('binding', binding); |
| OLD | NEW |