From cb3d007341e16e5bb4744a28dc612c62d1f76a19 Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Fri, 10 Aug 2007 01:38:59 +0000 Subject: [PATCH] attempt to fix problems with hints on not finished page load, should fix messages to the error console --- chrome/content/vimperator/hints.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/chrome/content/vimperator/hints.js b/chrome/content/vimperator/hints.js index aee3a23b..229916ff 100644 --- a/chrome/content/vimperator/hints.js +++ b/chrome/content/vimperator/hints.js @@ -70,6 +70,10 @@ function Hints() //{{{ this.loadCoord = function(winId, i) { + // win.res is not ready when loading has not finished yet + if(!win.res) + return; + win = wins[winId]; var elem = win.res.snapshotItem(i); @@ -88,7 +92,7 @@ function Hints() //{{{ { // NOTE: experiment for making the function faster, report problems // only works for FF3.0: - //var rect = elem.getBoundingClientRect(); + //var rect = elem.getClientRects()[0]; //if (rect) //{ // elem.absoLeft = rect.left; @@ -144,6 +148,8 @@ function Hints() //{{{ { genHintContainer(doc); hintContainer = doc.getElementById('hah_hints'); + if (!hintContainer) + return false; } hintContainer.valid_hint_count = 0; // none of these hints should be visible initially @@ -207,7 +213,13 @@ function Hints() //{{{ if (linkCount == 0 && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT)) { vimperator.beep(); - this.disableHahMode(win); + + // FIXME: this.disableHahMode(win); + vimperator.setMode(vimperator.modes.NORMAL); + isHahModeEnabled = false; + linkNumString = ''; + hintedElems = []; + return; } @@ -406,7 +418,7 @@ function Hints() //{{{ * @return -1 if already disabled */ //function disableHahMode(event) - this.disableHahMode = function(win, silent) + this.disableHahMode = function(win) { if(!isHahModeEnabled) return; @@ -630,7 +642,8 @@ function Hints() //{{{ hints = doc.createElement('HINTS'); hints.id = "hah_hints"; hints.valid_hint_count = 0; // initially 0 elements are usable as hints - doc.body.appendChild(hints); + if(doc.body) + doc.body.appendChild(hints); } function initDoc(event)