From 50330d9a78c696c9a32d623b35bf9fdfd8dfea87 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 31 Jan 2012 03:34:06 -0500 Subject: [PATCH] Move repaint code to fileInterface.js, because there's only one use of it --- chrome/content/zotero/fileInterface.js | 23 +++++++++++++++- chrome/content/zotero/xpcom/zotero.js | 38 -------------------------- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index b6d35efe37..9a77fd87dd 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -619,7 +619,28 @@ var Zotero_File_Interface = new function() { */ this.updateProgress = function(translate) { Zotero.updateZoteroPaneProgressMeter(translate.getProgress()); - Zotero.repaint(window); + + var now = Date.now(); + + // Don't repaint more than 10 times per second unless forced. + if(!force && window.zoteroLastRepaint && (now - window.zoteroLastRepaint) < 100) return + + // Start a nested event queue + Zotero.mainThread.pushEventQueue(null); + try { + // Add the redraw event onto event queue + window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIDOMWindowUtils) + .redraw(); + + // Process redraw event + Zotero.mainThread.processNextEvent(false); + } finally { + // Close nested event queue + Zotero.mainThread.popEventQueue(); + } + + window.zoteroLastRepaint = now; } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 59708632dd..c5e45255fe 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1495,44 +1495,6 @@ const ZOTERO_CONFIG = { return; }; - - /** - * Repaint UI on given window, without executing any events. - * - * @param {window} window Window to repaint - * @param {Boolean} [force=false] Whether to force a repaint. If false, a repaint only takes - * place if the last repaint was more than 100 ms ago. - */ - this.repaint = function(window, force) { - var now = Date.now(); - - if (!window) { - window = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator) - .getMostRecentWindow("navigator:browser"); - } - - // Don't repaint more than 10 times per second unless forced. - if(!force && window.zoteroLastRepaint && (now - window.zoteroLastRepaint) < 100) return - - // Start a nested event queue - Zotero.mainThread.pushEventQueue(null); - try { - // Add the redraw event onto event queue - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils) - .redraw(); - - // Process redraw event - Zotero.mainThread.processNextEvent(false); - } finally { - // Close nested event queue - Zotero.mainThread.popEventQueue(); - } - - window.zoteroLastRepaint = now; - }; - /** * Pumps a generator until it yields false. See itemTreeView.js for an example. *