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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/common/nav_description.js

Issue 604423002: Use an enum for ChromeVox queue mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 unified diff | Download patch
OLDNEW
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 /** 5 /**
6 * @fileoverview A simple container object for the description of a 6 * @fileoverview A simple container object for the description of a
7 * navigation from one object to another. 7 * navigation from one object to another.
8 * 8 *
9 */ 9 */
10 10
11 11
12 goog.provide('cvox.NavDescription'); 12 goog.provide('cvox.NavDescription');
13 13
14 goog.require('cvox.AbstractTts'); 14 goog.require('cvox.AbstractTts');
15 goog.require('cvox.ChromeVox'); 15 goog.require('cvox.ChromeVox');
16 goog.require('cvox.CursorSelection'); 16 goog.require('cvox.CursorSelection');
17 goog.require('cvox.QueueMode');
17 18
18 /** 19 /**
19 * A class representing the description of navigation from one object to 20 * A class representing the description of navigation from one object to
20 * another. 21 * another.
21 * @param {{context: (undefined|string), 22 * @param {{context: (undefined|string),
22 * text: (string), 23 * text: (string),
23 * userValue: (undefined|string), 24 * userValue: (undefined|string),
24 * annotation: (undefined|string), 25 * annotation: (undefined|string),
25 * earcons: (undefined|Array.<number>), 26 * earcons: (undefined|Array.<number>),
26 * personality: (undefined|Object), 27 * personality: (undefined|Object),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 * @param {number} earconId An earcon id to be pushed on to the list of earcon 84 * @param {number} earconId An earcon id to be pushed on to the list of earcon
84 * ids to play along with the spoken description of this object. 85 * ids to play along with the spoken description of this object.
85 */ 86 */
86 cvox.NavDescription.prototype.pushEarcon = function(earconId) { 87 cvox.NavDescription.prototype.pushEarcon = function(earconId) {
87 this.earcons.push(earconId); 88 this.earcons.push(earconId);
88 }; 89 };
89 90
90 91
91 /** 92 /**
92 * Speak this nav description with the given queue mode. 93 * Speak this nav description with the given queue mode.
93 * @param {number=} queueMode The queue mode: cvox.AbstractTts.QUEUE_MODE_FLUSH 94 * @param {cvox.QueueMode=} queueMode The queue mode.
94 * for flush, cvox.AbstractTts.QUEUE_MODE_QUEUE for adding to queue. 95 * @param {function()=} opt_startCallback Function called when this
95 * @param {function()=} startCallback Function called when this starts speaking. 96 * starts speaking.
96 * @param {function()=} endCallback Function called when this ends speaking. 97 * @param {function()=} opt_endCallback Function called when this ends speaking.
97 */ 98 */
98 cvox.NavDescription.prototype.speak = function( 99 cvox.NavDescription.prototype.speak = function(
99 queueMode, startCallback, endCallback) { 100 queueMode, opt_startCallback, opt_endCallback) {
100 /** 101 /**
101 * Return a deep copy of PERSONALITY_ANNOTATION for modifying. 102 * Return a deep copy of PERSONALITY_ANNOTATION for modifying.
102 * @return {Object} The newly created properties object. 103 * @return {Object} The newly created properties object.
103 */ 104 */
104 function makeAnnotationProps() { 105 function makeAnnotationProps() {
105 var properties = {}; 106 var properties = {};
106 var src = cvox.AbstractTts.PERSONALITY_ANNOTATION; 107 var src = cvox.AbstractTts.PERSONALITY_ANNOTATION;
107 for (var key in src) { 108 for (var key in src) {
108 properties[key] = src[key]; 109 properties[key] = src[key];
109 } 110 }
110 return properties; 111 return properties;
111 } 112 }
112 113
113 var speakArgs = new Array(); 114 var speakArgs = new Array();
114 if (this.context) { 115 if (this.context) {
115 speakArgs.push([this.context, queueMode, makeAnnotationProps()]); 116 speakArgs.push([this.context, queueMode, makeAnnotationProps()]);
116 queueMode = 1; 117 queueMode = cvox.QueueMode.QUEUE;
117 } 118 }
118 119
119 speakArgs.push([this.text, 120 speakArgs.push([this.text,
120 queueMode, 121 queueMode,
121 this.personality ? this.personality : {}]); 122 this.personality ? this.personality : {}]);
122 queueMode = 1; 123 queueMode = cvox.QueueMode.QUEUE;
123 124
124 if (this.userValue) { 125 if (this.userValue) {
125 speakArgs.push([this.userValue, queueMode, {}]); 126 speakArgs.push([this.userValue, queueMode, {}]);
126 } 127 }
127 128
128 if (this.annotation) { 129 if (this.annotation) {
129 speakArgs.push([this.annotation, queueMode, makeAnnotationProps()]); 130 speakArgs.push([this.annotation, queueMode, makeAnnotationProps()]);
130 } 131 }
131 132
132 if (this.hint) { 133 if (this.hint) {
133 speakArgs.push([this.hint, queueMode, makeAnnotationProps()]); 134 speakArgs.push([this.hint, queueMode, makeAnnotationProps()]);
134 } 135 }
135 136
136 var length = speakArgs.length; 137 var length = speakArgs.length;
137 for (var i = 0; i < length; i++) { 138 for (var i = 0; i < length; i++) {
138 if (i == 0 && startCallback) { 139 if (i == 0 && opt_startCallback) {
139 speakArgs[i][2]['startCallback'] = startCallback; 140 speakArgs[i][2]['startCallback'] = opt_startCallback;
140 } 141 }
141 if (i == length - 1 && endCallback) { 142 if (i == length - 1 && opt_endCallback) {
142 speakArgs[i][2]['endCallback'] = endCallback; 143 speakArgs[i][2]['endCallback'] = opt_endCallback;
143 } 144 }
144 if (this.category) { 145 if (this.category) {
145 speakArgs[i][2]['category'] = this.category; 146 speakArgs[i][2]['category'] = this.category;
146 } 147 }
147 cvox.ChromeVox.tts.speak.apply(cvox.ChromeVox.tts, speakArgs[i]); 148 cvox.ChromeVox.tts.speak.apply(cvox.ChromeVox.tts, speakArgs[i]);
148 } 149 }
149 }; 150 };
150 151
151 152
152 /** 153 /**
153 * Compares two NavDescriptions. 154 * Compares two NavDescriptions.
154 * @param {cvox.NavDescription} that A NavDescription. 155 * @param {cvox.NavDescription} that A NavDescription.
155 * @return {boolean} True if equal. 156 * @return {boolean} True if equal.
156 */ 157 */
157 cvox.NavDescription.prototype.equals = function(that) { 158 cvox.NavDescription.prototype.equals = function(that) {
158 return this.context == that.context && 159 return this.context == that.context &&
159 this.text == that.text && 160 this.text == that.text &&
160 this.userValue == that.userValue && 161 this.userValue == that.userValue &&
161 this.annotation == that.annotation; 162 this.annotation == that.annotation;
162 }; 163 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698