From 89fa440ba26067db62259c4fadca289928b65be9 Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Tue, 25 Sep 2007 05:41:29 +0000 Subject: [PATCH] new vimperator.sleep() method --- chrome/content/vimperator/default.css | 1 + chrome/content/vimperator/hints.js | 10 ++++++++++ chrome/content/vimperator/vimperator.js | 14 +++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/chrome/content/vimperator/default.css b/chrome/content/vimperator/default.css index 33308e0b..7d605347 100644 --- a/chrome/content/vimperator/default.css +++ b/chrome/content/vimperator/default.css @@ -149,6 +149,7 @@ fieldset.paypal { min-height: 18px !important; border: none !important; font-weight: bold; + font-family: monospace; } #vimperator-statusline { font-family: monospace; diff --git a/chrome/content/vimperator/hints.js b/chrome/content/vimperator/hints.js index 2ffa692c..5acdd74d 100644 --- a/chrome/content/vimperator/hints.js +++ b/chrome/content/vimperator/hints.js @@ -200,6 +200,13 @@ function Hints() //{{{ hintContainer.valid_hint_count++; // one more visible hint in this frame linkCount++; // and one more total hint + + // process firefox event to keep the UI snappy + if (linkCount % 10 == 0) + { + Components.classes['@mozilla.org/thread-manager;1']. + getService().mainThread.processNextEvent(false); + } } doc.coordsInvalidated = false; @@ -455,6 +462,9 @@ function Hints() //{{{ } }; + this.showHintsBackground = function() + { + } this.reshowHints = function() { diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index 7135e2bd..4ba3e94d 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -760,7 +760,19 @@ const vimperator = (function() //{{{ vimperator.events.destroy(); window.dump("All vimperator modules destroyed\n"); - } + }, + + sleep: function(ms) + { + var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); + var mainThread = threadManager.mainThread; + + var then = new Date().getTime(), now = then; + for (; now - then < ms; now = new Date().getTime()) { + mainThread.processNextEvent(true); + } + } + } //}}} })(); //}}}