From f8bf1c1d5cb5c869057da62acaa0dd03053cd075 Mon Sep 17 00:00:00 2001 From: Jeremy Maitin-Shepard Date: Tue, 30 Jun 2009 14:44:23 -0700 Subject: [PATCH] browser_object_frames: auto-select top frame if there are no visible frames The top frame is automatically selected without using the hints system if there are no FRAME elements and no visible IFRAME elements. The visibility of IFRAME elements is determined by checking the "display" and "visibility" attributes of the computed style. Previously, even invisible IFRAME elements were sufficient to trigger use of the hints system. --- modules/element.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/element.js b/modules/element.js index 2017e4b..a725203 100644 --- a/modules/element.js +++ b/modules/element.js @@ -57,9 +57,22 @@ define_browser_object_class( "frames","frame", null, function (I, prompt) { var doc = I.buffer.document; - if (doc.getElementsByTagName("frame").length == 0 && - doc.getElementsByTagName("iframe").length == 0) - { + // Check for any frames or visible iframes + var skip_hints = true; + if (doc.getElementsByTagName("frame").length > 0) + skip_hints = false; + else { + let topwin = I.buffer.top_frame; + for each (let x in doc.getElementsByTagName("iframe")) + { + let style = topwin.getComputedStyle(x, ""); + if (style.display == "none" || style.visibility == "hidden") + continue; + skip_hints = false; + break; + } + } + if (skip_hints) { // only one frame (the top-level one), no need to use the hints system yield co_return(I.buffer.top_frame); } -- 2.11.4.GIT