Bug 883953: Part 2: Implement infobar behaviours. r=mbrubeck

This commit is contained in:
Marina Samuel 2013-08-13 13:36:28 -04:00
parent 222aa5fea3
commit bfc2e97a12
4 changed files with 25 additions and 3 deletions

View File

@ -133,6 +133,17 @@ var ContentAreaObserver = {
let newWidth = width || this.width;
let newHeight = height || this.contentHeight;
if (Browser.selectedBrowser) {
let notificationBox = Browser.getNotificationBox();
// If a notification and navbar are visible together,
// make the notification appear above the navbar.
if (ContextUI.navbarVisible && !notificationBox.notificationsHidden &&
notificationBox.allNotifications.length != 0) {
newHeight -= Elements.navbar.getBoundingClientRect().height;
}
}
if (newHeight == oldHeight && newWidth == oldWidth)
return;

View File

@ -21,7 +21,6 @@ var ContextUI = {
init: function init() {
Elements.browsers.addEventListener("mousedown", this, true);
Elements.browsers.addEventListener("touchstart", this, true);
Elements.browsers.addEventListener("AlertActive", this, true);
Elements.browsers.addEventListener('URLChanged', this, true);
Elements.tabList.addEventListener('TabSelect', this, true);
@ -171,6 +170,7 @@ var ContextUI = {
displayNavbar: function () {
this._clearDelayedTimeout();
Elements.navbar.show();
ContentAreaObserver.updateContentArea();
},
// Display the tab tray
@ -183,6 +183,7 @@ var ContextUI = {
dismissNavbar: function dismissNavbar() {
if (!BrowserUI.isStartTabVisible) {
Elements.navbar.dismiss();
ContentAreaObserver.updateContentArea();
}
},
@ -275,12 +276,14 @@ var ContextUI = {
case "mousedown":
if (BrowserUI.isStartTabVisible)
break;
if (aEvent.button == 0 && this.isVisible)
let box = Browser.getNotificationBox();
if (!box.contains(aEvent.target) &&
aEvent.button == 0 && this.isVisible) {
this.dismiss();
}
break;
case "ToolPanelShown":
case "ToolPanelHidden":
case "AlertActive":
this.dismiss();
break;
case "touchstart":

View File

@ -54,6 +54,7 @@ var Downloads = {
Services.obs.addObserver(this, "dl-done", true);
Services.obs.addObserver(this, "dl-run", true);
Services.obs.addObserver(this, "dl-failed", true);
Services.obs.addObserver(this, "dl-request", true);
this._notificationBox = Browser.getNotificationBox();
@ -69,6 +70,7 @@ var Downloads = {
Services.obs.removeObserver(this, "dl-done");
Services.obs.removeObserver(this, "dl-run");
Services.obs.removeObserver(this, "dl-failed");
Services.obs.removeObserver(this, "dl-request");
}
},
@ -444,6 +446,11 @@ var Downloads = {
download = aSubject.QueryInterface(Ci.nsIDownload);
this._showDownloadFailedNotification(download);
break;
case "dl-request":
setTimeout(function() {
ContextUI.displayNavbar();
}, 1000);
break;
}
},

View File

@ -57,6 +57,7 @@ HelperAppLauncherDialog.prototype = {
},
_showDownloadInfobar: function do_showDownloadInfobar(aLauncher) {
Services.obs.notifyObservers(null, "dl-request", "");
let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
let runButtonText =