--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -55,17 +55,29 @@ const PanelUI = {
this.menuButton.addEventListener("mousedown", this);
this.menuButton.addEventListener("keypress", this);
this._overlayScrollListenerBoundFn = this._overlayScrollListener.bind(this);
Services.obs.addObserver(this, "fullscreen-nav-toolbox");
Services.obs.addObserver(this, "appMenu-notifications");
- window.addEventListener("fullscreen", this);
+ Services.prefs.addObserver("browser.fullscreen.autohide", this);
+
+ // On OSX, or with autohide preffed off, MozDOMFullscreen is the only
+ // event we care about, since fullscreen should behave just like non
+ // fullscreen. Otherwise, we don't want to listen to these because
+ // we'd just be spamming ourselves with both of them whenever a user
+ // opened a video.
+ if (this.autoHideToolbarInFullScreen) {
+ window.addEventListener("fullscreen", this);
+ } else {
+ window.addEventListener("MozDOMFullscreen:Entered", this);
+ window.addEventListener("MozDOMFullscreen:Exited", this);
+ }
window.addEventListener("activate", this);
window.matchMedia("(-moz-overlay-scrollbars)").addListener(this._overlayScrollListenerBoundFn);
CustomizableUI.addListener(this);
for (let event of this.kEvents) {
this.notificationPanel.addEventListener(event, this);
}
@@ -170,16 +182,20 @@ const PanelUI = {
this._removeEventListeners();
for (let event of this.kEvents) {
this.notificationPanel.removeEventListener(event, this);
}
Services.obs.removeObserver(this, "fullscreen-nav-toolbox");
Services.obs.removeObserver(this, "appMenu-notifications");
+ Services.prefs.removeObserver("browser.fullscreen.autohide", this);
+
+ window.removeEventListener("MozDOMFullscreen:Entered", this);
+ window.removeEventListener("MozDOMFullscreen:Exited", this);
window.removeEventListener("fullscreen", this);
window.removeEventListener("activate", this);
this.menuButton.removeEventListener("mousedown", this);
this.menuButton.removeEventListener("keypress", this);
window.matchMedia("(-moz-overlay-scrollbars)").removeListener(this._overlayScrollListenerBoundFn);
CustomizableUI.removeListener(this);
this._overlayScrollListenerBoundFn = null;
},
@@ -283,16 +299,31 @@ const PanelUI = {
case "appMenu-notifications":
// Don't initialize twice.
if (status == "init" && this._notifications) {
break;
}
this._notifications = AppMenuNotifications.notifications;
this._updateNotifications(true);
break;
+ case "nsPref:changed":
+ if (status == "browser.fullscreen.autohide") {
+ if (this.autoHideToolbarInFullScreen) {
+ window.removeEventListener("MozDOMFullscreen:Entered", this);
+ window.removeEventListener("MozDOMFullscreen:Exited", this);
+ window.addEventListener("fullscreen", this);
+ } else {
+ window.addEventListener("MozDOMFullscreen:Entered", this);
+ window.addEventListener("MozDOMFullscreen:Exited", this);
+ window.removeEventListener("fullscreen", this);
+ }
+
+ this._updateNotifications(false);
+ }
+ break;
}
},
handleEvent(aEvent) {
// Ignore context menus and menu button menus showing and hiding:
if (aEvent.type.startsWith("popup") &&
aEvent.target != this.panel) {
return;
@@ -321,16 +352,18 @@ const PanelUI = {
break;
case "mousedown":
if (aEvent.button == 0)
this.toggle(aEvent);
break;
case "keypress":
this.toggle(aEvent);
break;
+ case "MozDOMFullscreen:Entered":
+ case "MozDOMFullscreen:Exited":
case "fullscreen":
case "activate":
this._updateNotifications();
break;
}
},
get isReady() {
@@ -338,16 +371,21 @@ const PanelUI = {
},
get isNotificationPanelOpen() {
let panelState = this.notificationPanel.state;
return panelState == "showing" || panelState == "open";
},
+ get autoHideToolbarInFullScreen() {
+ return Services.prefs.getBoolPref("browser.fullscreen.autohide", false) &&
+ Services.appinfo.OS !== "Darwin";
+ },
+
/**
* Registering the menu panel is done lazily for performance reasons. This
* method is exposed so that CustomizationMode can force panel-readyness in the
* event that customization mode is started before the panel has been opened
* by the user.
*
* @param aCustomizing (optional) set to true if this was called while entering
* customization mode. If that's the case, we trust that customization
@@ -739,20 +777,18 @@ const PanelUI = {
// since we don't want their doorhangers competing for attention
doorhangers.forEach(n => { n.dismissed = true; })
this._hidePopup();
this._clearBadge();
if (!notifications[0].options.badgeOnly) {
this._showBannerItem(notifications[0]);
}
} else if (doorhangers.length > 0) {
- let autoHideFullScreen = Services.prefs.getBoolPref("browser.fullscreen.autohide", false) &&
- Services.appinfo.OS !== "Darwin";
// Only show the doorhanger if the window is focused and not fullscreen
- if ((window.fullScreen && autoHideFullScreen) || Services.focus.activeWindow !== window) {
+ if ((window.fullScreen && this.autoHideToolbarInFullScreen) || Services.focus.activeWindow !== window) {
this._hidePopup();
this._showBadge(doorhangers[0]);
this._showBannerItem(doorhangers[0]);
} else {
this._clearBadge();
this._showNotificationPanel(doorhangers[0]);
}
} else {