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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js

Issue 2486293002: Add keyboard explorer improvements for braille (Closed)
Patch Set: Indents and braille cap cond Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 drop-down menu in the ChromeVox panel. 6 * @fileoverview A drop-down menu in the ChromeVox panel.
7 */ 7 */
8 8
9 goog.provide('PanelMenu'); 9 goog.provide('PanelMenu');
10 goog.provide('PanelNodeMenu'); 10 goog.provide('PanelNodeMenu');
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 'keypress', this.onKeyPress_.bind(this), true); 70 'keypress', this.onKeyPress_.bind(this), true);
71 }; 71 };
72 72
73 PanelMenu.prototype = { 73 PanelMenu.prototype = {
74 /** 74 /**
75 * @param {string} menuItemTitle The title of the menu item. 75 * @param {string} menuItemTitle The title of the menu item.
76 * @param {string} menuItemShortcut The keystrokes to select this item. 76 * @param {string} menuItemShortcut The keystrokes to select this item.
77 * @param {Function} callback The function to call if this item is selected. 77 * @param {Function} callback The function to call if this item is selected.
78 * @return {!PanelMenuItem} The menu item just created. 78 * @return {!PanelMenuItem} The menu item just created.
79 */ 79 */
80 addMenuItem: function(menuItemTitle, menuItemShortcut, callback) { 80 addMenuItem: function(
81 var menuItem = new PanelMenuItem(menuItemTitle, menuItemShortcut, callback); 81 menuItemTitle, menuItemShortcut, menuItemBraille, callback) {
82 var menuItem = new PanelMenuItem(
83 menuItemTitle, menuItemShortcut, menuItemBraille, callback);
82 this.items_.push(menuItem); 84 this.items_.push(menuItem);
83 this.menuElement.appendChild(menuItem.element); 85 this.menuElement.appendChild(menuItem.element);
84 86
85 // Sync the active index with focus. 87 // Sync the active index with focus.
86 menuItem.element.addEventListener('focus', (function(index, event) { 88 menuItem.element.addEventListener('focus', (function(index, event) {
87 this.activeIndex_ = index; 89 this.activeIndex_ = index;
88 }).bind(this, this.items_.length - 1), false); 90 }).bind(this, this.items_.length - 1), false);
89 91
90 // Update the container height, adding a scroll bar if necessary - but 92 // Update the container height, adding a scroll bar if necessary - but
91 // to avoid excessive layout, schedule this once per batch of adding 93 // to avoid excessive layout, schedule this once per batch of adding
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 findMoreNodes_: function() { 303 findMoreNodes_: function() {
302 while (this.walker_.next().node) { 304 while (this.walker_.next().node) {
303 var node = this.walker_.node; 305 var node = this.walker_.node;
304 if (node == this.node_) 306 if (node == this.node_)
305 this.selectNext_ = true; 307 this.selectNext_ = true;
306 if (this.pred_(node)) { 308 if (this.pred_(node)) {
307 var output = new Output(); 309 var output = new Output();
308 var range = cursors.Range.fromNode(node); 310 var range = cursors.Range.fromNode(node);
309 output.withSpeech(range, range, Output.EventType.NAVIGATE); 311 output.withSpeech(range, range, Output.EventType.NAVIGATE);
310 var label = output.toString(); 312 var label = output.toString();
311 this.addMenuItem(label, '', function() { 313 this.addMenuItem(label, '', '', function() {
312 chrome.extension.getBackgroundPage().ChromeVoxState 314 chrome.extension.getBackgroundPage().ChromeVoxState
313 .instance['navigateToRange'](cursors.Range.fromNode(node)); 315 .instance['navigateToRange'](cursors.Range.fromNode(node));
314 }); 316 });
315 if (this.selectNext_) { 317 if (this.selectNext_) {
316 this.activateItem(this.items_.length - 1); 318 this.activateItem(this.items_.length - 1);
317 this.selectNext_ = false; 319 this.selectNext_ = false;
318 } 320 }
319 } 321 }
320 322
321 if (this.async_) { 323 if (this.async_) {
322 this.nodeCount_++; 324 this.nodeCount_++;
323 if (this.nodeCount_ >= PanelNodeMenu.MAX_NODES_BEFORE_ASYNC) { 325 if (this.nodeCount_ >= PanelNodeMenu.MAX_NODES_BEFORE_ASYNC) {
324 this.nodeCount_ = 0; 326 this.nodeCount_ = 0;
325 window.setTimeout(this.findMoreNodes_.bind(this), 0); 327 window.setTimeout(this.findMoreNodes_.bind(this), 0);
326 return; 328 return;
327 } 329 }
328 } 330 }
329 } 331 }
330 this.finish_(); 332 this.finish_();
331 }, 333 },
332 334
333 /** 335 /**
334 * Called when we've finished searching for nodes. If no matches were 336 * Called when we've finished searching for nodes. If no matches were
335 * found, adds an item to the menu indicating none were found. 337 * found, adds an item to the menu indicating none were found.
336 * @private 338 * @private
337 */ 339 */
338 finish_: function() { 340 finish_: function() {
339 if (!this.items_.length) { 341 if (!this.items_.length) {
340 this.addMenuItem( 342 this.addMenuItem(
341 Msgs.getMsg('panel_menu_item_none'), '', function() {}); 343 Msgs.getMsg('panel_menu_item_none'), '', '', function() {});
342 this.activateItem(0); 344 this.activateItem(0);
343 } 345 }
344 } 346 }
345 }; 347 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698