michael@0: # -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: var FullScreen = { michael@0: _XULNS: "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", michael@0: get _fullScrToggler() { michael@0: delete this._fullScrToggler; michael@0: return this._fullScrToggler = document.getElementById("fullscr-toggler"); michael@0: }, michael@0: toggle: function (event) { michael@0: var enterFS = window.fullScreen; michael@0: michael@0: // We get the fullscreen event _before_ the window transitions into or out of FS mode. michael@0: if (event && event.type == "fullscreen") michael@0: enterFS = !enterFS; michael@0: michael@0: // Toggle the View:FullScreen command, which controls elements like the michael@0: // fullscreen menuitem, and menubars. michael@0: let fullscreenCommand = document.getElementById("View:FullScreen"); michael@0: if (enterFS) { michael@0: fullscreenCommand.setAttribute("checked", enterFS); michael@0: } else { michael@0: fullscreenCommand.removeAttribute("checked"); michael@0: } michael@0: michael@0: #ifdef XP_MACOSX michael@0: // Make sure the menu items are adjusted. michael@0: document.getElementById("enterFullScreenItem").hidden = enterFS; michael@0: document.getElementById("exitFullScreenItem").hidden = !enterFS; michael@0: #endif michael@0: michael@0: // On OS X Lion we don't want to hide toolbars when entering fullscreen, unless michael@0: // we're entering DOM fullscreen, in which case we should hide the toolbars. michael@0: // If we're leaving fullscreen, then we'll go through the exit code below to michael@0: // make sure toolbars are made visible in the case of DOM fullscreen. michael@0: if (enterFS && this.useLionFullScreen) { michael@0: if (document.mozFullScreen) { michael@0: this.showXULChrome("toolbar", false); michael@0: } michael@0: else { michael@0: gNavToolbox.setAttribute("inFullscreen", true); michael@0: document.documentElement.setAttribute("inFullscreen", true); michael@0: } michael@0: return; michael@0: } michael@0: michael@0: // show/hide menubars, toolbars (except the full screen toolbar) michael@0: this.showXULChrome("toolbar", !enterFS); michael@0: michael@0: if (enterFS) { michael@0: // Add a tiny toolbar to receive mouseover and dragenter events, and provide affordance. michael@0: // This will help simulate the "collapse" metaphor while also requiring less code and michael@0: // events than raw listening of mouse coords. We don't add the toolbar in DOM full-screen michael@0: // mode, only browser full-screen mode. michael@0: if (!document.mozFullScreen) { michael@0: this._fullScrToggler.addEventListener("mouseover", this._expandCallback, false); michael@0: this._fullScrToggler.addEventListener("dragenter", this._expandCallback, false); michael@0: } michael@0: if (gPrefService.getBoolPref("browser.fullscreen.autohide")) michael@0: gBrowser.mPanelContainer.addEventListener("mousemove", michael@0: this._collapseCallback, false); michael@0: michael@0: document.addEventListener("keypress", this._keyToggleCallback, false); michael@0: document.addEventListener("popupshown", this._setPopupOpen, false); michael@0: document.addEventListener("popuphidden", this._setPopupOpen, false); michael@0: // We don't animate the toolbar collapse if in DOM full-screen mode, michael@0: // as the size of the content area would still be changing after the michael@0: // mozfullscreenchange event fired, which could confuse content script. michael@0: this._shouldAnimate = !document.mozFullScreen; michael@0: this.mouseoverToggle(false); michael@0: michael@0: // Autohide prefs michael@0: gPrefService.addObserver("browser.fullscreen", this, false); michael@0: } michael@0: else { michael@0: // The user may quit fullscreen during an animation michael@0: this._cancelAnimation(); michael@0: gNavToolbox.style.marginTop = ""; michael@0: if (this._isChromeCollapsed) michael@0: this.mouseoverToggle(true); michael@0: // This is needed if they use the context menu to quit fullscreen michael@0: this._isPopupOpen = false; michael@0: michael@0: this.cleanup(); michael@0: } michael@0: }, michael@0: michael@0: exitDomFullScreen : function() { michael@0: document.mozCancelFullScreen(); michael@0: }, michael@0: michael@0: handleEvent: function (event) { michael@0: switch (event.type) { michael@0: case "activate": michael@0: if (document.mozFullScreen) { michael@0: this.showWarning(this.fullscreenDoc); michael@0: } michael@0: break; michael@0: case "transitionend": michael@0: if (event.propertyName == "opacity") michael@0: this.cancelWarning(); michael@0: break; michael@0: } michael@0: }, michael@0: michael@0: enterDomFullscreen : function(event) { michael@0: if (!document.mozFullScreen) michael@0: return; michael@0: michael@0: // However, if we receive a "MozEnteredDomFullScreen" event for a document michael@0: // which is not a subdocument of a currently active (ie. visible) browser michael@0: // or iframe, we know that we've switched to a different frame since the michael@0: // request to enter full-screen was made, so we should exit full-screen michael@0: // since the "full-screen document" isn't acutally visible. michael@0: if (!event.target.defaultView.QueryInterface(Ci.nsIInterfaceRequestor) michael@0: .getInterface(Ci.nsIWebNavigation) michael@0: .QueryInterface(Ci.nsIDocShell).isActive) { michael@0: document.mozCancelFullScreen(); michael@0: return; michael@0: } michael@0: michael@0: let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); michael@0: if (focusManager.activeWindow != window) { michael@0: // The top-level window has lost focus since the request to enter michael@0: // full-screen was made. Cancel full-screen. michael@0: document.mozCancelFullScreen(); michael@0: return; michael@0: } michael@0: michael@0: // Ensure the sidebar is hidden. michael@0: if (!document.getElementById("sidebar-box").hidden) michael@0: toggleSidebar(); michael@0: michael@0: if (gFindBarInitialized) michael@0: gFindBar.close(); michael@0: michael@0: this.showWarning(event.target); michael@0: michael@0: // Exit DOM full-screen mode upon open, close, or change tab. michael@0: gBrowser.tabContainer.addEventListener("TabOpen", this.exitDomFullScreen); michael@0: gBrowser.tabContainer.addEventListener("TabClose", this.exitDomFullScreen); michael@0: gBrowser.tabContainer.addEventListener("TabSelect", this.exitDomFullScreen); michael@0: michael@0: // Add listener to detect when the fullscreen window is re-focused. michael@0: // If a fullscreen window loses focus, we show a warning when the michael@0: // fullscreen window is refocused. michael@0: if (!this.useLionFullScreen) { michael@0: window.addEventListener("activate", this); michael@0: } michael@0: michael@0: // Cancel any "hide the toolbar" animation which is in progress, and make michael@0: // the toolbar hide immediately. michael@0: this._cancelAnimation(); michael@0: this.mouseoverToggle(false); michael@0: michael@0: // Remove listeners on the full-screen toggler, so that mouseover michael@0: // the top of the screen will not cause the toolbar to re-appear. michael@0: this._fullScrToggler.removeEventListener("mouseover", this._expandCallback, false); michael@0: this._fullScrToggler.removeEventListener("dragenter", this._expandCallback, false); michael@0: }, michael@0: michael@0: cleanup: function () { michael@0: if (window.fullScreen) { michael@0: gBrowser.mPanelContainer.removeEventListener("mousemove", michael@0: this._collapseCallback, false); michael@0: document.removeEventListener("keypress", this._keyToggleCallback, false); michael@0: document.removeEventListener("popupshown", this._setPopupOpen, false); michael@0: document.removeEventListener("popuphidden", this._setPopupOpen, false); michael@0: gPrefService.removeObserver("browser.fullscreen", this); michael@0: michael@0: this._fullScrToggler.removeEventListener("mouseover", this._expandCallback, false); michael@0: this._fullScrToggler.removeEventListener("dragenter", this._expandCallback, false); michael@0: this.cancelWarning(); michael@0: gBrowser.tabContainer.removeEventListener("TabOpen", this.exitDomFullScreen); michael@0: gBrowser.tabContainer.removeEventListener("TabClose", this.exitDomFullScreen); michael@0: gBrowser.tabContainer.removeEventListener("TabSelect", this.exitDomFullScreen); michael@0: if (!this.useLionFullScreen) michael@0: window.removeEventListener("activate", this); michael@0: this.fullscreenDoc = null; michael@0: } michael@0: }, michael@0: michael@0: observe: function(aSubject, aTopic, aData) michael@0: { michael@0: if (aData == "browser.fullscreen.autohide") { michael@0: if (gPrefService.getBoolPref("browser.fullscreen.autohide")) { michael@0: gBrowser.mPanelContainer.addEventListener("mousemove", michael@0: this._collapseCallback, false); michael@0: } michael@0: else { michael@0: gBrowser.mPanelContainer.removeEventListener("mousemove", michael@0: this._collapseCallback, false); michael@0: } michael@0: } michael@0: }, michael@0: michael@0: // Event callbacks michael@0: _expandCallback: function() michael@0: { michael@0: FullScreen.mouseoverToggle(true); michael@0: }, michael@0: _collapseCallback: function() michael@0: { michael@0: FullScreen.mouseoverToggle(false); michael@0: }, michael@0: _keyToggleCallback: function(aEvent) michael@0: { michael@0: // if we can use the keyboard (eg Ctrl+L or Ctrl+E) to open the toolbars, we michael@0: // should provide a way to collapse them too. michael@0: if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) { michael@0: FullScreen._shouldAnimate = false; michael@0: FullScreen.mouseoverToggle(false, true); michael@0: } michael@0: // F6 is another shortcut to the address bar, but its not covered in OpenLocation() michael@0: else if (aEvent.keyCode == aEvent.DOM_VK_F6) michael@0: FullScreen.mouseoverToggle(true); michael@0: }, michael@0: michael@0: // Checks whether we are allowed to collapse the chrome michael@0: _isPopupOpen: false, michael@0: _isChromeCollapsed: false, michael@0: _safeToCollapse: function(forceHide) michael@0: { michael@0: if (!gPrefService.getBoolPref("browser.fullscreen.autohide")) michael@0: return false; michael@0: michael@0: // a popup menu is open in chrome: don't collapse chrome michael@0: if (!forceHide && this._isPopupOpen) michael@0: return false; michael@0: michael@0: // a textbox in chrome is focused (location bar anyone?): don't collapse chrome michael@0: if (document.commandDispatcher.focusedElement && michael@0: document.commandDispatcher.focusedElement.ownerDocument == document && michael@0: document.commandDispatcher.focusedElement.localName == "input") { michael@0: if (forceHide) michael@0: // hidden textboxes that still have focus are bad bad bad michael@0: document.commandDispatcher.focusedElement.blur(); michael@0: else michael@0: return false; michael@0: } michael@0: return true; michael@0: }, michael@0: michael@0: _setPopupOpen: function(aEvent) michael@0: { michael@0: // Popups should only veto chrome collapsing if they were opened when the chrome was not collapsed. michael@0: // Otherwise, they would not affect chrome and the user would expect the chrome to go away. michael@0: // e.g. we wouldn't want the autoscroll icon firing this event, so when the user michael@0: // toggles chrome when moving mouse to the top, it doesn't go away again. michael@0: if (aEvent.type == "popupshown" && !FullScreen._isChromeCollapsed && michael@0: aEvent.target.localName != "tooltip" && aEvent.target.localName != "window") michael@0: FullScreen._isPopupOpen = true; michael@0: else if (aEvent.type == "popuphidden" && aEvent.target.localName != "tooltip" && michael@0: aEvent.target.localName != "window") michael@0: FullScreen._isPopupOpen = false; michael@0: }, michael@0: michael@0: // Autohide helpers for the context menu item michael@0: getAutohide: function(aItem) michael@0: { michael@0: aItem.setAttribute("checked", gPrefService.getBoolPref("browser.fullscreen.autohide")); michael@0: }, michael@0: setAutohide: function() michael@0: { michael@0: gPrefService.setBoolPref("browser.fullscreen.autohide", !gPrefService.getBoolPref("browser.fullscreen.autohide")); michael@0: }, michael@0: michael@0: // Animate the toolbars disappearing michael@0: _shouldAnimate: true, michael@0: _isAnimating: false, michael@0: _animationTimeout: 0, michael@0: _animationHandle: 0, michael@0: _animateUp: function() { michael@0: // check again, the user may have done something before the animation was due to start michael@0: if (!window.fullScreen || !this._safeToCollapse(false)) { michael@0: this._isAnimating = false; michael@0: this._shouldAnimate = true; michael@0: return; michael@0: } michael@0: michael@0: this._animateStartTime = window.mozAnimationStartTime; michael@0: if (!this._animationHandle) michael@0: this._animationHandle = window.mozRequestAnimationFrame(this); michael@0: }, michael@0: michael@0: sample: function (timeStamp) { michael@0: const duration = 1500; michael@0: const timePassed = timeStamp - this._animateStartTime; michael@0: const pos = timePassed >= duration ? 1 : michael@0: 1 - Math.pow(1 - timePassed / duration, 4); michael@0: michael@0: if (pos >= 1) { michael@0: // We've animated enough michael@0: this._cancelAnimation(); michael@0: gNavToolbox.style.marginTop = ""; michael@0: this.mouseoverToggle(false); michael@0: return; michael@0: } michael@0: michael@0: gNavToolbox.style.marginTop = (gNavToolbox.boxObject.height * pos * -1) + "px"; michael@0: this._animationHandle = window.mozRequestAnimationFrame(this); michael@0: }, michael@0: michael@0: _cancelAnimation: function() { michael@0: window.mozCancelAnimationFrame(this._animationHandle); michael@0: this._animationHandle = 0; michael@0: clearTimeout(this._animationTimeout); michael@0: this._isAnimating = false; michael@0: this._shouldAnimate = false; michael@0: }, michael@0: michael@0: cancelWarning: function(event) { michael@0: if (!this.warningBox) michael@0: return; michael@0: this.warningBox.removeEventListener("transitionend", this); michael@0: if (this.warningFadeOutTimeout) { michael@0: clearTimeout(this.warningFadeOutTimeout); michael@0: this.warningFadeOutTimeout = null; michael@0: } michael@0: michael@0: // Ensure focus switches away from the (now hidden) warning box. If the user michael@0: // clicked buttons in the fullscreen key authorization UI, it would have been michael@0: // focused, and any key events would be directed at the (now hidden) chrome michael@0: // document instead of the target document. michael@0: gBrowser.selectedBrowser.focus(); michael@0: michael@0: this.warningBox.setAttribute("hidden", true); michael@0: this.warningBox.removeAttribute("fade-warning-out"); michael@0: this.warningBox.removeAttribute("obscure-browser"); michael@0: this.warningBox = null; michael@0: }, michael@0: michael@0: setFullscreenAllowed: function(isApproved) { michael@0: // The "remember decision" checkbox is hidden when showing for documents that michael@0: // the permission manager can't handle (documents with URIs without a host). michael@0: // We simply require those to be approved every time instead. michael@0: let rememberCheckbox = document.getElementById("full-screen-remember-decision"); michael@0: let uri = this.fullscreenDoc.nodePrincipal.URI; michael@0: if (!rememberCheckbox.hidden) { michael@0: if (rememberCheckbox.checked) michael@0: Services.perms.add(uri, michael@0: "fullscreen", michael@0: isApproved ? Services.perms.ALLOW_ACTION : Services.perms.DENY_ACTION, michael@0: Services.perms.EXPIRE_NEVER); michael@0: else if (isApproved) { michael@0: // The user has only temporarily approved fullscren for this fullscreen michael@0: // session only. Add the permission (so Gecko knows to approve any further michael@0: // fullscreen requests for this host in this fullscreen session) but add michael@0: // a listener to revoke the permission when the chrome document exits michael@0: // fullscreen. michael@0: Services.perms.add(uri, michael@0: "fullscreen", michael@0: Services.perms.ALLOW_ACTION, michael@0: Services.perms.EXPIRE_SESSION); michael@0: let host = uri.host; michael@0: var onFullscreenchange = function onFullscreenchange(event) { michael@0: if (event.target == document && document.mozFullScreenElement == null) { michael@0: // The chrome document has left fullscreen. Remove the temporary permission grant. michael@0: Services.perms.remove(host, "fullscreen"); michael@0: document.removeEventListener("mozfullscreenchange", onFullscreenchange); michael@0: } michael@0: } michael@0: document.addEventListener("mozfullscreenchange", onFullscreenchange); michael@0: } michael@0: } michael@0: if (this.warningBox) michael@0: this.warningBox.setAttribute("fade-warning-out", "true"); michael@0: // If the document has been granted fullscreen, notify Gecko so it can resume michael@0: // any pending pointer lock requests, otherwise exit fullscreen; the user denied michael@0: // the fullscreen request. michael@0: if (isApproved) michael@0: Services.obs.notifyObservers(this.fullscreenDoc, "fullscreen-approved", ""); michael@0: else michael@0: document.mozCancelFullScreen(); michael@0: }, michael@0: michael@0: warningBox: null, michael@0: warningFadeOutTimeout: null, michael@0: fullscreenDoc: null, michael@0: michael@0: // Shows the fullscreen approval UI, or if the domain has already been approved michael@0: // for fullscreen, shows a warning that the site has entered fullscreen for a short michael@0: // duration. michael@0: showWarning: function(targetDoc) { michael@0: if (!document.mozFullScreen || michael@0: !gPrefService.getBoolPref("full-screen-api.approval-required")) michael@0: return; michael@0: michael@0: // Set the strings on the fullscreen approval UI. michael@0: this.fullscreenDoc = targetDoc; michael@0: let uri = this.fullscreenDoc.nodePrincipal.URI; michael@0: let host = null; michael@0: try { michael@0: host = uri.host; michael@0: } catch (e) { } michael@0: let hostLabel = document.getElementById("full-screen-domain-text"); michael@0: let rememberCheckbox = document.getElementById("full-screen-remember-decision"); michael@0: let isApproved = false; michael@0: if (host) { michael@0: // Document's principal's URI has a host. Display a warning including the hostname and michael@0: // show UI to enable the user to permanently grant this host permission to enter fullscreen. michael@0: let utils = {}; michael@0: Cu.import("resource://gre/modules/DownloadUtils.jsm", utils); michael@0: let displayHost = utils.DownloadUtils.getURIHost(uri.spec)[0]; michael@0: let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); michael@0: michael@0: hostLabel.textContent = bundle.formatStringFromName("fullscreen.entered", [displayHost], 1); michael@0: hostLabel.removeAttribute("hidden"); michael@0: michael@0: rememberCheckbox.label = bundle.formatStringFromName("fullscreen.rememberDecision", [displayHost], 1); michael@0: rememberCheckbox.checked = false; michael@0: rememberCheckbox.removeAttribute("hidden"); michael@0: michael@0: // Note we only allow documents whose principal's URI has a host to michael@0: // store permission grants. michael@0: isApproved = Services.perms.testPermission(uri, "fullscreen") == Services.perms.ALLOW_ACTION; michael@0: } else { michael@0: hostLabel.setAttribute("hidden", "true"); michael@0: rememberCheckbox.setAttribute("hidden", "true"); michael@0: } michael@0: michael@0: // Note: the warning box can be non-null if the warning box from the previous request michael@0: // wasn't hidden before another request was made. michael@0: if (!this.warningBox) { michael@0: this.warningBox = document.getElementById("full-screen-warning-container"); michael@0: // Add a listener to clean up state after the warning is hidden. michael@0: this.warningBox.addEventListener("transitionend", this); michael@0: this.warningBox.removeAttribute("hidden"); michael@0: } else { michael@0: if (this.warningFadeOutTimeout) { michael@0: clearTimeout(this.warningFadeOutTimeout); michael@0: this.warningFadeOutTimeout = null; michael@0: } michael@0: this.warningBox.removeAttribute("fade-warning-out"); michael@0: } michael@0: michael@0: // If fullscreen mode has not yet been approved for the fullscreen michael@0: // document's domain, show the approval UI and don't auto fade out the michael@0: // fullscreen warning box. Otherwise, we're just notifying of entry into michael@0: // fullscreen mode. Note if the resource's host is null, we must be michael@0: // showing a local file or a local data URI, and we require explicit michael@0: // approval every time. michael@0: let authUI = document.getElementById("full-screen-approval-pane"); michael@0: if (isApproved) { michael@0: authUI.setAttribute("hidden", "true"); michael@0: this.warningBox.removeAttribute("obscure-browser"); michael@0: } else { michael@0: // Partially obscure the element underneath the approval UI. michael@0: this.warningBox.setAttribute("obscure-browser", "true"); michael@0: authUI.removeAttribute("hidden"); michael@0: } michael@0: michael@0: // If we're not showing the fullscreen approval UI, we're just notifying the user michael@0: // of the transition, so set a timeout to fade the warning out after a few moments. michael@0: if (isApproved) michael@0: this.warningFadeOutTimeout = michael@0: setTimeout( michael@0: function() { michael@0: if (this.warningBox) michael@0: this.warningBox.setAttribute("fade-warning-out", "true"); michael@0: }.bind(this), michael@0: 3000); michael@0: }, michael@0: michael@0: mouseoverToggle: function(aShow, forceHide) michael@0: { michael@0: // Don't do anything if: michael@0: // a) we're already in the state we want, michael@0: // b) we're animating and will become collapsed soon, or michael@0: // c) we can't collapse because it would be undesirable right now michael@0: if (aShow != this._isChromeCollapsed || (!aShow && this._isAnimating) || michael@0: (!aShow && !this._safeToCollapse(forceHide))) michael@0: return; michael@0: michael@0: // browser.fullscreen.animateUp michael@0: // 0 - never animate up michael@0: // 1 - animate only for first collapse after entering fullscreen (default for perf's sake) michael@0: // 2 - animate every time it collapses michael@0: if (gPrefService.getIntPref("browser.fullscreen.animateUp") == 0) michael@0: this._shouldAnimate = false; michael@0: michael@0: if (!aShow && this._shouldAnimate) { michael@0: this._isAnimating = true; michael@0: this._shouldAnimate = false; michael@0: this._animationTimeout = setTimeout(this._animateUp.bind(this), 800); michael@0: return; michael@0: } michael@0: michael@0: // The chrome is collapsed so don't spam needless mousemove events michael@0: if (aShow) { michael@0: gBrowser.mPanelContainer.addEventListener("mousemove", michael@0: this._collapseCallback, false); michael@0: } michael@0: else { michael@0: gBrowser.mPanelContainer.removeEventListener("mousemove", michael@0: this._collapseCallback, false); michael@0: } michael@0: michael@0: // Hiding/collapsing the toolbox interferes with the tab bar's scrollbox, michael@0: // so we just move it off-screen instead. See bug 430687. michael@0: gNavToolbox.style.marginTop = michael@0: aShow ? "" : -gNavToolbox.getBoundingClientRect().height + "px"; michael@0: michael@0: this._fullScrToggler.collapsed = aShow; michael@0: this._isChromeCollapsed = !aShow; michael@0: if (gPrefService.getIntPref("browser.fullscreen.animateUp") == 2) michael@0: this._shouldAnimate = true; michael@0: }, michael@0: michael@0: showXULChrome: function(aTag, aShow) michael@0: { michael@0: var els = document.getElementsByTagNameNS(this._XULNS, aTag); michael@0: michael@0: for (let el of els) { michael@0: // XXX don't interfere with previously collapsed toolbars michael@0: if (el.getAttribute("fullscreentoolbar") == "true") { michael@0: if (!aShow) { michael@0: // Give the main nav bar and the tab bar the fullscreen context menu, michael@0: // otherwise remove context menu to prevent breakage michael@0: el.setAttribute("saved-context", el.getAttribute("context")); michael@0: if (el.id == "nav-bar" || el.id == "TabsToolbar") michael@0: el.setAttribute("context", "autohide-context"); michael@0: else michael@0: el.removeAttribute("context"); michael@0: michael@0: // Set the inFullscreen attribute to allow specific styling michael@0: // in fullscreen mode michael@0: el.setAttribute("inFullscreen", true); michael@0: } michael@0: else { michael@0: if (el.hasAttribute("saved-context")) { michael@0: el.setAttribute("context", el.getAttribute("saved-context")); michael@0: el.removeAttribute("saved-context"); michael@0: } michael@0: el.removeAttribute("inFullscreen"); michael@0: } michael@0: } else { michael@0: // use moz-collapsed so it doesn't persist hidden/collapsed, michael@0: // so that new windows don't have missing toolbars michael@0: if (aShow) michael@0: el.removeAttribute("moz-collapsed"); michael@0: else michael@0: el.setAttribute("moz-collapsed", "true"); michael@0: } michael@0: } michael@0: michael@0: if (aShow) { michael@0: gNavToolbox.removeAttribute("inFullscreen"); michael@0: document.documentElement.removeAttribute("inFullscreen"); michael@0: } else { michael@0: gNavToolbox.setAttribute("inFullscreen", true); michael@0: document.documentElement.setAttribute("inFullscreen", true); michael@0: } michael@0: michael@0: var fullscreenctls = document.getElementById("window-controls"); michael@0: var navbar = document.getElementById("nav-bar"); michael@0: var ctlsOnTabbar = window.toolbar.visible; michael@0: if (fullscreenctls.parentNode == navbar && ctlsOnTabbar) { michael@0: fullscreenctls.removeAttribute("flex"); michael@0: document.getElementById("TabsToolbar").appendChild(fullscreenctls); michael@0: } michael@0: else if (fullscreenctls.parentNode.id == "TabsToolbar" && !ctlsOnTabbar) { michael@0: fullscreenctls.setAttribute("flex", "1"); michael@0: navbar.appendChild(fullscreenctls); michael@0: } michael@0: fullscreenctls.hidden = aShow; michael@0: michael@0: ToolbarIconColor.inferFromText(); michael@0: } michael@0: }; michael@0: XPCOMUtils.defineLazyGetter(FullScreen, "useLionFullScreen", function() { michael@0: // We'll only use OS X Lion full screen if we're michael@0: // * on OS X michael@0: // * on Lion or higher (Darwin 11+) michael@0: // * have fullscreenbutton="true" michael@0: #ifdef XP_MACOSX michael@0: return parseFloat(Services.sysinfo.getProperty("version")) >= 11 && michael@0: document.documentElement.getAttribute("fullscreenbutton") == "true"; michael@0: #else michael@0: return false; michael@0: #endif michael@0: });