зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1385194 - Make PopupNotifications handle windows without a location bar or a tab bar. r=Paolo
This also fixes a bug where notifications would not be displayed correctly when PopupNotifications.jsm was initialized while the window is in DOM fullscreen. MozReview-Commit-ID: D5SCqd9efGk --HG-- extra : rebase_source : 90197e537ce3f12248e1acd066ea1aac83397d39
This commit is contained in:
Родитель
2eedc3c26e
Коммит
e3da4aef9e
|
@ -259,6 +259,12 @@ this.PopupNotifications = function PopupNotifications(tabbrowser, panel,
|
|||
}
|
||||
};
|
||||
|
||||
let documentElement = this.window.document.documentElement;
|
||||
let locationBarHidden = documentElement.getAttribute("chromehidden").includes("location");
|
||||
let isFullscreen = !!this.window.document.fullscreenElement;
|
||||
|
||||
this.panel.setAttribute("followanchor", !locationBarHidden && !isFullscreen);
|
||||
|
||||
// There are no anchor icons in DOM fullscreen mode, but we would
|
||||
// still like to show the popup notification. To avoid an infinite
|
||||
// loop of showing and hiding, we have to disable followanchor
|
||||
|
@ -267,7 +273,7 @@ this.PopupNotifications = function PopupNotifications(tabbrowser, panel,
|
|||
this.panel.setAttribute("followanchor", "false");
|
||||
}, true);
|
||||
this.window.addEventListener("MozDOMFullscreen:Exited", () => {
|
||||
this.panel.setAttribute("followanchor", "true");
|
||||
this.panel.setAttribute("followanchor", !locationBarHidden);
|
||||
}, true);
|
||||
|
||||
this.window.addEventListener("activate", this, true);
|
||||
|
@ -940,6 +946,13 @@ PopupNotifications.prototype = {
|
|||
if (!anchorElement || (anchorElement.boxObject.height == 0 &&
|
||||
anchorElement.boxObject.width == 0)) {
|
||||
anchorElement = this.tabbrowser.selectedTab;
|
||||
|
||||
// If we're in an entirely chromeless environment, set the anchorElement
|
||||
// to null and let openPopup show the notification at (0,0) later.
|
||||
if (!anchorElement || (anchorElement.boxObject.height == 0 &&
|
||||
anchorElement.boxObject.width == 0)) {
|
||||
anchorElement = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1036,7 @@ PopupNotifications.prototype = {
|
|||
this._popupshownListener = this._popupshownListener.bind(this);
|
||||
target.addEventListener("popupshown", this._popupshownListener, true);
|
||||
|
||||
this.panel.openPopup(anchorElement, "bottomcenter topleft");
|
||||
this.panel.openPopup(anchorElement, "bottomcenter topleft", 0, 0);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче