Bug 1589826 - Remove the megabar's "focused & collapsed" state. r=mak
authorHarry Twyford <htwyford@mozilla.com>
Tue, 05 Nov 2019 15:21:29 +0000
changeset 500684 8b79d4ccb76e0a85a1f9de2933b4c16665065c82
parent 500683 e6fa62187db798c6c58c2bf973cc453768047b67
child 500685 af59b0e5851cfa43f709449bd2b0cb4950424640
push id36769
push userncsoregi@mozilla.com
push dateWed, 06 Nov 2019 09:57:42 +0000
treeherdermozilla-central@d73cfe3a04e9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1589826
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1589826 - Remove the megabar's "focused & collapsed" state. r=mak Differential Revision: https://phabricator.services.mozilla.com/D49824
browser/components/urlbar/UrlbarController.jsm
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/tests/browser/browser.ini
browser/components/urlbar/tests/browser/browser_urlbar_collapseOnChromeMousedown.js
browser/themes/linux/browser.css
browser/themes/osx/browser.css
browser/themes/windows/browser.css
--- a/browser/components/urlbar/UrlbarController.jsm
+++ b/browser/components/urlbar/UrlbarController.jsm
@@ -297,17 +297,16 @@ class UrlbarController {
 
     switch (event.keyCode) {
       case KeyEvent.DOM_VK_ESCAPE:
         if (executeAction) {
           if (this.view.isOpen) {
             this.view.close();
           } else {
             this.input.handleRevert();
-            this.input.endLayoutExtend(true);
           }
         }
         event.preventDefault();
         break;
       case KeyEvent.DOM_VK_RETURN:
         if (executeAction) {
           this.input.handleCommand(event);
         }
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -1004,21 +1004,21 @@ class UrlbarInput {
       this.window.promiseDocumentFlushed(() => {
         this.window.requestAnimationFrame(() => {
           this.setAttribute("breakout-extend-animate", "true");
         });
       });
     }
   }
 
-  endLayoutExtend(force) {
+  endLayoutExtend() {
     if (
       !this.hasAttribute("breakout-extend") ||
       this.view.isOpen ||
-      (!force && this.getAttribute("focused") == "true")
+      this.getAttribute("focused") == "true"
     ) {
       return;
     }
     this.removeAttribute("breakout-extend");
     if (this._toolbar) {
       this._toolbar.removeAttribute("urlbar-exceeds-toolbar-bounds");
     }
   }
@@ -1741,20 +1741,21 @@ class UrlbarInput {
   _on_focus(event) {
     if (!this._hideFocus) {
       this.setAttribute("focused", "true");
     }
 
     // We handle mouse-based expansion events separately in _on_click.
     if (this._focusedViaMousedown) {
       this._focusedViaMousedown = false;
-    } else if (this.inputField.hasAttribute("refocused-by-panel")) {
-      this._maybeSelectAll(true);
     } else {
       this.startLayoutExtend();
+      if (this.inputField.hasAttribute("refocused-by-panel")) {
+        this._maybeSelectAll(true);
+      }
     }
 
     this._updateUrlTooltip();
     this.formatValue();
 
     // Hide popup notifications, to reduce visual noise.
     if (this.getAttribute("pageproxystate") != "valid") {
       this.window.UpdatePopupNotificationsVisibility();
@@ -1829,27 +1830,17 @@ class UrlbarInput {
 
         // Close the view when clicking on toolbars and other UI pieces that might
         // not automatically remove focus from the input.
         // Respect the autohide preference for easier inspecting/debugging via
         // the browser toolbox.
         if (!UrlbarPrefs.get("ui.popup.disable_autohide")) {
           this.view.close();
         }
-
-        if (
-          event.target.id == "tabs-newtab-button" ||
-          event.target.id == "new-tab-button" ||
-          event.target.classList.contains("tab-close-button")
-        ) {
-          break;
-        }
-
-        // We collapse the urlbar for any clicks outside of it.
-        this.endLayoutExtend(true);
+        break;
     }
   }
 
   _on_input(event) {
     let value = this.value;
     this.valueIsTyped = true;
     this._untrimmedValue = value;
     this.window.gBrowser.userTypedValue = value;
--- a/browser/components/urlbar/tests/browser/browser.ini
+++ b/browser/components/urlbar/tests/browser/browser.ini
@@ -112,17 +112,16 @@ support-files =
 support-files =
   moz.png
 [browser_textruns.js]
 [browser_tip_selection.js]
 [browser_updateRows.js]
 [browser_urlbar_blanking.js]
 support-files =
   file_blank_but_not_blank.html
-[browser_urlbar_collapseOnChromeMousedown.js]
 [browser_urlbar_content_opener.js]
 [browser_urlbar_copy_during_load.js]
 support-files =
   slow-page.sjs
 [browser_urlbar_display_selectedAction_Extensions.js]
 [browser_urlbar_empty_search.js]
 [browser_urlbar_event_telemetry.js]
 support-files =
deleted file mode 100644
--- a/browser/components/urlbar/tests/browser/browser_urlbar_collapseOnChromeMousedown.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const MEGABAR_PREF = "browser.urlbar.megabar";
-
-add_task(async function() {
-  Services.prefs.setBoolPref(MEGABAR_PREF, true);
-  // We need to open a new window for the Megabar to kick in. This can be
-  // removed when the Megabar is on by default.
-  let win = await BrowserTestUtils.openNewBrowserWindow();
-  registerCleanupFunction(() => {
-    BrowserTestUtils.closeWindow(win);
-    Services.prefs.clearUserPref(MEGABAR_PREF);
-  });
-
-  win.gURLBar.focus();
-  Assert.ok(
-    win.gURLBar.hasAttribute("breakout-extend"),
-    "The Urlbar should have the breakout-extend attribute."
-  );
-  EventUtils.synthesizeMouseAtCenter(win.gURLBar.textbox, {}, win);
-  Assert.ok(
-    win.gURLBar.hasAttribute("breakout-extend"),
-    "The Urlbar should have the breakout-extend attribute."
-  );
-
-  // We just want a non-interactive part of the UI.
-  let chromeTarget = win.gURLBar.textbox
-    .closest("toolbar")
-    .querySelector("toolbarspring");
-  EventUtils.synthesizeMouseAtCenter(chromeTarget, {}, win);
-  Assert.ok(
-    !win.gURLBar.hasAttribute("breakout-extend"),
-    "The Urlbar should not have the breakout-extend attribute."
-  );
-  Assert.ok(win.gURLBar.focused, "The Urlbar should be focused.");
-});
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -372,17 +372,19 @@ notification[value="translation"] menuli
 #context_closeTab {
   list-style-image: url("moz-icon://stock/gtk-close?size=menu");
 }
 
 /* Tab drag and drop */
 .tab-drop-indicator {
   list-style-image: url(chrome://browser/skin/tabbrowser/tabDragIndicator.png);
   margin-bottom: -9px;
-  z-index: 3;
+  /* The z-index needs to be big enough to trump other positioned UI pieces
+     that we want to overlay. The expanded urlbar uses 3. */
+  z-index: 4;
 }
 
 /* All tabs menupopup */
 
 .alltabs-item[selected="true"] {
   font-weight: bold;
 }
 
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -609,17 +609,19 @@
 
 .tab-drop-indicator-box {
   -moz-box-align: center;
 }
 
 .tab-drop-indicator {
   list-style-image: url(chrome://browser/skin/tabbrowser/tabDragIndicator.png);
   margin-top: -2px;
-  z-index: 3;
+  /* The z-index needs to be big enough to trump other positioned UI pieces
+     that we want to overlay. The expanded urlbar uses 3. */
+  z-index: 4;
 }
 
 @media (min-resolution: 2dppx) {
   .tab-drop-indicator {
     list-style-image: url(chrome://browser/skin/tabbrowser/tabDragIndicator@2x.png);
     width: 12px;
   }
 }
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -602,17 +602,19 @@ menuitem.bookmark-item {
   outline: 1px dotted;
   outline-offset: -6px;
 }
 
 /* Tab DnD indicator */
 .tab-drop-indicator {
   list-style-image: url(chrome://browser/skin/tabbrowser/tabDragIndicator.png);
   margin-bottom: -9px;
-  z-index: 3;
+  /* The z-index needs to be big enough to trump other positioned UI pieces
+     that we want to overlay. The expanded urlbar uses 3. */
+  z-index: 4;
 }
 
 /* All tabs menupopup */
 
 .alltabs-item[selected="true"] {
   font-weight: bold;
 }