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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js

Issue 2649373002: Re-land: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Fix presubmit Created 3 years, 11 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
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..2920129c28d0bf7d3f7a54df80674c10a22a6cb9 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
@@ -11,6 +11,7 @@ goog.provide('DesktopAutomationHandler');
goog.require('AutomationObjectConstructorInstaller');
goog.require('BaseAutomationHandler');
goog.require('ChromeVoxState');
+goog.require('CustomAutomationEvent');
goog.require('Stubs');
goog.require('editing.TextEditHandler');
@@ -43,28 +44,48 @@ 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);
+ 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);
AutomationObjectConstructorInstaller.init(node, function() {
chrome.automation.getFocus((function(focus) {
@@ -72,9 +93,8 @@ DesktopAutomationHandler = function(node) {
return;
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));
}.bind(this));
@@ -205,8 +225,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 +253,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 +269,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 +282,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 +290,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 +297,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 +332,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 +394,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 +428,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 +439,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 +468,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 +476,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 +505,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 +530,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);

Powered by Google App Engine
This is Rietveld 408576698