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

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: Call finish from all codepaths 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 337 }
338 }); 338 });
339 }); 339 });
340 340
341 // Add a menu item that disables / closes ChromeVox. 341 // Add a menu item that disables / closes ChromeVox.
342 chromevoxMenu.addMenuItem( 342 chromevoxMenu.addMenuItem(
343 Msgs.getMsg('disable_chromevox'), 'Ctrl+Alt+Z', function() { 343 Msgs.getMsg('disable_chromevox'), 'Ctrl+Alt+Z', function() {
344 Panel.onClose(); 344 Panel.onClose();
345 }); 345 });
346 346
347 // Add menus for various role types. 347 var roleListMenuMapping = [
348 { menuTitle: 'role_heading', predicate: AutomationPredicate.heading },
349 { menuTitle: 'role_landmark', predicate: AutomationPredicate.landmark },
350 { menuTitle: 'role_link', predicate: AutomationPredicate.link },
351 { menuTitle: 'role_form', predicate: AutomationPredicate.formField },
352 { menuTitle: 'role_table', predicate: AutomationPredicate.table }];
353
348 var node = bkgnd.ChromeVoxState.instance.getCurrentRange().start.node; 354 var node = bkgnd.ChromeVoxState.instance.getCurrentRange().start.node;
349 Panel.addNodeMenu('role_heading', node, AutomationPredicate.heading); 355 for (var i = 0; i < roleListMenuMapping.length; ++i) {
350 Panel.addNodeMenu('role_landmark', node, AutomationPredicate.landmark); 356 var menuTitle = roleListMenuMapping[i].menuTitle;
351 Panel.addNodeMenu('role_link', node, AutomationPredicate.link); 357 var predicate = roleListMenuMapping[i].predicate;
352 Panel.addNodeMenu('role_form', node, AutomationPredicate.formField); 358 // Create node menus asynchronously (because it may require searching a
353 Panel.addNodeMenu('role_table', node, AutomationPredicate.table); 359 // long document) unless that's the specific menu the
360 // user requested.
361 var async = (menuTitle != opt_activateMenuTitle);
362 Panel.addNodeMenu(menuTitle, node, predicate, async);
363 }
354 364
355 // Activate either the specified menu or the first menu. 365 // Activate either the specified menu or the first menu.
356 var selectedMenu = Panel.menus_[0]; 366 var selectedMenu = Panel.menus_[0];
357 for (var i = 0; i < Panel.menus_.length; i++) { 367 for (var i = 0; i < Panel.menus_.length; i++) {
358 if (this.menus_[i].menuMsg == opt_activateMenuTitle) 368 if (this.menus_[i].menuMsg == opt_activateMenuTitle)
359 selectedMenu = this.menus_[i]; 369 selectedMenu = this.menus_[i];
360 } 370 }
361 Panel.activateMenu(selectedMenu); 371 Panel.activateMenu(selectedMenu);
362 }; 372 };
363 373
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 bottomCell.setAttribute('companionID', i + '-textCell'); 486 bottomCell.setAttribute('companionID', i + '-textCell');
477 bottomCell.className = 'unhighlighted-cell'; 487 bottomCell.className = 'unhighlighted-cell';
478 } 488 }
479 }; 489 };
480 490
481 491
482 492
483 /** 493 /**
484 * Create a new node menu with the given name and add it to the menu bar. 494 * Create a new node menu with the given name and add it to the menu bar.
485 * @param {string} menuMsg The msg id of the new menu to add. 495 * @param {string} menuMsg The msg id of the new menu to add.
486 * @param {chrome.automation.AutomationNode} node 496 * @param {!chrome.automation.AutomationNode} node
487 * @param {AutomationPredicate.Unary} pred 497 * @param {AutomationPredicate.Unary} pred
498 * @param {boolean} defer If true, defers populating the menu.
488 * @return {PanelMenu} The menu just created. 499 * @return {PanelMenu} The menu just created.
489 */ 500 */
490 Panel.addNodeMenu = function(menuMsg, node, pred) { 501 Panel.addNodeMenu = function(menuMsg, node, pred, defer) {
491 var menu = new PanelNodeMenu(menuMsg, node, pred); 502 var menu = new PanelNodeMenu(menuMsg, node, pred, defer);
492 $('menu-bar').appendChild(menu.menuBarItemElement); 503 $('menu-bar').appendChild(menu.menuBarItemElement);
493 menu.menuBarItemElement.addEventListener('mouseover', function() { 504 menu.menuBarItemElement.addEventListener('mouseover', function() {
494 Panel.activateMenu(menu); 505 Panel.activateMenu(menu);
495 }, false); 506 }, false);
496 507
497 $('menus_background').appendChild(menu.menuContainerElement); 508 $('menus_background').appendChild(menu.menuContainerElement);
498 this.menus_.push(menu); 509 this.menus_.push(menu);
499 return menu; 510 return menu;
500 }; 511 };
501 512
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 }, false); 777 }, false);
767 778
768 window.addEventListener('hashchange', function() { 779 window.addEventListener('hashchange', function() {
769 if (location.hash == '#fullscreen' || location.hash == '#focus') { 780 if (location.hash == '#fullscreen' || location.hash == '#focus') {
770 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; 781 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn;
771 cvox.ChromeVox.isStickyPrefOn = false; 782 cvox.ChromeVox.isStickyPrefOn = false;
772 } else { 783 } else {
773 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; 784 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_;
774 } 785 }
775 }, false); 786 }, false);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698