From 04c6cde5741a104a4e6412a253623e9a04454bd0 Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" Date: Sat, 26 Jan 2008 05:48:51 +0000 Subject: [PATCH] bug 404232: for performance, don't update Edit commands every time focus changes unless some edit UI is visible; r=mconnor --- browser/base/content/browser-menubar.inc | 4 +- browser/base/content/browser.js | 68 ++++++++++++++++++++++++ browser/base/content/browser.xul | 4 +- toolkit/content/editMenuOverlay.js | 8 +++ 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc index 55834bad8d2..197a5894239 100644 --- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -88,7 +88,9 @@ - + + onpopupshowing="if (event.target != this) return true; updateEditUIVisibility(); gContextMenu = new nsContextMenu(this, window.getBrowser()); return gContextMenu.shouldDisplay;" + onpopuphiding="if (event.target == this) { gContextMenu = null; updateEditUIVisibility(); }"> #include browser-context.inc diff --git a/toolkit/content/editMenuOverlay.js b/toolkit/content/editMenuOverlay.js index 20e9b644194..cd175cca31c 100644 --- a/toolkit/content/editMenuOverlay.js +++ b/toolkit/content/editMenuOverlay.js @@ -39,6 +39,14 @@ // update menu items that rely on focus or on the current selection function goUpdateGlobalEditMenuItems() { + // Don't bother updating the edit commands if they aren't visible in any way + // (i.e. the Edit menu isn't open, nor is the context menu open, nor have the + // cut, copy, and paste buttons been added to the toolbars) for performance. + // This only works in applications/on platforms that set the gEditUIVisible + // flag, so we check to see if that flag is defined before using it. + if (typeof gEditUIVisible != "undefined" && !gEditUIVisible) + return; + goUpdateCommand("cmd_undo"); goUpdateCommand("cmd_redo"); goUpdateCommand("cmd_cut");