Simplify visibility checks in OpenLocation and getSearchBar

RESOLVED FIXED in Firefox 3 alpha1

Status

()

Firefox
General
P3
normal
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: mano, Assigned: mano)

Tracking

unspecified
Firefox 3 alpha1
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

We can do simple checks on the boxObject of the location bar and search bar elements instead of checking their containers visibility etc.
Created attachment 238937 [details] [diff] [review]
patch
Attachment #238937 - Flags: review?(gavin.sharp)
Status: NEW → ASSIGNED
Comment on attachment 238937 [details] [diff] [review]
patch

>Index: browser/base/content/browser.js

>   var element;
>-  if (gIsLoadingBlank && gURLBar && !gURLBar.hidden &&
>-      !gURLBarContainer.parentNode.collapsed)
>+  if (gIsLoadingBlank && gURLBar && isElementVisible(gURLBar))
>     element = gURLBar;
>   else
>     element = content;

>-  if (gURLBar) {
>-    var style = document.defaultView.getComputedStyle(gURLBarContainer, null);
>-    if (style.visibility == "visible" && style.display != "none") {
>-      gURLBar.focus();
>-      gURLBar.select();
>-      return;
>-    }
>+  if (gURLBar && isElementVisible(gURLBar)) {
>+    gURLBar.focus();
>+    gURLBar.select();
>+    return;

gURLBarContainer is now unused, so you can remove it.

>Index: browser/base/content/utilityOverlay.js

>+function isElementVisible(aElement)
>+{
>+  // * When an element is hidden (not collapsed), its boxObject.x property is
>+  //   set to 0.

This is also true for elements on the leftmost edge of the screen, though... You should probably check at least one of width and height, too. I kinda of wish there was a better way to tell whether an element has a frame or not (or maybe there is and I don't know about it - maybe one of the Neils would?). Also, use document.defaultView.getComputedStyle instead of window.getComputedStyle.
Attachment #238937 - Flags: review?(gavin.sharp) → review-
Priority: -- → P3
Created attachment 239426 [details] [diff] [review]
patch
Attachment #238937 - Attachment is obsolete: true
Attachment #239426 - Flags: review?(gavin.sharp)
Comment on attachment 239426 [details] [diff] [review]
patch

r=me if you also remove other traces of gURLBarContainer.
Attachment #239426 - Flags: review?(gavin.sharp) → review+
Created attachment 239496 [details] [diff] [review]
as checked in

mozilla/browser/base/content/browser.js 1.708
mozilla/browser/base/content/utilityOverlay.js 1.43
Attachment #239426 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
OS: Mac OS X 10.3 → All
Hardware: Macintosh → All
You need to log in before you can comment on or make changes to this bug.