Bug 353071 - Simplify visibility checks in OpenLocation and getSearchBar. r=gavin.

This commit is contained in:
mozilla.mano%sent.com 2006-09-21 12:57:21 +00:00
Родитель b1615967f5
Коммит 519c22045f
2 изменённых файлов: 19 добавлений и 17 удалений

Просмотреть файл

@ -94,7 +94,6 @@ var gCharsetMenu = null;
var gLastBrowserCharset = null;
var gPrevCharset = null;
var gURLBar = null;
var gURLBarContainer = null;
var gProxyButton = null;
var gProxyFavIcon = null;
var gProxyDeck = null;
@ -869,7 +868,6 @@ function BrowserStartup()
function prepareForStartup()
{
gURLBar = document.getElementById("urlbar");
gURLBarContainer = document.getElementById("urlbar-container");
gNavigatorBundle = document.getElementById("bundle_browser");
gProgressMeterPanel = document.getElementById("statusbar-progresspanel");
gBrowser.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver.onUpdatePageReport, false);
@ -1010,8 +1008,7 @@ function delayedStartup()
window.addEventListener("fullscreen", onFullScreen, true);
var element;
if (gIsLoadingBlank && gURLBar && !gURLBar.hidden &&
!gURLBarContainer.parentNode.collapsed)
if (gIsLoadingBlank && gURLBar && isElementVisible(gURLBar))
element = gURLBar;
else
element = content;
@ -1787,13 +1784,10 @@ function addBookmarkForBrowser(aDocShell, aIsWebPanel)
function openLocation()
{
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;
}
#ifdef XP_MACOSX
if (window.location.href != getBrowserURL()) {
@ -3120,11 +3114,9 @@ const BrowserSearch = {
*/
getSearchBar: function BrowserSearch_getSearchBar() {
var searchBar = document.getElementById("searchbar");
if (searchBar) {
var style = window.getComputedStyle(searchBar.parentNode, null);
if (style.visibility == "visible" && style.display != "none")
return searchBar;
}
if (searchBar && isElementVisible(searchBar))
return searchBar;
return null;
},
@ -3373,7 +3365,6 @@ function BrowserToolboxCustomizeDone(aToolboxChanged)
// Update global UI elements that may have been added or removed
if (aToolboxChanged) {
gURLBar = document.getElementById("urlbar");
gURLBarContainer = document.getElementById("urlbar-container");
if (gURLBar)
gURLBar.clickSelectsAll = gClickSelectsAll;
gProxyButton = document.getElementById("page-proxy-button");

Просмотреть файл

@ -486,3 +486,14 @@ function buildHelpMenu()
else
checkForUpdates.removeAttribute("loading");
}
function isElementVisible(aElement)
{
// * When an element is hidden, the width and height of its boxObject
// are set to 0
// * css-visibility (unlike css-display) is inherited.
var bo = aElement.boxObject;
return (bo.height != 0 && bo.width != 0 &&
document.defaultView
.getComputedStyle(aElement, null).visibility == "visible");
}