Bug 1446982 - Show the url when a remote tab entry is selected/hovered in the Address Bar. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 06 Apr 2018 17:43:18 +0200
changeset 413214 7cc86dc1bbc8fb7d935b258fe5dcebb059a323cc
parent 413213 c4bee2eae27cf8476d09a2c8df9009e63a7a5d91
child 413215 f60708e61cf434567254e890126a0602fbfd7f27
push id62638
push usermak77@bonardo.net
push dateFri, 13 Apr 2018 16:13:03 +0000
treeherderautoland@7cc86dc1bbc8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1446982
milestone61.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 1446982 - Show the url when a remote tab entry is selected/hovered in the Address Bar. r=adw MozReview-Commit-ID: 63fmwkESd4w
browser/base/content/browser.css
toolkit/content/widgets/autocomplete.xml
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -621,20 +621,28 @@ html|input.urlbar-input[textoverflow]:no
 
 /* For non-action items, hide the action text; for action items, hide the URL
    text. Don't show the separator for keyword results. */
 #PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-type-icon,
 #PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-site-icon,
 #PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-tags:not([empty]),
 #PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-separator:not([type=keyword]),
 #PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-url:not([actiontype]),
-#PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-action[actiontype] {
+#PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-action[actiontype],
+#PopupAutoCompleteRichResult > richlistbox > richlistitem[selected] > .ac-url[actiontype=remotetab],
+#PopupAutoCompleteRichResult > richlistbox > richlistitem:hover > .ac-url[actiontype=remotetab]
+{
   display: -moz-box;
 }
 
+#PopupAutoCompleteRichResult > richlistbox > richlistitem[selected] > .ac-action[actiontype=remotetab],
+#PopupAutoCompleteRichResult > richlistbox > richlistitem:hover > .ac-action[actiontype=remotetab] {
+  display: none;
+}
+
 /* Only show the "Search with" label on hover or selection. */
 #PopupAutoCompleteRichResult > richlistbox > richlistitem:not([selected]):not(:hover) > .ac-action[actiontype=searchengine],
 #PopupAutoCompleteRichResult > richlistbox > richlistitem:not([selected]):not(:hover) > .ac-separator[actiontype=searchengine] {
   display: none;
 }
 
 #PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-site-icon {
   margin-inline-start: 0;
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1806,58 +1806,62 @@
           let title = this.getAttribute("ac-comment");
           this.setAttribute("url", originalUrl);
           this.setAttribute("image", this.getAttribute("ac-image"));
           this.setAttribute("title", title);
           this.setAttribute("text", this.getAttribute("ac-text"));
 
           let popup = this.parentNode.parentNode;
           let titleLooksLikeUrl = false;
-          let displayUrl;
+          let displayUrl = originalUrl;
           let emphasiseUrl = true;
+          let trimDisplayUrl = true;
 
           let type = this.getAttribute("originaltype");
           let types = new Set(type.split(/\s+/));
           let initialTypes = new Set(types);
           // Remove types that should ultimately not be in the `type` string.
           types.delete("action");
           types.delete("autofill");
           types.delete("heuristic");
           type = [...types][0] || "";
 
           let action;
 
           if (initialTypes.has("autofill")) {
             // Treat autofills as visiturl actions.
             action = {
               type: "visiturl",
-              params: {
-                url: this.getAttribute("title"),
-              },
+              params: { url: title },
             };
           }
 
           this.removeAttribute("actiontype");
           this.classList.remove("overridable-action");
 
           // If the type includes an action, set up the item appropriately.
           if (initialTypes.has("action") || action) {
             action = action || this._parseActionUrl(originalUrl);
             this.setAttribute("actiontype", action.type);
 
-            if (action.type == "switchtab") {
+            switch (action.type) {
+            case "switchtab": {
               this.classList.add("overridable-action");
-              displayUrl = this._unescapeUrl(action.params.url);
+              displayUrl = action.params.url;
               let desc = this._stringBundle.GetStringFromName("switchToTab2");
               this._setUpDescription(this._actionText, desc, true);
-            } else if (action.type == "remotetab") {
-              displayUrl = this._unescapeUrl(action.params.url);
+              break;
+            }
+            case "remotetab": {
+              displayUrl = action.params.url;
               let desc = action.params.deviceName;
               this._setUpDescription(this._actionText, desc, true);
-            } else if (action.type == "searchengine") {
+              break;
+            }
+            case "searchengine": {
               emphasiseUrl = false;
 
               // The order here is not localizable, we default to appending
               // "- Search with Engine" to the search string, to be able to
               // properly generate emphasis pairs. That said, no localization
               // changed the order while it was possible, so doesn't look like
               // there's a strong need for that.
               let {engineName, searchSuggestion, searchQuery} = action.params;
@@ -1909,53 +1913,59 @@
               // can style it ourselves with a generic search icon.
               // We don't do this when matching an aliased search engine,
               // because the icon helps with recognising which engine will be
               // used (when using the default engine, we don't need that
               // recognition).
               if (!action.params.alias && !initialTypes.has("favicon")) {
                 this.removeAttribute("image");
               }
-            } else if (action.type == "visiturl") {
+              break;
+            }
+            case "visiturl": {
               emphasiseUrl = false;
-              displayUrl = this._unescapeUrl(action.params.url);
-              title = displayUrl;
+              displayUrl = action.params.url;
               titleLooksLikeUrl = true;
               let visitStr = this._stringBundle.GetStringFromName("visit");
               this._setUpDescription(this._actionText, visitStr, true);
-            } else if (action.type == "extension") {
+              break;
+            }
+            case "extension": {
               let content = action.params.content;
               displayUrl = content;
+              trimDisplayUrl = false;
               this._setUpDescription(this._actionText, content, true);
+              break;
+            }
             }
           }
 
-          if (!displayUrl) {
+          if (trimDisplayUrl) {
             let input = popup.input;
-            let url = typeof(input.trimValue) == "function" ?
-                      input.trimValue(originalUrl) :
-                      originalUrl;
-            displayUrl = this._unescapeUrl(url);
+            if (typeof input.trimValue == "function")
+              displayUrl = input.trimValue(displayUrl);
+            displayUrl = this._unescapeUrl(displayUrl);
           }
           // For performance reasons we may want to limit the displayUrl size.
           if (popup.textRunsMaxLen) {
             displayUrl = displayUrl.substr(0, popup.textRunsMaxLen);
           }
           this.setAttribute("displayurl", displayUrl);
 
           // Show the domain as the title if we don't have a title.
           if (!title) {
-            title = displayUrl;
             titleLooksLikeUrl = true;
             try {
               let uri = Services.io.newURI(originalUrl);
               // Not all valid URLs have a domain.
               if (uri.host)
                 title = uri.host;
             } catch (e) {}
+            if (!title)
+              title = displayUrl;
           }
 
           this._tags.setAttribute("empty", "true");
 
           if (type == "tag" || type == "bookmark-tag") {
             // The title is separated from the tags by an endash
             let tags;
             [, title, tags] = title.match(/^(.+) \u2013 (.+)$/);