Commit 613ce4af authored by David Tseng's avatar David Tseng Committed by Commit Bot

Remove |mode| from ChromeVox

ChromeVox Classic is no longer available to users.
This allows us to remove some complexity surrounding the idea of the various modes for ChromeVox (classic, next, etc).

This change mostly is meant to be cleanup, but it also addresses some bugs. Namely, we unintentionally relied upon onModeChanged to trigger specific behaviors such as installing command handlers. This made sense when mode changes had to be supported. However, with this in a limbo state now that there is no classic mode, we can no longer invoke commands with an empty desktop.


Bug: 
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ic9270ab7e3cc3ba734f21bc84c00738bb0d43e56
Reviewed-on: https://chromium-review.googlesource.com/825169
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524343}
parent bdfd3647
...@@ -148,7 +148,6 @@ chromevox_modules = [ ...@@ -148,7 +148,6 @@ chromevox_modules = [
"cvox2/background/panel_menu.js", "cvox2/background/panel_menu.js",
"cvox2/background/panel_menu_item.js", "cvox2/background/panel_menu_item.js",
"cvox2/background/recovery_strategy.js", "cvox2/background/recovery_strategy.js",
"cvox2/background/tabs_automation_handler.js",
"cvox2/background/tree_walker.js", "cvox2/background/tree_walker.js",
"cvox2/background/tutorial.js", "cvox2/background/tutorial.js",
"cvox2/injected/keyboard_handler.js", "cvox2/injected/keyboard_handler.js",
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
goog.provide('cvox.TabsApiHandler'); goog.provide('cvox.TabsApiHandler');
goog.require('TabsAutomationHandler');
goog.require('cvox.AbstractEarcons'); goog.require('cvox.AbstractEarcons');
goog.require('cvox.AbstractTts'); goog.require('cvox.AbstractTts');
goog.require('cvox.BrailleInterface'); goog.require('cvox.BrailleInterface');
...@@ -73,9 +72,6 @@ cvox.TabsApiHandler.prototype = { ...@@ -73,9 +72,6 @@ cvox.TabsApiHandler.prototype = {
cvox.NavBraille.fromText(this.msg_('chrome_tab_created'))); cvox.NavBraille.fromText(this.msg_('chrome_tab_created')));
} }
cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_OPEN); cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_OPEN);
if (tab) {
this.refreshAutomationHandler_(tab.id);
}
}, },
/** /**
...@@ -115,7 +111,6 @@ cvox.TabsApiHandler.prototype = { ...@@ -115,7 +111,6 @@ cvox.TabsApiHandler.prototype = {
this.msg_('chrome_tab_selected', [title]))); this.msg_('chrome_tab_selected', [title])));
} }
cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_SELECT); cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_SELECT);
this.refreshAutomationHandler_(tab.id);
}.bind(this)); }.bind(this));
}, },
...@@ -161,7 +156,6 @@ cvox.TabsApiHandler.prototype = { ...@@ -161,7 +156,6 @@ cvox.TabsApiHandler.prototype = {
cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.PAGE_FINISH_LOADING); cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.PAGE_FINISH_LOADING);
this.cancelPageLoadTimer_(); this.cancelPageLoadTimer_();
} }
this.refreshAutomationHandler_(tabId);
}.bind(this)); }.bind(this));
}, },
...@@ -193,29 +187,10 @@ cvox.TabsApiHandler.prototype = { ...@@ -193,29 +187,10 @@ cvox.TabsApiHandler.prototype = {
cvox.NavBraille.fromText(this.msg_(msgId, [title]))); cvox.NavBraille.fromText(this.msg_(msgId, [title])));
} }
cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_SELECT); cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_SELECT);
this.refreshAutomationHandler_(tab.id);
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
/**
* Installs a new automation handler for the given tab.
* @param {number} tabId
* @private
*/
refreshAutomationHandler_: function(tabId) {
if (!cvox.ChromeVox.isMac ||
ChromeVoxState.instance.mode == ChromeVoxMode.CLASSIC)
return;
chrome.automation.getTree(tabId, function(node) {
if (this.handler_)
this.handler_.removeAllListeners();
this.handler_ = new TabsAutomationHandler(node);
}.bind(this));
},
/** /**
* The chrome.tabs API doesn't always fire an onUpdated event when a * The chrome.tabs API doesn't always fire an onUpdated event when a
* page finishes loading, so we poll it. * page finishes loading, so we poll it.
......
...@@ -25,8 +25,6 @@ BackgroundTest.prototype = { ...@@ -25,8 +25,6 @@ BackgroundTest.prototype = {
window.RoleType = chrome.automation.RoleType; window.RoleType = chrome.automation.RoleType;
window.doCmd = this.doCmd; window.doCmd = this.doCmd;
// Reset notifications so only explicit mode changes can cause them to trigger.
Notifications.reset();
this.forceContextualLastOutput(); this.forceContextualLastOutput();
}, },
...@@ -514,78 +512,6 @@ TEST_F('BackgroundTest', 'DISABLED_ActiveOrInactive', function() { ...@@ -514,78 +512,6 @@ TEST_F('BackgroundTest', 'DISABLED_ActiveOrInactive', function() {
}); });
}); });
TEST_F('BackgroundTest', 'ModeSwitching', function() {
this.runWithLoadedTree('<button></button>', function(root) {
var fakeDesktop = {};
fakeDesktop.role = 'desktop';
fakeDesktop.root = fakeDesktop;
var fakeWebRoot = {};
fakeWebRoot.root = fakeWebRoot;
fakeWebRoot.parent = fakeDesktop;
fakeWebRoot.role = RoleType.ROOT_WEB_AREA;
fakeWebRoot.makeVisible = function() {};
fakeWebRoot.unclippedLocation = {left: 1, top: 1, width: 1, height: 1};
var fakeSubRoot = {};
fakeSubRoot.root = fakeSubRoot;
fakeSubRoot.parent = fakeWebRoot;
fakeSubRoot.role = RoleType.ROOT_WEB_AREA;
fakeSubRoot.makeVisible = function() {};
fakeSubRoot.unclippedLocation = {left: 1, top: 1, width: 1, height: 1};
var bk = ChromeVoxState.instance;
// Tests default to force next mode.
assertEquals('force_next', bk.mode);
// Force next mode stays set regardless of where the range lands.
fakeWebRoot.docUrl = 'http://google.com';
bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
assertEquals('force_next', bk.mode);
// Empty urls occur before document load or when root is desktop.
fakeWebRoot.docUrl = '';
bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
assertEquals('force_next', bk.mode);
// Verify force next -> classic compat switching.
localStorage['useClassic'] = true;
fakeWebRoot.docUrl = 'chrome://foobar';
bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
assertEquals('classic_compat', bk.mode);
// Classic compat -> classic.
fakeWebRoot.docUrl = 'http://google.com';
bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
assertEquals('classic', bk.mode);
// Ensure we switch to classic compat if our current range has focused
// state set and is not in web content.
assertTrue(root.parent.state.focused);
bk.setCurrentRange(cursors.Range.fromNode(root.parent));
assertEquals('classic_compat', bk.mode);
// And back to classic.
bk.setCurrentRange(cursors.Range.fromNode(root));
assertEquals('classic', bk.mode);
// Now, verify mode switching uses the top level root.
fakeWebRoot.docUrl = 'http://google.com/#chromevox_next_test';
fakeSubRoot.docUrl = 'http://chromevox.com';
bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
assertEquals('next', bk.mode);
// Next compat switching.
localStorage['useClassic'] = false;
fakeWebRoot.docUrl = 'http://docs.google.com/document/#123123';
bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
assertEquals('force_next', bk.mode);
// And, back to force next.
fakeWebRoot.docUrl = 'http://docs.google.com/form/123';
bk.setCurrentRange(cursors.Range.fromNode(fakeWebRoot));
assertEquals('force_next', bk.mode);
}.bind(this));
});
TEST_F('BackgroundTest', 'ShouldNotFocusIframe', function() { TEST_F('BackgroundTest', 'ShouldNotFocusIframe', function() {
this.runWithLoadedTree( function() {/*! this.runWithLoadedTree( function() {/*!
<iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe> <iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe>
......
...@@ -8,24 +8,12 @@ ...@@ -8,24 +8,12 @@
* object and to facilitate mocking for tests. * object and to facilitate mocking for tests.
*/ */
goog.provide('ChromeVoxMode');
goog.provide('ChromeVoxState'); goog.provide('ChromeVoxState');
goog.provide('ChromeVoxStateObserver'); goog.provide('ChromeVoxStateObserver');
goog.require('cursors.Cursor'); goog.require('cursors.Cursor');
goog.require('cursors.Range'); goog.require('cursors.Range');
/**
* All possible modes ChromeVox can run.
* @enum {string}
*/
ChromeVoxMode = {
CLASSIC: 'classic',
CLASSIC_COMPAT: 'classic_compat',
NEXT: 'next',
FORCE_NEXT: 'force_next'
};
/** /**
* An interface implemented by objects that want to observe ChromeVox state * An interface implemented by objects that want to observe ChromeVox state
* changes. * changes.
...@@ -67,19 +55,6 @@ ChromeVoxState.backgroundTts; ...@@ -67,19 +55,6 @@ ChromeVoxState.backgroundTts;
ChromeVoxState.isReadingContinuously; ChromeVoxState.isReadingContinuously;
ChromeVoxState.prototype = { ChromeVoxState.prototype = {
/** @type {ChromeVoxMode} */
get mode() {
return this.getMode();
},
/**
* @return {ChromeVoxMode} The current mode.
* @protected
*/
getMode: function() {
return ChromeVoxMode.NEXT;
},
/** @type {cursors.Range} */ /** @type {cursors.Range} */
get currentRange() { get currentRange() {
return this.getCurrentRange(); return this.getCurrentRange();
......
...@@ -12,6 +12,7 @@ goog.require('ChromeVoxState'); ...@@ -12,6 +12,7 @@ goog.require('ChromeVoxState');
goog.require('CustomAutomationEvent'); goog.require('CustomAutomationEvent');
goog.require('Output'); goog.require('Output');
goog.require('cvox.ChromeVoxBackground'); goog.require('cvox.ChromeVoxBackground');
goog.require('cvox.ChromeVoxKbHandler');
goog.scope(function() { goog.scope(function() {
var AutomationEvent = chrome.automation.AutomationEvent; var AutomationEvent = chrome.automation.AutomationEvent;
...@@ -39,7 +40,7 @@ CommandHandler.onCommand = function(command) { ...@@ -39,7 +40,7 @@ CommandHandler.onCommand = function(command) {
ChromeVoxState.instance.setCurrentRange(null); ChromeVoxState.instance.setCurrentRange(null);
}); });
// These commands don't require a current range and work in all modes. // These commands don't require a current range.
switch (command) { switch (command) {
case 'speakTimeAndDate': case 'speakTimeAndDate':
chrome.automation.getDesktop(function(d) { chrome.automation.getDesktop(function(d) {
...@@ -237,10 +238,6 @@ CommandHandler.onCommand = function(command) { ...@@ -237,10 +238,6 @@ CommandHandler.onCommand = function(command) {
if (!ChromeVoxState.instance.currentRange_) if (!ChromeVoxState.instance.currentRange_)
return true; return true;
// Next/classic compat commands hereafter.
if (ChromeVoxState.instance.mode == ChromeVoxMode.CLASSIC)
return true;
var current = ChromeVoxState.instance.currentRange_; var current = ChromeVoxState.instance.currentRange_;
var dir = Dir.FORWARD; var dir = Dir.FORWARD;
var pred = null; var pred = null;
...@@ -812,24 +809,6 @@ CommandHandler.onCommand = function(command) { ...@@ -812,24 +809,6 @@ CommandHandler.onCommand = function(command) {
return false; return false;
}; };
/**
* React to mode changes.
* @param {ChromeVoxMode} newMode
* @param {ChromeVoxMode?} oldMode
*/
CommandHandler.onModeChanged = function(newMode, oldMode) {
// Previously uninitialized.
if (!oldMode)
cvox.ChromeVoxKbHandler.commandHandler = CommandHandler.onCommand;
var hasListener =
chrome.commands.onCommand.hasListener(CommandHandler.onCommand);
if (newMode == ChromeVoxMode.CLASSIC && hasListener)
chrome.commands.onCommand.removeListener(CommandHandler.onCommand);
else if (newMode == ChromeVoxMode.CLASSIC && !hasListener)
chrome.commands.onCommand.addListener(CommandHandler.onCommand);
};
/** /**
* Increase or decrease a speech property and make an announcement. * Increase or decrease a speech property and make an announcement.
* @param {string} propertyName The name of the property to change. * @param {string} propertyName The name of the property to change.
...@@ -927,9 +906,9 @@ CommandHandler.viewGraphicAsBraille_ = function(current) { ...@@ -927,9 +906,9 @@ CommandHandler.viewGraphicAsBraille_ = function(current) {
/** /**
* Performs global initialization. * Performs global initialization.
* @private
*/ */
CommandHandler.init_ = function() { CommandHandler.init = function() {
cvox.ChromeVoxKbHandler.commandHandler = CommandHandler.onCommand;
var firstRunId = 'jdgcneonijmofocbhmijhacgchbihela'; var firstRunId = 'jdgcneonijmofocbhmijhacgchbihela';
chrome.runtime.onMessageExternal.addListener(function( chrome.runtime.onMessageExternal.addListener(function(
request, sender, sendResponse) { request, sender, sendResponse) {
...@@ -955,6 +934,4 @@ CommandHandler.init_ = function() { ...@@ -955,6 +934,4 @@ CommandHandler.init_ = function() {
}); });
}; };
CommandHandler.init_();
}); // goog.scope }); // goog.scope
...@@ -81,9 +81,6 @@ DesktopAutomationHandler = function(node) { ...@@ -81,9 +81,6 @@ DesktopAutomationHandler = function(node) {
AutomationObjectConstructorInstaller.init(node, function() { AutomationObjectConstructorInstaller.init(node, function() {
chrome.automation.getFocus( chrome.automation.getFocus(
(function(focus) { (function(focus) {
if (ChromeVoxState.instance.mode != ChromeVoxMode.FORCE_NEXT)
return;
if (focus) { if (focus) {
var event = var event =
new CustomAutomationEvent(EventType.FOCUS, focus, 'page'); new CustomAutomationEvent(EventType.FOCUS, focus, 'page');
...@@ -137,9 +134,6 @@ DesktopAutomationHandler.prototype = { ...@@ -137,9 +134,6 @@ DesktopAutomationHandler.prototype = {
ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(node)); ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(node));
if (!this.shouldOutput_(evt))
return;
// Don't output if focused node hasn't changed. // Don't output if focused node hasn't changed.
if (prevRange && evt.type == 'focus' && if (prevRange && evt.type == 'focus' &&
ChromeVoxState.instance.currentRange.equals(prevRange)) ChromeVoxState.instance.currentRange.equals(prevRange))
...@@ -162,9 +156,6 @@ DesktopAutomationHandler.prototype = { ...@@ -162,9 +156,6 @@ DesktopAutomationHandler.prototype = {
* @param {!AutomationEvent} evt * @param {!AutomationEvent} evt
*/ */
onEventIfInRange: function(evt) { onEventIfInRange: function(evt) {
if (!this.shouldOutput_(evt))
return;
var prev = ChromeVoxState.instance.currentRange; var prev = ChromeVoxState.instance.currentRange;
if (prev.contentEquals(cursors.Range.fromNode(evt.target)) || if (prev.contentEquals(cursors.Range.fromNode(evt.target)) ||
evt.target.state.focused) { evt.target.state.focused) {
...@@ -245,9 +236,6 @@ DesktopAutomationHandler.prototype = { ...@@ -245,9 +236,6 @@ DesktopAutomationHandler.prototype = {
*/ */
onAlert: function(evt) { onAlert: function(evt) {
var node = evt.target; var node = evt.target;
if (!node || !this.shouldOutput_(evt))
return;
var range = cursors.Range.fromNode(node); var range = cursors.Range.fromNode(node);
new Output().withSpeechAndBraille(range, null, evt.type).go(); new Output().withSpeechAndBraille(range, null, evt.type).go();
...@@ -279,9 +267,6 @@ DesktopAutomationHandler.prototype = { ...@@ -279,9 +267,6 @@ DesktopAutomationHandler.prototype = {
* @param {!AutomationEvent} evt * @param {!AutomationEvent} evt
*/ */
onChildrenChanged: function(evt) { onChildrenChanged: function(evt) {
if (!this.shouldOutput_(evt))
return;
var curRange = ChromeVoxState.instance.currentRange; var curRange = ChromeVoxState.instance.currentRange;
// Always refresh the braille contents. // Always refresh the braille contents.
...@@ -418,9 +403,6 @@ DesktopAutomationHandler.prototype = { ...@@ -418,9 +403,6 @@ DesktopAutomationHandler.prototype = {
return; return;
} }
if (!this.shouldOutput_(evt))
return;
var t = evt.target; var t = evt.target;
var fromDesktop = t.root.role == RoleType.DESKTOP; var fromDesktop = t.root.role == RoleType.DESKTOP;
if (t.state.focused || fromDesktop || if (t.state.focused || fromDesktop ||
...@@ -454,7 +436,7 @@ DesktopAutomationHandler.prototype = { ...@@ -454,7 +436,7 @@ DesktopAutomationHandler.prototype = {
*/ */
onScrollPositionChanged: function(evt) { onScrollPositionChanged: function(evt) {
var currentRange = ChromeVoxState.instance.currentRange; var currentRange = ChromeVoxState.instance.currentRange;
if (currentRange && currentRange.isValid() && this.shouldOutput_(evt)) if (currentRange && currentRange.isValid())
new Output().withLocation(currentRange, null, evt.type).go(); new Output().withLocation(currentRange, null, evt.type).go();
}, },
...@@ -558,19 +540,6 @@ DesktopAutomationHandler.prototype = { ...@@ -558,19 +540,6 @@ DesktopAutomationHandler.prototype = {
return !!this.textEditHandler_; return !!this.textEditHandler_;
}, },
/**
* Once an event handler updates ChromeVox's range based on |evt|
* which updates mode, returns whether |evt| should be outputted.
* @return {boolean}
*/
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 ||
(mode == ChromeVoxMode.NEXT || mode == ChromeVoxMode.FORCE_NEXT ||
mode == ChromeVoxMode.CLASSIC_COMPAT);
},
/** /**
* @param {AutomationEvent} evt * @param {AutomationEvent} evt
* @private * @private
...@@ -611,8 +580,6 @@ DesktopAutomationHandler.prototype = { ...@@ -611,8 +580,6 @@ DesktopAutomationHandler.prototype = {
} }
ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(focus)); ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(focus));
if (!this.shouldOutput_(evt))
return;
Output.forceModeForNextSpeechUtterance(cvox.QueueMode.FLUSH); Output.forceModeForNextSpeechUtterance(cvox.QueueMode.FLUSH);
o.withRichSpeechAndBraille( o.withRichSpeechAndBraille(
......
...@@ -11,24 +11,10 @@ goog.require('Output'); ...@@ -11,24 +11,10 @@ goog.require('Output');
goog.scope(function() { goog.scope(function() {
var TreeChangeObserverFilter = chrome.automation.TreeChangeObserverFilter; var TreeChangeObserverFilter = chrome.automation.TreeChangeObserverFilter;
/**
* Responds to mode changes.
* @param {ChromeVoxMode} newMode
* @param {?ChromeVoxMode} oldMode Can be null at startup when no range was
* previously set.
*/
FindHandler.onModeChanged = function(newMode, oldMode) {
if (newMode == ChromeVoxMode.FORCE_NEXT)
FindHandler.init_();
else
FindHandler.uninit_();
};
/** /**
* Initializes this module. * Initializes this module.
* @private
*/ */
FindHandler.init_ = function() { FindHandler.init = function() {
chrome.automation.addTreeChangeObserver( chrome.automation.addTreeChangeObserver(
TreeChangeObserverFilter.TEXT_MARKER_CHANGES, FindHandler.onTextMatch_); TreeChangeObserverFilter.TEXT_MARKER_CHANGES, FindHandler.onTextMatch_);
}; };
......
...@@ -12,9 +12,6 @@ goog.require('cvox.ChromeVoxKbHandler'); ...@@ -12,9 +12,6 @@ goog.require('cvox.ChromeVoxKbHandler');
/** @constructor */ /** @constructor */
BackgroundKeyboardHandler = function() { BackgroundKeyboardHandler = function() {
// Classic keymap.
cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults();
/** @type {number} @private */ /** @type {number} @private */
this.passThroughKeyUpCount_ = 0; this.passThroughKeyUpCount_ = 0;
...@@ -24,7 +21,9 @@ BackgroundKeyboardHandler = function() { ...@@ -24,7 +21,9 @@ BackgroundKeyboardHandler = function() {
document.addEventListener('keydown', this.onKeyDown.bind(this), false); document.addEventListener('keydown', this.onKeyDown.bind(this), false);
document.addEventListener('keyup', this.onKeyUp.bind(this), false); document.addEventListener('keyup', this.onKeyUp.bind(this), false);
chrome.accessibilityPrivate.setKeyboardListener(true, false); chrome.accessibilityPrivate.setKeyboardListener(
true, cvox.ChromeVox.isStickyPrefOn);
window['prefs'].switchToKeyMap('keymap_next');
}; };
BackgroundKeyboardHandler.prototype = { BackgroundKeyboardHandler.prototype = {
...@@ -38,8 +37,7 @@ BackgroundKeyboardHandler.prototype = { ...@@ -38,8 +37,7 @@ BackgroundKeyboardHandler.prototype = {
if (cvox.ChromeVox.passThroughMode) if (cvox.ChromeVox.passThroughMode)
return false; return false;
if (ChromeVoxState.instance.mode != ChromeVoxMode.CLASSIC && if (cvox.ChromeVoxKbHandler.basicKeyDownActionsListener(evt)) {
!cvox.ChromeVoxKbHandler.basicKeyDownActionsListener(evt)) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
this.eatenKeyDowns_.add(evt.keyCode); this.eatenKeyDowns_.add(evt.keyCode);
...@@ -72,32 +70,5 @@ BackgroundKeyboardHandler.prototype = { ...@@ -72,32 +70,5 @@ BackgroundKeyboardHandler.prototype = {
} }
return false; return false;
},
/**
* React to mode changes.
* @param {ChromeVoxMode} newMode
* @param {ChromeVoxMode?} oldMode
*/
onModeChanged: function(newMode, oldMode) {
if (newMode == ChromeVoxMode.CLASSIC) {
chrome.accessibilityPrivate.setKeyboardListener(false, false);
} else {
chrome.accessibilityPrivate.setKeyboardListener(
true, cvox.ChromeVox.isStickyPrefOn);
}
if (newMode === ChromeVoxMode.NEXT ||
newMode === ChromeVoxMode.FORCE_NEXT) {
// Switching out of classic, classic compat, or uninitialized
// (on startup).
window['prefs'].switchToKeyMap('keymap_next');
} else if (
oldMode && oldMode != ChromeVoxMode.CLASSIC &&
oldMode != ChromeVoxMode.CLASSIC_COMPAT) {
// Switching out of next. Intentionally do nothing when switching out of
// an uninitialized |oldMode|.
window['prefs'].switchToKeyMap('keymap_classic');
}
} }
}; };
...@@ -84,7 +84,7 @@ LiveRegions.prototype = { ...@@ -84,7 +84,7 @@ LiveRegions.prototype = {
var mode = this.chromeVoxState_.mode; var mode = this.chromeVoxState_.mode;
var currentRange = this.chromeVoxState_.currentRange; var currentRange = this.chromeVoxState_.currentRange;
if (mode === ChromeVoxMode.CLASSIC || !cvox.ChromeVox.isActive) if (!cvox.ChromeVox.isActive)
return; return;
if (!currentRange) if (!currentRange)
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Handles automation from a tabs automation node.
*/
goog.provide('TabsAutomationHandler');
goog.require('CustomAutomationEvent');
goog.require('DesktopAutomationHandler');
goog.scope(function() {
var EventType = chrome.automation.EventType;
var RoleType = chrome.automation.RoleType;
var StateType = chrome.automation.StateType;
/**
* @param {!chrome.automation.AutomationNode} tabRoot
* @constructor
* @extends {DesktopAutomationHandler}
*/
TabsAutomationHandler = function(tabRoot) {
DesktopAutomationHandler.call(this, tabRoot);
if (tabRoot.role != RoleType.ROOT_WEB_AREA)
throw new Error('Expected rootWebArea node but got ' + tabRoot.role);
// When the root is focused, simulate what happens on a load complete.
if (tabRoot.state[StateType.FOCUSED]) {
var event =
new CustomAutomationEvent(EventType.LOAD_COMPLETE, tabRoot, 'page');
this.onLoadComplete(event);
}
};
TabsAutomationHandler.prototype = {
__proto__: DesktopAutomationHandler.prototype,
/** @override */
didHandleEvent_: function(evt) {
evt.stopPropagation();
},
/** @override */
onLoadComplete: function(evt) {
var focused = evt.target.find({state: {focused: true}}) || evt.target;
var event =
new CustomAutomationEvent(EventType.FOCUS, focused, evt.eventFrom);
this.onFocus(event);
}
};
}); // goog.scope
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment