Bug 1477525 part 1 - Merge the logic of _safeToCollapse into hideNavToolbox. r?dao draft
authorXidorn Quan <me@upsuper.org>
Mon, 23 Jul 2018 10:59:23 +1000
changeset 821337 d6a28c3be45477295d106ab7071dba34efff8e57
parent 821334 49a0290d1a95286236e95573705b538215a21ab5
child 821338 29e4f086058230b8ad243c6a86dca79ac650af78
push id117066
push userxquan@mozilla.com
push dateMon, 23 Jul 2018 01:12:09 +0000
reviewersdao
bugs1477525
milestone63.0a1
Bug 1477525 part 1 - Merge the logic of _safeToCollapse into hideNavToolbox. r?dao MozReview-Commit-ID: 1SEUVGprmv3
browser/base/content/browser-fullScreenAndPointerLock.js
--- a/browser/base/content/browser-fullScreenAndPointerLock.js
+++ b/browser/base/content/browser-fullScreenAndPointerLock.js
@@ -517,37 +517,16 @@ var FullScreen = {
       // F6 is another shortcut to the address bar, but its not covered in OpenLocation()
       FullScreen.showNavToolbox();
     }
   },
 
   // Checks whether we are allowed to collapse the chrome
   _isPopupOpen: false,
   _isChromeCollapsed: false,
-  _safeToCollapse() {
-    if (!Services.prefs.getBoolPref("browser.fullscreen.autohide"))
-      return false;
-
-    // a popup menu is open in chrome: don't collapse chrome
-    if (this._isPopupOpen)
-      return false;
-
-    // On OS X Lion we don't want to hide toolbars.
-    if (this.useLionFullScreen)
-      return false;
-
-    // a textbox in chrome is focused (location bar anyone?): don't collapse chrome
-    if (document.commandDispatcher.focusedElement &&
-        document.commandDispatcher.focusedElement.ownerDocument == document &&
-        document.commandDispatcher.focusedElement.localName == "input") {
-      return false;
-    }
-
-    return true;
-  },
 
   _setPopupOpen(aEvent) {
     // Popups should only veto chrome collapsing if they were opened when the chrome was not collapsed.
     // Otherwise, they would not affect chrome and the user would expect the chrome to go away.
     // e.g. we wouldn't want the autoscroll icon firing this event, so when the user
     // toggles chrome when moving mouse to the top, it doesn't go away again.
     if (aEvent.type == "popupshown" && !FullScreen._isChromeCollapsed &&
         aEvent.target.localName != "tooltip" && aEvent.target.localName != "window" &&
@@ -596,18 +575,37 @@ var FullScreen = {
       MousePosTracker.addListener(this);
     }
 
     this._isChromeCollapsed = false;
     Services.obs.notifyObservers(null, "fullscreen-nav-toolbox", "shown");
   },
 
   hideNavToolbox(aAnimate = false) {
-    if (this._isChromeCollapsed || !this._safeToCollapse())
+    if (this._isChromeCollapsed) {
+      return;
+    }
+    if (!Services.prefs.getBoolPref("browser.fullscreen.autohide")) {
+      return;
+    }
+    // a popup menu is open in chrome: don't collapse chrome
+    if (this._isPopupOpen) {
       return;
+    }
+    // On OS X Lion we don't want to hide toolbars.
+    if (this.useLionFullScreen) {
+      return;
+    }
+
+    // a textbox in chrome is focused (location bar anyone?): don't collapse chrome
+    if (document.commandDispatcher.focusedElement &&
+        document.commandDispatcher.focusedElement.ownerDocument == document &&
+        document.commandDispatcher.focusedElement.localName == "input") {
+      return;
+    }
 
     this._fullScrToggler.hidden = false;
 
     if (aAnimate && Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled")) {
       gNavToolbox.setAttribute("fullscreenShouldAnimate", true);
       // Hide the fullscreen toggler until the transition ends.
       let listener = () => {
         gNavToolbox.removeEventListener("transitionend", listener, true);