From 684095c241e072e0949ee4e96035c216165c1146 Mon Sep 17 00:00:00 2001 From: John Foerch Date: Fri, 23 Sep 2011 17:04:08 -0400 Subject: [PATCH] generate_hints: special case for sizeless anchor A sizeless anchor may have children at different coordinates from the anchor itself. Our test case was the paneltoggle2 widget on google maps (which collapses the information panel). We do a simple thing for these cases, and just use the client-rect of the first child of the anchor that has one. --- modules/hints.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/hints.js b/modules/hints.js index 9fa00f4..8544333 100644 --- a/modules/hints.js +++ b/modules/hints.js @@ -183,6 +183,18 @@ hint_manager.prototype = { rect = elem.getClientRects()[0]; if (!rect) continue; + var nchildren = elem.childNodes.length; + if (elem instanceof Ci.nsIDOMHTMLAnchorElement && + rect.left == rect.right && rect.top == rect.bottom) + { + for (var c = 0; c < nchildren; ++c) { + var cc = elem.childNodes.item(c); + if (cc.getBoundingClientRect) { + rect = cc.getBoundingClientRect(); + break; + } + } + } show_text = false; if (elem instanceof Ci.nsIDOMHTMLInputElement || elem instanceof Ci.nsIDOMHTMLTextAreaElement) text = elem.value; @@ -194,7 +206,7 @@ hint_manager.prototype = { } else if (elem instanceof Ci.nsIDOMHTMLFrameElement) { text = elem.name ? elem.name : ""; } else if (/^\s*$/.test(elem.textContent) && - elem.childNodes.length == 1 && + nchildren == 1 && elem.childNodes.item(0) instanceof Ci.nsIDOMHTMLImageElement) { text = elem.childNodes.item(0).alt; show_text = true; -- 2.11.4.GIT