Bug 1583531 - add in-bookmarks-menu class for arrowscrollboxes to adjust padding in bookmarks submenus r=bgrins
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 17 Oct 2019 18:23:44 +0000
changeset 559396 1f285b3386fa01b242fc3c9947ac50876973652b
parent 559395 650273d192077a93007e509e7d7ec6690d84ee87
child 559397 28e214b713438e55208b8f78ca32ea5a21630c4f
push id12177
push usercsabou@mozilla.com
push dateMon, 21 Oct 2019 14:52:16 +0000
treeherdermozilla-beta@1918a9cd33bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1583531
milestone71.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 1583531 - add in-bookmarks-menu class for arrowscrollboxes to adjust padding in bookmarks submenus r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D49633
browser/components/places/content/places-menupopup.js
toolkit/content/widgets/menupopup.js
toolkit/themes/windows/global/scrollbox.css
--- a/browser/components/places/content/places-menupopup.js
+++ b/browser/components/places/content/places-menupopup.js
@@ -42,16 +42,23 @@
         <arrowscrollbox class="popup-internal-box" flex="1" orient="vertical"
                         smoothscroll="false" part="popupbox">
           <html:slot></html:slot>
         </arrowscrollbox>
       </hbox>
     `;
     }
 
+    initShadowDOM() {
+      super.initShadowDOM();
+      if (this.closest("#BMB_bookmarksPopup")) {
+        this.scrollBox.classList.add("in-bookmarks-menu");
+      }
+    }
+
     connectedCallback() {
       if (this.delayConnectedCallback()) {
         return;
       }
 
       /**
        * Sub-menus should be opened when the mouse drags over them, and closed
        * when the mouse drags off.  The overFolder object manages opening and
--- a/toolkit/content/widgets/menupopup.js
+++ b/toolkit/content/widgets/menupopup.js
@@ -40,36 +40,37 @@
       }
 
       this.hasConnected = true;
       if (this.parentNode && this.parentNode.localName == "menulist") {
         this._setUpMenulistPopup();
       }
     }
 
+    initShadowDOM() {
+      // Retarget events from shadow DOM arrowscrollbox to the host.
+      this.scrollBox.addEventListener("scroll", ev =>
+        this.dispatchEvent(new Event("scroll"))
+      );
+      this.scrollBox.addEventListener("overflow", ev =>
+        this.dispatchEvent(new Event("overflow"))
+      );
+      this.scrollBox.addEventListener("underflow", ev =>
+        this.dispatchEvent(new Event("underflow"))
+      );
+      this.scrollBox._scrollButtonUp.classList.add("menupopup-scrollbutton");
+      this.scrollBox._scrollButtonDown.classList.add("menupopup-scrollbutton");
+    }
+
     get shadowRoot() {
       // We generate shadow DOM lazily on popupshowing event to avoid extra load
       // on the system during browser startup.
       if (!super.shadowRoot.firstElementChild) {
         super.shadowRoot.appendChild(this.fragment);
-
-        // Retarget events from shadow DOM arrowscrollbox to the host.
-        this.scrollBox.addEventListener("scroll", ev =>
-          this.dispatchEvent(new Event("scroll"))
-        );
-        this.scrollBox.addEventListener("overflow", ev =>
-          this.dispatchEvent(new Event("overflow"))
-        );
-        this.scrollBox.addEventListener("underflow", ev =>
-          this.dispatchEvent(new Event("underflow"))
-        );
-        this.scrollBox._scrollButtonUp.classList.add("menupopup-scrollbutton");
-        this.scrollBox._scrollButtonDown.classList.add(
-          "menupopup-scrollbutton"
-        );
+        this.initShadowDOM();
       }
       return super.shadowRoot;
     }
 
     get fragment() {
       if (!this.constructor.hasOwnProperty("_fragment")) {
         this.constructor._fragment = MozXULElement.parseXULToFragment(
           this.markup
--- a/toolkit/themes/windows/global/scrollbox.css
+++ b/toolkit/themes/windows/global/scrollbox.css
@@ -6,16 +6,22 @@
 
 arrowscrollbox[scrolledtoend=true]::part(arrowscrollbox-overflow-end-indicator),
 arrowscrollbox[scrolledtostart=true]::part(arrowscrollbox-overflow-start-indicator),
 arrowscrollbox[notoverflowing=true]::part(scrollbutton-up),
 arrowscrollbox[notoverflowing=true]::part(scrollbutton-down) {
   visibility: collapse;
 }
 
+/* Add some space at the top because there are no headers in menupopups of
+ the bookmarks menu. */
+arrowscrollbox.in-bookmarks-menu::part(scrollbox) {
+  padding-top: 4px;
+}
+
 /*
  * Scroll arrows
  */
 
 /* Horizontal enabled */
 .scrollbutton-up[orient="horizontal"],
 .scrollbutton-down:-moz-locale-dir(rtl)[orient="horizontal"] {
   list-style-image: url("chrome://global/skin/arrow/arrow-lft.gif");