From c95531067db6cf9c9166ca26a54d785b96b8e00a Mon Sep 17 00:00:00 2001 From: aminomancer Date: Fri, 21 Jan 2022 22:52:24 +0000 Subject: [PATCH] Bug 1591040 - show both fullscreen and normal toolbar/tabstrip context menus in full screen, r=jaws,Gijs Differential Revision: https://phabricator.services.mozilla.com/D131493 --- .../browser-fullScreenAndPointerLock.js | 17 +-- browser/base/content/browser.js | 13 ++ browser/base/content/main-popupset.inc.xhtml | 27 ++-- browser/base/content/tabbrowser.js | 4 + .../base/content/test/fullscreen/browser.ini | 1 + .../browser_fullscreen_context_menu.js | 142 ++++++++++++++++++ 6 files changed, 180 insertions(+), 24 deletions(-) create mode 100644 browser/base/content/test/fullscreen/browser_fullscreen_context_menu.js diff --git a/browser/base/content/browser-fullScreenAndPointerLock.js b/browser/base/content/browser-fullScreenAndPointerLock.js index 8a08c7f88f9b..37cfc0fffb00 100644 --- a/browser/base/content/browser-fullScreenAndPointerLock.js +++ b/browser/base/content/browser-fullScreenAndPointerLock.js @@ -870,24 +870,11 @@ var FullScreen = { for (let el of document.querySelectorAll( "toolbar[fullscreentoolbar=true]" )) { + // Set the inFullscreen attribute to allow specific styling + // in fullscreen mode if (aEnterFS) { - // Give the main nav bar and the tab bar the fullscreen context menu, - // otherwise remove context menu to prevent breakage - el.setAttribute("saved-context", el.getAttribute("context")); - if (el.id == "nav-bar" || el.id == "TabsToolbar") { - el.setAttribute("context", "autohide-context"); - } else { - el.removeAttribute("context"); - } - - // Set the inFullscreen attribute to allow specific styling - // in fullscreen mode el.setAttribute("inFullscreen", true); } else { - if (el.hasAttribute("saved-context")) { - el.setAttribute("context", el.getAttribute("saved-context")); - el.removeAttribute("saved-context"); - } el.removeAttribute("inFullscreen"); } } diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 8544f39868ae..9a4f86720d61 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -6367,6 +6367,16 @@ nsBrowserAccess.prototype = { }, }; +function showFullScreenViewContextMenuItems(popup) { + for (let node of popup.querySelectorAll('[contexttype="fullscreen"]')) { + node.hidden = !window.fullScreen; + } + let autoHide = popup.querySelector(".fullscreen-context-autohide"); + if (autoHide) { + FullScreen.getAutohide(autoHide); + } +} + function onViewToolbarsPopupShowing(aEvent, aInsertPoint) { var popup = aEvent.target; if (popup != aEvent.currentTarget) { @@ -6418,6 +6428,9 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) { let removeFromToolbar = popup.querySelector( ".customize-context-removeFromToolbar" ); + // Show/hide fullscreen context menu items and set the + // autohide item's checked state to mirror the autohide pref. + showFullScreenViewContextMenuItems(popup); // View -> Toolbars menu doesn't have the moveToPanel or removeFromToolbar items. if (!moveToPanel || !removeFromToolbar) { return; diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml index c531d2b0ce10..01b6e51c05ed 100644 --- a/browser/base/content/main-popupset.inc.xhtml +++ b/browser/base/content/main-popupset.inc.xhtml @@ -92,6 +92,15 @@ data-lazy-l10n-id="tab-context-reopen-closed-tabs" data-l10n-args='{"tabCount": 1}' observes="History:UndoCloseTab"/> + + +