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

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: Improve jankiness, add jsdoc 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 // Create node menus asynchronously (because it may require searching a
364 Panel.addNodeMenu('role_table', node, AutomationPredicate.table); 370 // long document) unless that's the specific menu the
371 // user requested.
372 var async = (menuTitle != opt_activateMenuTitle);
373 Panel.addNodeMenu(menuTitle, node, predicate, async);
374 }
365 375
366 // Activate either the specified menu or the first menu. 376 // Activate either the specified menu or the first menu.
367 var selectedMenu = Panel.menus_[0]; 377 var selectedMenu = Panel.menus_[0];
368 for (var i = 0; i < Panel.menus_.length; i++) { 378 for (var i = 0; i < Panel.menus_.length; i++) {
369 if (this.menus_[i].menuMsg == opt_activateMenuTitle) 379 if (this.menus_[i].menuMsg == opt_activateMenuTitle)
370 selectedMenu = this.menus_[i]; 380 selectedMenu = this.menus_[i];
371 } 381 }
372 Panel.activateMenu(selectedMenu); 382 Panel.activateMenu(selectedMenu);
373 }; 383 };
374 384
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 421
412 $('menus_background').appendChild(menu.menuContainerElement); 422 $('menus_background').appendChild(menu.menuContainerElement);
413 this.menus_.push(menu); 423 this.menus_.push(menu);
414 return menu; 424 return menu;
415 }; 425 };
416 426
417 427
418 /** 428 /**
419 * Create a new node menu with the given name and add it to the menu bar. 429 * 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. 430 * @param {string} menuMsg The msg id of the new menu to add.
421 * @param {chrome.automation.AutomationNode} node 431 * @param {!chrome.automation.AutomationNode} node
422 * @param {AutomationPredicate.Unary} pred 432 * @param {AutomationPredicate.Unary} pred
433 * @param {boolean} defer If true, defers populating the menu.
423 * @return {PanelMenu} The menu just created. 434 * @return {PanelMenu} The menu just created.
424 */ 435 */
425 Panel.addNodeMenu = function(menuMsg, node, pred) { 436 Panel.addNodeMenu = function(menuMsg, node, pred, defer) {
426 var menu = new PanelNodeMenu(menuMsg, node, pred); 437 var menu = new PanelNodeMenu(menuMsg, node, pred, defer);
427 $('menu-bar').appendChild(menu.menuBarItemElement); 438 $('menu-bar').appendChild(menu.menuBarItemElement);
428 menu.menuBarItemElement.addEventListener('mouseover', function() { 439 menu.menuBarItemElement.addEventListener('mouseover', function() {
429 Panel.activateMenu(menu); 440 Panel.activateMenu(menu);
430 }, false); 441 }, false);
431 442
432 $('menus_background').appendChild(menu.menuContainerElement); 443 $('menus_background').appendChild(menu.menuContainerElement);
433 this.menus_.push(menu); 444 this.menus_.push(menu);
434 return menu; 445 return menu;
435 }; 446 };
436 447
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 }, false); 712 }, false);
702 713
703 window.addEventListener('hashchange', function() { 714 window.addEventListener('hashchange', function() {
704 if (location.hash == '#fullscreen' || location.hash == '#focus') { 715 if (location.hash == '#fullscreen' || location.hash == '#focus') {
705 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; 716 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn;
706 cvox.ChromeVox.isStickyPrefOn = false; 717 cvox.ChromeVox.isStickyPrefOn = false;
707 } else { 718 } else {
708 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; 719 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_;
709 } 720 }
710 }, false); 721 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698