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

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: 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f95f0104fd44ff0175debdc63d86a131652fb089..2d4d184282df23160038cec70f66a1e2324f535c 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
@@ -344,13 +344,23 @@ 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;
+ // Create node menus asynchronously (because it may require searching a
+ // long document) unless that's the specific menu the
+ // user requested.
+ var async = (menuTitle != opt_activateMenuTitle);
+ Panel.addNodeMenu(menuTitle, node, predicate, async);
+ }
// Activate either the specified menu or the first menu.
var selectedMenu = Panel.menus_[0];
@@ -483,12 +493,13 @@ Panel.onUpdateBraille = function(data) {
/**
* Create a new node menu with the given name and add it to the menu bar.
* @param {string} menuMsg The msg id of the new menu to add.
- * @param {chrome.automation.AutomationNode} node
+ * @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);
« 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