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

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

Issue 2443103004: Defer creating ChromeVox node menus to make menus open more quickly. (Closed)
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 The ChromeVox panel and menus. 6 * @fileoverview The ChromeVox panel and menus.
7 */ 7 */
8 8
9 goog.provide('Panel'); 9 goog.provide('Panel');
10 10
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 }); 349 });
350 }); 350 });
351 351
352 // Add a menu item that disables / closes ChromeVox. 352 // Add a menu item that disables / closes ChromeVox.
353 chromevoxMenu.addMenuItem( 353 chromevoxMenu.addMenuItem(
354 Msgs.getMsg('disable_chromevox'), 'Ctrl+Alt+Z', function() { 354 Msgs.getMsg('disable_chromevox'), 'Ctrl+Alt+Z', function() {
355 Panel.onClose(); 355 Panel.onClose();
356 }); 356 });
357 357
358 // Add menus for various role types. 358 var roleListMenuMapping = [
359 { menuTitle: 'role_heading', predicate: AutomationPredicate.heading },
360 { menuTitle: 'role_landmark', predicate: AutomationPredicate.landmark },
361 { menuTitle: 'role_link', predicate: AutomationPredicate.link },
362 { menuTitle: 'role_form', predicate: AutomationPredicate.formField },
363 { menuTitle: 'role_table', predicate: AutomationPredicate.table }];
364
359 var node = bkgnd.ChromeVoxState.instance.getCurrentRange().start.node; 365 var node = bkgnd.ChromeVoxState.instance.getCurrentRange().start.node;
360 Panel.addNodeMenu('role_heading', node, AutomationPredicate.heading); 366 for (var i = 0; i < roleListMenuMapping.length; ++i) {
361 Panel.addNodeMenu('role_landmark', node, AutomationPredicate.landmark); 367 var menuTitle = roleListMenuMapping[i].menuTitle;
362 Panel.addNodeMenu('role_link', node, AutomationPredicate.link); 368 var predicate = roleListMenuMapping[i].predicate;
363 Panel.addNodeMenu('role_form', node, AutomationPredicate.formField); 369 // Defer creating node menus unless that's the specific menu the
364 Panel.addNodeMenu('role_table', node, AutomationPredicate.table); 370 // user requested.
371 var defer = (menuTitle != opt_activateMenuTitle);
372 Panel.addNodeMenu(menuTitle, node, predicate, defer);
373 }
365 374
366 // Activate either the specified menu or the first menu. 375 // Activate either the specified menu or the first menu.
367 var selectedMenu = Panel.menus_[0]; 376 var selectedMenu = Panel.menus_[0];
368 for (var i = 0; i < Panel.menus_.length; i++) { 377 for (var i = 0; i < Panel.menus_.length; i++) {
369 if (this.menus_[i].menuMsg == opt_activateMenuTitle) 378 if (this.menus_[i].menuMsg == opt_activateMenuTitle)
370 selectedMenu = this.menus_[i]; 379 selectedMenu = this.menus_[i];
371 } 380 }
372 Panel.activateMenu(selectedMenu); 381 Panel.activateMenu(selectedMenu);
373 }; 382 };
374 383
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 this.menus_.push(menu); 422 this.menus_.push(menu);
414 return menu; 423 return menu;
415 }; 424 };
416 425
417 426
418 /** 427 /**
419 * Create a new node menu with the given name and add it to the menu bar. 428 * Create a new node menu with the given name and add it to the menu bar.
420 * @param {string} menuMsg The msg id of the new menu to add. 429 * @param {string} menuMsg The msg id of the new menu to add.
421 * @param {chrome.automation.AutomationNode} node 430 * @param {chrome.automation.AutomationNode} node
422 * @param {AutomationPredicate.Unary} pred 431 * @param {AutomationPredicate.Unary} pred
432 * @param {boolean} defer If true, defers populating the menu.
423 * @return {PanelMenu} The menu just created. 433 * @return {PanelMenu} The menu just created.
424 */ 434 */
425 Panel.addNodeMenu = function(menuMsg, node, pred) { 435 Panel.addNodeMenu = function(menuMsg, node, pred, defer) {
426 var menu = new PanelNodeMenu(menuMsg, node, pred); 436 var menu = new PanelNodeMenu(menuMsg, node, pred, defer);
427 $('menu-bar').appendChild(menu.menuBarItemElement); 437 $('menu-bar').appendChild(menu.menuBarItemElement);
428 menu.menuBarItemElement.addEventListener('mouseover', function() { 438 menu.menuBarItemElement.addEventListener('mouseover', function() {
429 Panel.activateMenu(menu); 439 Panel.activateMenu(menu);
430 }, false); 440 }, false);
431 441
432 $('menus_background').appendChild(menu.menuContainerElement); 442 $('menus_background').appendChild(menu.menuContainerElement);
433 this.menus_.push(menu); 443 this.menus_.push(menu);
434 return menu; 444 return menu;
435 }; 445 };
436 446
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 }, false); 706 }, false);
697 707
698 window.addEventListener('hashchange', function() { 708 window.addEventListener('hashchange', function() {
699 if (location.hash == '#fullscreen' || location.hash == '#focus') { 709 if (location.hash == '#fullscreen' || location.hash == '#focus') {
700 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; 710 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn;
701 cvox.ChromeVox.isStickyPrefOn = false; 711 cvox.ChromeVox.isStickyPrefOn = false;
702 } else { 712 } else {
703 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; 713 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_;
704 } 714 }
705 }, false); 715 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698