Commit f72920ef authored by dtseng's avatar dtseng Committed by Commit bot

Fix ChromeVox Next compile.

Review URL: https://codereview.chromium.org/613223003

Cr-Commit-Position: refs/heads/master@{#297541}
parent 7bdade57
......@@ -551,6 +551,7 @@ cvox.ChromeVoxBackground.prototype.onLoadStateChanged = function(
// Export the braille object for access by the options page.
window['braille'] = cvox.ChromeVox.braille;
// Export this background page for ChromeVox Next to access.
cvox.ChromeVox.background = background;
// Export injection for ChromeVox Next.
cvox.ChromeVox.injectChromeVoxIntoTabs =
background.injectChromeVoxIntoTabs.bind(background);
})();
......@@ -957,7 +957,7 @@ ChromeEvent.prototype.hasListener = function(callback) {};
/** @return {boolean} */
ChromeEvent.prototype.hasListeners = function(callback) {};
ChromeEvent.prototype.hasListeners = function() {};
/**
......@@ -1209,3 +1209,91 @@ chrome.storage.local.remove = function(keys, opt_callback) {};
* @type {ChromeEvent}
*/
chrome.storage.onChanged;
/**
* @const
*/
chrome.automation = {};
/**
* @constructor
*/
chrome.automation.AutomationNode = function() {};
/**
* @type {!Object}
*/
chrome.automation.AutomationNode.prototype.attributes;
/**
* @return {chrome.automation.AutomationNode}
*/
chrome.automation.AutomationNode.prototype.firstChild = function() {};
/**
* @return {chrome.automation.AutomationNode}
*/
chrome.automation.AutomationNode.prototype.lastChild = function() {};
/**
* @return {chrome.automation.AutomationNode}
*/
chrome.automation.AutomationNode.prototype.nextSibling = function() {};
/**
* @return {chrome.automation.AutomationNode}
*/
chrome.automation.AutomationNode.prototype.previousSibling = function() {};
/**
* @return {chrome.automation.AutomationNode}
*/
chrome.automation.AutomationNode.prototype.parent = function() {};
/**
* @param {string} eventType
* @param {function(chrome.automation.AutomationNode) : void} callback
* @param {boolean} capture
*/
chrome.automation.AutomationNode.prototype.addEventListener =
function(eventType, callback, capture) {};
/**
* @param {string} eventType
* @param {function(chrome.automation.AutomationNode) : void} callback
* @param {boolean} capture
*/
chrome.automation.AutomationNode.prototype.removeEventListener =
function(eventType, callback, capture) {};
/**
* @param {function(chrome.automation.AutomationNode)} callback
*/
chrome.automation.getDesktop = function(callback) {};
/**
* @param {function(chrome.automation.AutomationNode)} callback
*/
chrome.automation.getTree = function(callback) {};
/**
* @const
*/
chrome.commands = {};
/**
* @type {ChromeEvent}
*/
chrome.commands.onCommand;
......@@ -18,7 +18,7 @@ cvox2.AutomationPredicates = function() {};
/**
* Constructs a predicate given a role.
* @param {string} role
* @return {function(AutomationNode) : boolean}
* @return {function(chrome.automation.AutomationNode) : boolean}
*/
cvox2.AutomationPredicates.makeRolePredicate = function(role) {
return function(node) {
......@@ -26,18 +26,15 @@ cvox2.AutomationPredicates.makeRolePredicate = function(role) {
};
};
/** @type {function(AutomationNode) : boolean} */
/** @type {function(chrome.automation.AutomationNode) : boolean} */
cvox2.AutomationPredicates.heading =
cvox2.AutomationPredicates.makeRolePredicate(
chrome.automation.RoleType.heading);
/** @type {function(AutomationNode) : boolean} */
cvox2.AutomationPredicates.makeRolePredicate('heading');
/** @type {function(chrome.automation.AutomationNode) : boolean} */
cvox2.AutomationPredicates.inlineTextBox =
cvox2.AutomationPredicates.makeRolePredicate(
chrome.automation.RoleType.inlineTextBox);
/** @type {function(AutomationNode) : boolean} */
cvox2.AutomationPredicates.makeRolePredicate('inlineTextBox');
/** @type {function(chrome.automation.AutomationNode) : boolean} */
cvox2.AutomationPredicates.link =
cvox2.AutomationPredicates.makeRolePredicate(
chrome.automation.RoleType.link);
cvox2.AutomationPredicates.makeRolePredicate('link');
/**
* Possible directions to perform tree traversals.
......@@ -58,11 +55,11 @@ cvox2.AutomationUtil = function() {};
/**
* Find a node in subtree of |cur| satisfying |pred| using pre-order traversal.
* @param {AutomationNode} cur Node to begin the search from.
* @param {chrome.automation.AutomationNode} cur Node to begin the search from.
* @param {cvox2.Dir} dir
* @param {function(AutomationNode) : boolean} pred A predicate to apply to a
* candidate node.
* @return {AutomationNode}
* @param {function(chrome.automation.AutomationNode) : boolean} pred A
* predicate to apply to a candidate node.
* @return {chrome.automation.AutomationNode}
*/
cvox2.AutomationUtil.findNodePre = function(cur, dir, pred) {
if (pred(cur))
......@@ -80,11 +77,11 @@ cvox2.AutomationUtil.findNodePre = function(cur, dir, pred) {
/**
* Find a node in subtree of |cur| satisfying |pred| using post-order traversal.
* @param {AutomationNode} cur Node to begin the search from.
* @param {chrome.automation.AutomationNode} cur Node to begin the search from.
* @param {cvox2.Dir} dir
* @param {function(AutomationNode) : boolean} pred A predicate to apply to a
* candidate node.
* @return {AutomationNode}
* @param {function(chrome.automation.AutomationNode) : boolean} pred A
* predicate to apply to a candidate node.
* @return {chrome.automation.AutomationNode}
*/
cvox2.AutomationUtil.findNodePost = function(cur, dir, pred) {
var child = dir == cvox2.Dir.BACKWARD ? cur.lastChild() : cur.firstChild();
......@@ -103,9 +100,9 @@ cvox2.AutomationUtil.findNodePost = function(cur, dir, pred) {
/**
* Find the next node in the given direction that is either an immediate
* sibling or a sibling of an ancestor.
* @param {AutomationNode} cur Node to start search from.
* @param {chrome.automation.AutomationNode} cur Node to start search from.
* @param {cvox2.Dir} dir
* @return {AutomationNode}
* @return {chrome.automation.AutomationNode}
*/
cvox2.AutomationUtil.findNextSubtree = function(cur, dir) {
while (cur) {
......@@ -120,11 +117,11 @@ cvox2.AutomationUtil.findNextSubtree = function(cur, dir) {
/**
* Find the next node in the given direction in depth first order.
* @param {AutomationNode} cur Node to begin the search from.
* @param {chrome.automation.AutomationNode} cur Node to begin the search from.
* @param {cvox2.Dir} dir
* @param {function(AutomationNode) : boolean} pred A predicate to apply to a
* candidate node.
* @return {AutomationNode}
* @param {function(chrome.automation.AutomationNode) : boolean} pred A
* predicate to apply to a candidate node.
* @return {chrome.automation.AutomationNode}
*/
cvox2.AutomationUtil.findNextNode = function(cur, dir, pred) {
var next = cur;
......
......@@ -5,6 +5,7 @@
/**
* @fileoverview The entry point for all ChromeVox2 related code for the
* background page.
*
*/
goog.provide('cvox2.Background');
......@@ -21,28 +22,31 @@ cvox2.global.accessibility =
/**
* ChromeVox2 background page.
* @constructor
*/
cvox2.Background = function() {
/**
* A list of site substring patterns to use with ChromeVox next. Keep these
* strings relatively specific.
* @type {!Array.<string>}
* @private
*/
this.whitelist_ = ['http://www.chromevox.com/', 'chromevox_next_test'];
/** @type {cvox.TabsApiHandler} @private */
/**
* @type {cvox.TabsApiHandler}
* @private
*/
this.tabsHandler_ = new cvox.TabsApiHandler(cvox.ChromeVox.tts,
cvox.ChromeVox.braille,
cvox.ChromeVox.earcons);
/** @type {AutomationNode} @private */
/**
* @type {chrome.automation.AutomationNode}
* @private
*/
this.currentNode_ = null;
/** @type {cvox.TabsApiHandler} @private */
this.tabsHandler_ = new cvox.TabsApiHandler(cvox.ChromeVox.tts,
cvox.ChromeVox.braille,
cvox.ChromeVox.earcons);
// Only needed with unmerged ChromeVox classic loaded before.
cvox2.global.accessibility.setAccessibilityEnabled(false);
......@@ -73,7 +77,7 @@ cvox2.Background.prototype = {
if (!this.isWhitelisted_(tab.url)) {
chrome.commands.onCommand.removeListener(this.onGotCommand);
cvox.ChromeVox.background.injectChromeVoxIntoTabs([tab], true);
cvox.ChromeVox.injectChromeVoxIntoTabs([tab], true);
return;
}
......@@ -88,14 +92,14 @@ cvox2.Background.prototype = {
/**
* Handles all setup once a new automation tree appears.
* @param {AutomationTree} tree The new automation tree.
* @param {chrome.automation.AutomationNode} root
*/
onGotTree: function(root) {
// Register all automation event listeners.
root.addEventListener(chrome.automation.EventType.focus,
root.addEventListener('focus',
this.onFocus,
true);
root.addEventListener(chrome.automation.EventType.loadComplete,
root.addEventListener('loadComplete',
this.onLoadComplete,
true);
......@@ -142,7 +146,7 @@ cvox2.Background.prototype = {
pred = cvox2.AutomationPredicates.link;
break;
case 'nextElement':
current = current.role == chrome.automation.RoleType.inlineTextBox ?
current = current.role == 'inlineTextBox' ?
current.parent() : current;
current = cvox2.AutomationUtil.findNextNode(current,
cvox2.Dir.FORWARD,
......@@ -150,7 +154,7 @@ cvox2.Background.prototype = {
current = current ? current.parent() : current;
break;
case 'previousElement':
current = current.role == chrome.automation.RoleType.inlineTextBox ?
current = current.role == 'inlineTextBox' ?
current.parent() : current;
current = cvox2.AutomationUtil.findNextNode(current,
cvox2.Dir.BACKWARD,
......
// Copyright 2014 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 Definitions for APIs used by ChromeVox Next.
*
* @externs
*/
/**
* @param {Array} tabs
* @param {boolean=} opt_forceCompile
*/
cvox.ChromeVox.injectChromeVoxIntoTabs =
function(tabs, opt_forceCompile) {};
......@@ -36,6 +36,7 @@ def CVoxPath(path='.'):
# Externs common to many ChromeVox scripts.
_COMMON_EXTERNS = [
CVoxPath('cvox2/background/externs.js'),
CVoxPath('common/externs.js'),
CVoxPath('common/chrome_extension_externs.js'),
CVoxPath('chromevox/background/externs.js'),
......@@ -50,6 +51,7 @@ _TOP_LEVEL_SCRIPTS = [
[[CVoxPath('chromevox/background/loader.js')], _COMMON_EXTERNS],
[[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS],
[[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS],
[[CVoxPath('cvox2/background/loader.js')], _COMMON_EXTERNS],
]
......
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