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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
index 6c51f5dd1efe92bf79615dea8d6c5ec3949dac54..b139043c7afbf557a40ac9b450b34869fa89c870 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
@@ -355,13 +355,22 @@ Panel.onOpenMenus = function(opt_event, opt_activateMenuTitle) {
Panel.onClose();
});
- // Add menus for various role types.
+ var roleListMenuMapping = [
+ { menuTitle: 'role_heading', predicate: AutomationPredicate.heading },
+ { menuTitle: 'role_landmark', predicate: AutomationPredicate.landmark },
+ { menuTitle: 'role_link', predicate: AutomationPredicate.link },
+ { menuTitle: 'role_form', predicate: AutomationPredicate.formField },
+ { menuTitle: 'role_table', predicate: AutomationPredicate.table }];
+
var node = bkgnd.ChromeVoxState.instance.getCurrentRange().start.node;
- Panel.addNodeMenu('role_heading', node, AutomationPredicate.heading);
- Panel.addNodeMenu('role_landmark', node, AutomationPredicate.landmark);
- Panel.addNodeMenu('role_link', node, AutomationPredicate.link);
- Panel.addNodeMenu('role_form', node, AutomationPredicate.formField);
- Panel.addNodeMenu('role_table', node, AutomationPredicate.table);
+ for (var i = 0; i < roleListMenuMapping.length; ++i) {
+ var menuTitle = roleListMenuMapping[i].menuTitle;
+ var predicate = roleListMenuMapping[i].predicate;
+ // Defer creating node menus unless that's the specific menu the
+ // user requested.
+ var defer = (menuTitle != opt_activateMenuTitle);
+ Panel.addNodeMenu(menuTitle, node, predicate, defer);
+ }
// Activate either the specified menu or the first menu.
var selectedMenu = Panel.menus_[0];
@@ -420,10 +429,11 @@ Panel.addMenu = function(menuMsg) {
* @param {string} menuMsg The msg id of the new menu to add.
* @param {chrome.automation.AutomationNode} node
* @param {AutomationPredicate.Unary} pred
+ * @param {boolean} defer If true, defers populating the menu.
* @return {PanelMenu} The menu just created.
*/
-Panel.addNodeMenu = function(menuMsg, node, pred) {
- var menu = new PanelNodeMenu(menuMsg, node, pred);
+Panel.addNodeMenu = function(menuMsg, node, pred, defer) {
+ var menu = new PanelNodeMenu(menuMsg, node, pred, defer);
$('menu-bar').appendChild(menu.menuBarItemElement);
menu.menuBarItemElement.addEventListener('mouseover', function() {
Panel.activateMenu(menu);

Powered by Google App Engine
This is Rietveld 408576698