Bug 1534939 - Quantumbar: Force the first result's title to be LTR when typing a URL. r=dao
authorDrew Willcoxon <adw@mozilla.com>
Tue, 07 May 2019 16:39:04 +0000
changeset 534800 28fa627eb8e9b430526a1d8d302e0ccdaef22d73
parent 534799 264bdfcb9ebb54017a4abc88b870def85e486de8
child 534801 fc0f97c01c6a68139af6e2c90f40cc3bfd870867
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1534939
milestone68.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 1534939 - Quantumbar: Force the first result's title to be LTR when typing a URL. r=dao Set an "isurl" attribute on the title and force it to be LTR. Differential Revision: https://phabricator.services.mozilla.com/D30149
browser/components/urlbar/UrlbarView.jsm
browser/themes/shared/urlbar-autocomplete.inc.css
--- a/browser/components/urlbar/UrlbarView.jsm
+++ b/browser/components/urlbar/UrlbarView.jsm
@@ -474,70 +474,79 @@ class UrlbarView {
     let favicon = item._elements.get("favicon");
     if (result.type == UrlbarUtils.RESULT_TYPE.SEARCH ||
         result.type == UrlbarUtils.RESULT_TYPE.KEYWORD) {
       favicon.src = result.payload.icon || UrlbarUtils.ICON.SEARCH_GLASS;
     } else {
       favicon.src = result.payload.icon || UrlbarUtils.ICON.DEFAULT;
     }
 
+    let title = item._elements.get("title");
     this._addTextContentWithHighlights(
-      item._elements.get("title"), result.title, result.titleHighlights);
+      title, result.title, result.titleHighlights);
 
     let tagsContainer = item._elements.get("tagsContainer");
     tagsContainer.textContent = "";
     if (result.payload.tags && result.payload.tags.length > 0) {
       tagsContainer.append(...result.payload.tags.map((tag, i) => {
         const element = this._createElement("span");
         element.className = "urlbarView-tag";
         this._addTextContentWithHighlights(
           element, tag, result.payloadHighlights.tags[i]);
         return element;
       }));
     }
 
     let action = "";
+    let isVisitAction = false;
     let setURL = false;
     switch (result.type) {
       case UrlbarUtils.RESULT_TYPE.TAB_SWITCH:
         action = bundle.GetStringFromName("switchToTab2");
         setURL = true;
         break;
       case UrlbarUtils.RESULT_TYPE.REMOTE_TAB:
         action = result.payload.device;
         setURL = true;
         break;
       case UrlbarUtils.RESULT_TYPE.SEARCH:
         action = bundle.formatStringFromName("searchWithEngine",
                                              [result.payload.engine], 1);
         break;
       case UrlbarUtils.RESULT_TYPE.KEYWORD:
-        if (result.payload.input.trim() == result.payload.keyword) {
-          action = bundle.GetStringFromName("visit");
-        }
+        isVisitAction = result.payload.input.trim() == result.payload.keyword;
         break;
       case UrlbarUtils.RESULT_TYPE.OMNIBOX:
         action = result.payload.content;
         break;
       default:
         if (result.heuristic) {
-          action = bundle.GetStringFromName("visit");
+          isVisitAction = true;
         } else {
           setURL = true;
         }
         break;
     }
+
     let url = item._elements.get("url");
     if (setURL) {
       this._addTextContentWithHighlights(url, result.payload.displayUrl,
                                          result.payloadHighlights.displayUrl || []);
     } else {
       url.textContent = "";
     }
+
+    if (isVisitAction) {
+      action = bundle.GetStringFromName("visit");
+      title.setAttribute("isurl", "true");
+    } else {
+      title.removeAttribute("isurl");
+    }
     item._elements.get("action").textContent = action;
+
     item._elements.get("titleSeparator").hidden = !action && !setURL;
   }
 
   _removeStaleRows() {
     let row = this._rows.lastElementChild;
     while (row) {
       let next = row.previousElementSibling;
       if (row.hasAttribute("stale")) {
--- a/browser/themes/shared/urlbar-autocomplete.inc.css
+++ b/browser/themes/shared/urlbar-autocomplete.inc.css
@@ -67,20 +67,25 @@
   justify-content: start;
 }
 
 .urlbarView-title[overflow],
 .urlbarView-url[overflow] {
   mask-image: linear-gradient(to left, transparent, black 2em);
 }
 
-.urlbarView-title[overflow]:-moz-locale-dir(rtl) {
+.urlbarView-title[overflow]:not([isurl]):-moz-locale-dir(rtl) {
   mask-image: linear-gradient(to right, transparent, black 2em);
 }
 
+.urlbarView-title[isurl]:-moz-locale-dir(rtl),
+.urlbarView-url:-moz-locale-dir(rtl) {
+  direction: ltr !important;
+}
+
 .urlbarView-row:hover {
   background: var(--arrowpanel-dimmed);
 }
 
 .urlbarView-row[selected] {
   background: var(--autocomplete-popup-highlight-background);
   color: var(--autocomplete-popup-highlight-color);
   fill-opacity: 1;
@@ -151,20 +156,16 @@
   color: var(--urlbar-popup-action-color);
 }
 
 .urlbarView-url {
   overflow: hidden;
   color: var(--urlbar-popup-url-color);
 }
 
-.urlbarView-url:-moz-locale-dir(rtl) {
-  direction: ltr !important;
-}
-
 .urlbarView-row[selected] > .urlbarView-row-inner > .urlbarView-title-separator::before,
 .urlbarView-row[selected] > .urlbarView-row-inner > .urlbarView-secondary {
   color: inherit;
 }
 
 .urlbarView-row[type=remotetab][selected] > .urlbarView-row-inner > .urlbarView-action,
 .urlbarView-row[type=remotetab]:hover > .urlbarView-row-inner > .urlbarView-action,
 .urlbarView-row[type=remotetab]:not([selected]):not(:hover) > .urlbarView-row-inner > .urlbarView-url,