Bug 1386745 - Activated URL/address/location bar makes bookmark doorhanger/panelUI located under "Show site information" button area after landing patch from bug #1352063. r?Gijs draft
authorDrew Willcoxon <adw@mozilla.com>
Fri, 08 Sep 2017 10:16:38 -0700
changeset 661523 e13e609e4dd6d8f125e739035cf3011efa2f4203
parent 661321 50857982881ae7803ceb438fee90650a282f7f05
child 730614 5312fbbe7ac5ed587f4f30de210f60df8f5a1f28
push id78808
push userdwillcoxon@mozilla.com
push dateFri, 08 Sep 2017 17:17:17 +0000
reviewersGijs
bugs1386745, 1352063
milestone57.0a1
Bug 1386745 - Activated URL/address/location bar makes bookmark doorhanger/panelUI located under "Show site information" button area after landing patch from bug #1352063. r?Gijs MozReview-Commit-ID: Kzymx5qbp4i
browser/base/content/browser-places.js
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -474,33 +474,27 @@ var PlacesCommandHook = {
 
     // Revert the contents of the location bar
     gURLBar.handleRevert();
 
     // If it was not requested to open directly in "edit" mode, we are done.
     if (!aShowEditUI)
       return;
 
-    // Try to dock the panel to:
-    // 1. the bookmarks menu button
-    // 2. the identity icon
-    // 3. the content area
-    if (BookmarkingUI.anchor && isVisible(BookmarkingUI.anchor)) {
-      await StarUI.showEditBookmarkPopup(itemId, BookmarkingUI.anchor,
-                                        "bottomcenter topright", isNewBookmark, uri);
+    let anchor = BookmarkingUI.anchor;
+    if (anchor) {
+      await StarUI.showEditBookmarkPopup(itemId, anchor,
+                                         "bottomcenter topright", isNewBookmark,
+                                         uri);
       return;
     }
 
-    let identityIcon = document.getElementById("identity-icon");
-    if (isVisible(identityIcon)) {
-      await StarUI.showEditBookmarkPopup(itemId, identityIcon,
-                                        "bottomcenter topright", isNewBookmark, uri);
-    } else {
-      await StarUI.showEditBookmarkPopup(itemId, aBrowser, "overlap", isNewBookmark, uri);
-    }
+    // Fall back to showing the panel over the content area.
+    await StarUI.showEditBookmarkPopup(itemId, aBrowser, "overlap",
+                                       isNewBookmark, uri);
   },
 
   // TODO: Replace bookmarkPage code with this function once legacy
   // transactions are removed.
   async _bookmarkPagePT(aBrowser, aParentId, aShowEditUI, aUrl, aTitle) {
     // If aUrl is provided, we want to bookmark that url rather than the
     // the current page
     let url = aUrl ? new URL(aUrl) : new URL(aBrowser.currentURI.spec);
@@ -556,33 +550,26 @@ var PlacesCommandHook = {
     gURLBar.handleRevert();
 
     // If it was not requested to open directly in "edit" mode, we are done.
     if (!aShowEditUI)
       return;
 
     let node = await PlacesUIUtils.promiseNodeLikeFromFetchInfo(info);
 
-    // Try to dock the panel to:
-    // 1. the bookmarks menu button
-    // 2. the identity icon
-    // 3. the content area
-    if (BookmarkingUI.anchor && isVisible(BookmarkingUI.anchor)) {
-      await StarUI.showEditBookmarkPopup(node, BookmarkingUI.anchor,
-                                   "bottomcenter topright", isNewBookmark, url);
+    let anchor = BookmarkingUI.anchor;
+    if (anchor) {
+      await StarUI.showEditBookmarkPopup(node, anchor, "bottomcenter topright",
+                                         isNewBookmark, url);
       return;
     }
 
-    let identityIcon = document.getElementById("identity-icon");
-    if (isVisible(identityIcon)) {
-      await StarUI.showEditBookmarkPopup(node, identityIcon,
-                                   "bottomcenter topright", isNewBookmark, url);
-    } else {
-      await StarUI.showEditBookmarkPopup(node, aBrowser, "overlap", isNewBookmark, url);
-    }
+    // Fall back to showing the panel over the content area.
+    await StarUI.showEditBookmarkPopup(node, aBrowser, "overlap", isNewBookmark,
+                                       url);
   },
 
   _getPageDetails(browser) {
     return new Promise(resolve => {
       let mm = browser.messageManager;
       mm.addMessageListener("Bookmarks:GetPageDetails:Result", function listener(msg) {
         mm.removeMessageListener("Bookmarks:GetPageDetails:Result", listener);
         resolve(msg.data);
@@ -1585,31 +1572,48 @@ var LibraryUI = {
 };
 
 /**
  * Handles the bookmarks menu-button in the toolbar.
  */
 
 var BookmarkingUI = {
   STAR_ID: "star-button",
+  STAR_BOX_ID: "star-button-box",
   BOOKMARK_BUTTON_ID: "bookmarks-menu-button",
   BOOKMARK_BUTTON_SHORTCUT: "addBookmarkAsKb",
   get button() {
     delete this.button;
     let widgetGroup = CustomizableUI.getWidget(this.BOOKMARK_BUTTON_ID);
     return this.button = widgetGroup.forWindow(window).node;
   },
 
   get star() {
     delete this.star;
     return this.star = document.getElementById(this.STAR_ID);
   },
 
+  get starBox() {
+    delete this.starBox;
+    return this.starBox = document.getElementById(this.STAR_BOX_ID);
+  },
+
   get anchor() {
-    return this.star;
+    // Try to anchor the panel to:
+    // 1. The bookmarks star box (using the star itself is trickier because it
+    //    can be hidden while the star animation is visible)
+    // 2. The identity icon
+    if (this.starBox && isVisible(this.starBox)) {
+      return this.starBox;
+    }
+    let identityIcon = document.getElementById("identity-icon");
+    if (identityIcon && isVisible(identityIcon)) {
+      return identityIcon;
+    }
+    return null;
   },
 
   get notifier() {
     delete this.notifier;
     return this.notifier = document.getElementById("bookmarked-notification-anchor");
   },
 
   get dropmarkerNotifier() {