fxr-fullScreen.js (2034B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 2 * This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 // fxr-fullScreen.js is a provisional, stripped-down clone of 7 // browser\base\content\browser-fullScreenAndPointerLock.js 8 // that is adapted for Firefox Reality on Desktop. 9 // The bug to track its removal is 10 // Bug 1587946 - Rationalize the fork of browser-fullScreenAndPointerLock.js 11 12 var FullScreen = { 13 init() { 14 // Called when the Firefox window go into fullscreen. 15 addEventListener("fullscreen", this, true); 16 17 if (window.fullScreen) { 18 this.toggle(); 19 } 20 }, 21 22 toggle() { 23 var enterFS = window.fullScreen; 24 if (enterFS) { 25 document.documentElement.setAttribute("inFullscreen", true); 26 } else { 27 document.documentElement.removeAttribute("inFullscreen"); 28 } 29 }, 30 31 handleEvent(event) { 32 if (event.type === "fullscreen") { 33 this.toggle(); 34 } 35 }, 36 37 enterDomFullscreen(aBrowser, aActor) { 38 if (!document.fullscreenElement) { 39 return; 40 } 41 42 // If it is a remote browser, send a message to ask the content 43 // to enter fullscreen state. We don't need to do so if it is an 44 // in-process browser, since all related document should have 45 // entered fullscreen state at this point. 46 // This should be done before the active tab check below to ensure 47 // that the content document handles the pending request. Doing so 48 // before the check is fine since we also check the activeness of 49 // the requesting document in content-side handling code. 50 if (aBrowser.isRemoteBrowser) { 51 aActor.sendAsyncMessage("DOMFullscreen:Entered", {}); 52 } 53 54 document.documentElement.setAttribute("inDOMFullscreen", true); 55 }, 56 57 cleanupDomFullscreen(aActor) { 58 aActor.sendAsyncMessage("DOMFullscreen:CleanUp", {}); 59 document.documentElement.removeAttribute("inDOMFullscreen"); 60 }, 61 };