| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
|
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
|
| index 2b56429048988d69a4848ee11ffe301adb45f3d3..de18866b7b36d42d906cb2a7ea750798a68b3af5 100644
|
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
|
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js
|
| @@ -8,9 +8,9 @@
|
|
|
| goog.provide('DesktopAutomationHandler');
|
|
|
| -goog.require('AutomationObjectConstructorInstaller');
|
| goog.require('BaseAutomationHandler');
|
| goog.require('ChromeVoxState');
|
| +goog.require('CustomAutomationEvent');
|
| goog.require('Stubs');
|
| goog.require('editing.TextEditHandler');
|
|
|
| @@ -43,41 +43,58 @@ DesktopAutomationHandler = function(node) {
|
| */
|
| this.lastValueChanged_ = new Date(0);
|
|
|
| - var e = EventType;
|
| - this.addListener_(e.activedescendantchanged, this.onActiveDescendantChanged);
|
| - this.addListener_(e.alert, this.onAlert);
|
| - this.addListener_(e.ariaAttributeChanged, this.onAriaAttributeChanged);
|
| - this.addListener_(e.autocorrectionOccured, this.onEventIfInRange);
|
| - this.addListener_(e.checkedStateChanged, this.onCheckedStateChanged);
|
| - this.addListener_(e.childrenChanged, this.onActiveDescendantChanged);
|
| - this.addListener_(e.expandedChanged, this.onEventIfInRange);
|
| - this.addListener_(e.focus, this.onFocus);
|
| - this.addListener_(e.hover, this.onHover);
|
| - this.addListener_(e.invalidStatusChanged, this.onEventIfInRange);
|
| - this.addListener_(e.loadComplete, this.onLoadComplete);
|
| - this.addListener_(e.menuEnd, this.onMenuEnd);
|
| - this.addListener_(e.menuListItemSelected, this.onEventIfSelected);
|
| - this.addListener_(e.menuStart, this.onMenuStart);
|
| - this.addListener_(e.rowCollapsed, this.onEventIfInRange);
|
| - this.addListener_(e.rowExpanded, this.onEventIfInRange);
|
| - this.addListener_(e.scrollPositionChanged, this.onScrollPositionChanged);
|
| - this.addListener_(e.selection, this.onSelection);
|
| - this.addListener_(e.textChanged, this.onTextChanged);
|
| - this.addListener_(e.textSelectionChanged, this.onTextSelectionChanged);
|
| - this.addListener_(e.valueChanged, this.onValueChanged);
|
| -
|
| - AutomationObjectConstructorInstaller.init(node, function() {
|
| - chrome.automation.getFocus((function(focus) {
|
| - if (ChromeVoxState.instance.mode != ChromeVoxMode.FORCE_NEXT)
|
| - return;
|
| -
|
| - if (focus) {
|
| - this.onFocus(
|
| - new chrome.automation.AutomationEvent(
|
| - EventType.focus, focus, 'page'));
|
| - }
|
| - }).bind(this));
|
| - }.bind(this));
|
| + this.addListener_(EventType.ACTIVEDESCENDANTCHANGED,
|
| + this.onActiveDescendantChanged);
|
| + this.addListener_(EventType.ALERT,
|
| + this.onAlert);
|
| + this.addListener_(EventType.ARIA_ATTRIBUTE_CHANGED,
|
| + this.onAriaAttributeChanged);
|
| + this.addListener_(EventType.AUTOCORRECTION_OCCURED,
|
| + this.onEventIfInRange);
|
| + this.addListener_(EventType.CHECKED_STATE_CHANGED,
|
| + this.onCheckedStateChanged);
|
| + this.addListener_(EventType.CHILDREN_CHANGED,
|
| + this.onActiveDescendantChanged);
|
| + this.addListener_(EventType.EXPANDED_CHANGED,
|
| + this.onEventIfInRange);
|
| + this.addListener_(EventType.FOCUS,
|
| + this.onFocus);
|
| + this.addListener_(EventType.HOVER,
|
| + this.onHover);
|
| + this.addListener_(EventType.INVALID_STATUS_CHANGED,
|
| + this.onEventIfInRange);
|
| + this.addListener_(EventType.LOAD_COMPLETE,
|
| + this.onLoadComplete);
|
| + this.addListener_(EventType.MENU_END,
|
| + this.onMenuEnd);
|
| + this.addListener_(EventType.MENU_LIST_ITEM_SELECTED,
|
| + this.onEventIfSelected);
|
| + this.addListener_(EventType.MENU_START,
|
| + this.onMenuStart);
|
| + this.addListener_(EventType.ROW_COLLAPSED,
|
| + this.onEventIfInRange);
|
| + this.addListener_(EventType.ROW_EXPANDED,
|
| + this.onEventIfInRange);
|
| + this.addListener_(EventType.SCROLL_POSITION_CHANGED,
|
| + this.onScrollPositionChanged);
|
| + this.addListener_(EventType.SELECTION,
|
| + this.onSelection);
|
| + this.addListener_(EventType.TEXT_CHANGED,
|
| + this.onTextChanged);
|
| + this.addListener_(EventType.TEXT_SELECTION_CHANGED,
|
| + this.onTextSelectionChanged);
|
| + this.addListener_(EventType.VALUE_CHANGED,
|
| + this.onValueChanged);
|
| +
|
| + chrome.automation.getFocus((function(focus) {
|
| + if (ChromeVoxState.instance.mode != ChromeVoxMode.FORCE_NEXT)
|
| + return;
|
| +
|
| + if (focus) {
|
| + var event = new CustomAutomationEvent(EventType.FOCUS, focus, 'page');
|
| + this.onFocus(event);
|
| + }
|
| + }).bind(this));
|
| };
|
|
|
| /**
|
| @@ -205,8 +222,9 @@ DesktopAutomationHandler.prototype = {
|
| onActiveDescendantChanged: function(evt) {
|
| if (!evt.target.activeDescendant || !evt.target.state.focused)
|
| return;
|
| - this.onEventDefault(new chrome.automation.AutomationEvent(
|
| - EventType.focus, evt.target.activeDescendant, evt.eventFrom));
|
| + var event = new CustomAutomationEvent(
|
| + EventType.FOCUS, evt.target.activeDescendant, evt.eventFrom);
|
| + this.onEventDefault(event);
|
| },
|
|
|
| /**
|
| @@ -232,9 +250,9 @@ DesktopAutomationHandler.prototype = {
|
| return;
|
|
|
| Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH);
|
| - this.onEventIfInRange(
|
| - new chrome.automation.AutomationEvent(
|
| - EventType.checkedStateChanged, evt.target, evt.eventFrom));
|
| + var event = new CustomAutomationEvent(
|
| + EventType.CHECKED_STATE_CHANGED, evt.target, evt.eventFrom);
|
| + this.onEventIfInRange(event);
|
| },
|
|
|
| /**
|
| @@ -248,7 +266,7 @@ DesktopAutomationHandler.prototype = {
|
| var node = evt.target;
|
|
|
| // Discard focus events on embeddedObject.
|
| - if (node.role == RoleType.embeddedObject)
|
| + if (node.role == RoleType.EMBEDDED_OBJECT)
|
| return;
|
|
|
| this.createTextEditHandlerIfNeeded_(evt.target);
|
| @@ -261,7 +279,6 @@ DesktopAutomationHandler.prototype = {
|
| return;
|
|
|
| var root = AutomationUtil.getTopLevelRoot(node.root);
|
| -
|
| // If we're crossing out of a root, save it in case it needs recovering.
|
| var prevRange = ChromeVoxState.instance.currentRange;
|
| var prevNode = prevRange ? prevRange.start.node : null;
|
| @@ -270,7 +287,6 @@ DesktopAutomationHandler.prototype = {
|
| if (prevRoot && prevRoot !== root)
|
| ChromeVoxState.instance.focusRecoveryMap.set(prevRoot, prevRange);
|
| }
|
| -
|
| // If a previous node was saved for this focus, restore it.
|
| var savedRange = ChromeVoxState.instance.focusRecoveryMap.get(root);
|
| ChromeVoxState.instance.focusRecoveryMap.delete(root);
|
| @@ -278,9 +294,8 @@ DesktopAutomationHandler.prototype = {
|
| ChromeVoxState.instance.navigateToRange(savedRange, false);
|
| return;
|
| }
|
| -
|
| - this.onEventDefault(new chrome.automation.AutomationEvent(
|
| - EventType.focus, node, evt.eventFrom));
|
| + var event = new CustomAutomationEvent(EventType.FOCUS, node, evt.eventFrom);
|
| + this.onEventDefault(event);
|
| },
|
|
|
| /**
|
| @@ -314,7 +329,7 @@ DesktopAutomationHandler.prototype = {
|
| return;
|
|
|
| var o = new Output();
|
| - if (focus.role == RoleType.rootWebArea) {
|
| + if (focus.role == RoleType.ROOT_WEB_AREA) {
|
| // Restore to previous position.
|
| var url = focus.docUrl;
|
| url = url.substring(0, url.indexOf('#')) || url;
|
| @@ -376,9 +391,9 @@ DesktopAutomationHandler.prototype = {
|
|
|
| // Sync the ChromeVox range to the editable, if a selection exists.
|
| var anchorObject = evt.target.root.anchorObject;
|
| - var anchorOffset = evt.target.root.anchorOffset;
|
| + var anchorOffset = evt.target.root.anchorOffset || 0;
|
| var focusObject = evt.target.root.focusObject;
|
| - var focusOffset = evt.target.root.focusOffset;
|
| + var focusOffset = evt.target.root.focusOffset || 0;
|
| if (anchorObject && focusObject) {
|
| var selectedRange = new cursors.Range(
|
| new cursors.WrappingCursor(anchorObject, anchorOffset),
|
| @@ -410,7 +425,7 @@ DesktopAutomationHandler.prototype = {
|
|
|
| var t = evt.target;
|
| if (t.state.focused ||
|
| - t.root.role == RoleType.desktop ||
|
| + t.root.role == RoleType.DESKTOP ||
|
| AutomationUtil.isDescendantOf(
|
| ChromeVoxState.instance.currentRange.start.node, t)) {
|
| if (new Date() - this.lastValueChanged_ <=
|
| @@ -421,7 +436,7 @@ DesktopAutomationHandler.prototype = {
|
|
|
| var output = new Output();
|
|
|
| - if (t.root.role == RoleType.desktop)
|
| + if (t.root.role == RoleType.DESKTOP)
|
| output.withQueueMode(cvox.QueueMode.FLUSH);
|
|
|
| output.format('$value', evt.target).go();
|
| @@ -450,7 +465,7 @@ DesktopAutomationHandler.prototype = {
|
| chrome.automation.getFocus(function(focus) {
|
| // Desktop tabs get "selection" when there's a focused webview during tab
|
| // switching.
|
| - if (focus.role == RoleType.webView && evt.target.role == RoleType.tab) {
|
| + if (focus.role == RoleType.WEB_VIEW && evt.target.role == RoleType.TAB) {
|
| ChromeVoxState.instance.setCurrentRange(
|
| cursors.Range.fromNode(focus.firstChild));
|
| return;
|
| @@ -458,9 +473,9 @@ DesktopAutomationHandler.prototype = {
|
|
|
| // Some cases (e.g. in overview mode), require overriding the assumption
|
| // that focus is an ancestor of a selection target.
|
| - var override = evt.target.role == RoleType.menuItem ||
|
| + var override = evt.target.role == RoleType.MENU_ITEM ||
|
| (evt.target.root == focus.root &&
|
| - focus.root.role == RoleType.desktop);
|
| + focus.root.role == RoleType.DESKTOP);
|
| Output.forceModeForNextSpeechUtterance(cvox.QueueMode.FLUSH);
|
| if (override || AutomationUtil.isDescendantOf(evt.target, focus))
|
| this.onEventDefault(evt);
|
| @@ -487,9 +502,8 @@ DesktopAutomationHandler.prototype = {
|
| // after you close them.
|
| chrome.automation.getFocus(function(focus) {
|
| if (focus) {
|
| - this.onFocus(
|
| - new chrome.automation.AutomationEvent(
|
| - EventType.focus, focus, 'page'));
|
| + var event = new CustomAutomationEvent(EventType.FOCUS, focus, 'page');
|
| + this.onFocus(event);
|
| }
|
| }.bind(this));
|
| },
|
| @@ -513,7 +527,7 @@ DesktopAutomationHandler.prototype = {
|
| shouldOutput_: function(evt) {
|
| var mode = ChromeVoxState.instance.mode;
|
| // Only output desktop rooted nodes or web nodes for next engine modes.
|
| - return evt.target.root.role == RoleType.desktop ||
|
| + return evt.target.root.role == RoleType.DESKTOP ||
|
| (mode == ChromeVoxMode.NEXT ||
|
| mode == ChromeVoxMode.FORCE_NEXT ||
|
| mode == ChromeVoxMode.CLASSIC_COMPAT);
|
|
|