Move repaint code to fileInterface.js, because there's only one use of it

This commit is contained in:
Simon Kornblith 2012-01-31 03:34:06 -05:00
parent 943d2cd5de
commit 50330d9a78
2 changed files with 22 additions and 39 deletions

View file

@ -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;
}
}

View file

@ -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.
*