Bug 1427366 - Use richlistbox autocomplete by default. r=mak,surkov draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Wed, 07 Feb 2018 14:40:38 +0000
changeset 752106 4aa470b69bf83a84f123b71bf94e10985f86e639
parent 752021 4fe6f6560083f8c8257282bef1d4e0ced9d1b975
push id98160
push userpaolo.mozmail@amadzone.org
push dateWed, 07 Feb 2018 14:41:39 +0000
reviewersmak, surkov
bugs1427366
milestone60.0a1
Bug 1427366 - Use richlistbox autocomplete by default. r=mak,surkov MozReview-Commit-ID: BeAEWMjS6eW
accessible/tests/mochitest/tree/test_txtctrl.xul
browser/components/places/content/editBookmarkOverlay.xul
browser/components/places/tests/browser/browser_bookmarksProperties.js
toolkit/content/widgets/autocomplete.xml
toolkit/themes/linux/global/autocomplete.css
toolkit/themes/osx/global/autocomplete.css
toolkit/themes/windows/global/autocomplete.css
--- a/accessible/tests/mochitest/tree/test_txtctrl.xul
+++ b/accessible/tests/mochitest/tree/test_txtctrl.xul
@@ -111,49 +111,37 @@
                 children: []
               }
             ]
           },
           {
             // xul:menupopup
             role: ROLE_COMBOBOX_LIST,
             children: []
+          },
+          {
+            // xul:richlistbox
+            role: ROLE_COMBOBOX_LIST,
+            children: []
           }
         ]
       };
 
       function test_AutocompleteControl() {
         testAccessibleTree("txc_autocomplete", accTree);
         SimpleTest.finish();
       }
 
       var txc = document.getElementById("txc_autocomplete");
       SimpleTest.ok(txc, "Testing (New) Toolkit autocomplete widget.");
 
       // Dumb access to trigger popup lazy creation.
       dump("Trigget popup lazy creation");
       waitForEvent(EVENT_REORDER, txc, test_AutocompleteControl);
       txc.popup;
-
-      accTree.children.push(
-        {
-          role: ROLE_LIST,
-          children: [
-            {
-              role: ROLE_LIST,
-              children: [
-                {
-                  role: ROLE_COLUMNHEADER,
-                  children: []
-                }
-              ]
-            }
-          ]
-        }
-      );
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>
 
   <hbox flex="1" style="overflow: auto;">
--- a/browser/components/places/content/editBookmarkOverlay.xul
+++ b/browser/components/places/content/editBookmarkOverlay.xul
@@ -117,17 +117,18 @@
           <label value="&editBookmarkOverlay.tags.label;"
                  class="editBMPanel_rowLabel"
                  accesskey="&editBookmarkOverlay.tags.accesskey;"
                  control="editBMPanel_tagsField"/>
           <hbox flex="1" align="center">
             <textbox id="editBMPanel_tagsField"
                      type="autocomplete"
                      flex="1"
-                     autocompletesearch="places-tag-autocomplete" 
+                     autocompletesearch="places-tag-autocomplete"
+                     autocompletepopup="PopupAutoComplete"
                      completedefaultindex="true"
                      tabscrolling="true"
                      showcommentcolumn="true"
                      placeholder="&editBookmarkOverlay.tagsEmptyDesc.label;"
                      onchange="gEditItemOverlay.onTagsFieldChange();"/>
             <button id="editBMPanel_tagsSelectorExpander"
                     class="expander-down"
                     tooltiptext="&editBookmarkOverlay.tagsExpanderDown.tooltip;"
--- a/browser/components/places/tests/browser/browser_bookmarksProperties.js
+++ b/browser/components/places/tests/browser/browser_bookmarksProperties.js
@@ -99,31 +99,28 @@ gTests.push({
       handleEvent(aEvent) {
         switch (aEvent.type) {
           case "popuphidden":
             // Everything worked fine, we can stop observing the window.
             self._cleanShutdown = true;
             self.window.document.documentElement.cancelDialog();
             break;
           case "popupshown":
-            (async function() {
-              tagsField.popup.removeEventListener("popupshown", this, true);
-              // In case this test fails the window will close, the test will fail
-              // since we didn't set _cleanShutdown.
-              var tree = tagsField.popup.tree;
-              // Focus and select first result.
-              Assert.notEqual(tree, null, "Autocomplete results tree exists");
-              Assert.equal(tree.view.rowCount, 1, "We have 1 autocomplete result");
-              tagsField.popup.selectedIndex = 0;
-              Assert.equal(tree.view.selection.count, 1,
-                 "We have selected a tag from the autocomplete popup");
-              info("About to focus the autocomplete results tree");
-              tree.focus();
-              EventUtils.synthesizeKey("VK_RETURN", {}, self.window);
-            })();
+            tagsField.popup.removeEventListener("popupshown", this, true);
+            // In case this test fails the window will close, the test will fail
+            // since we didn't set _cleanShutdown.
+            let richlistbox = tagsField.popup.richlistbox;
+            // Focus and select first result.
+            Assert.equal(richlistbox.itemCount, 1, "We have 1 autocomplete result");
+            tagsField.popup.selectedIndex = 0;
+            Assert.equal(richlistbox.selectedItems.length, 1,
+               "We have selected a tag from the autocomplete popup");
+            info("About to focus the autocomplete results");
+            richlistbox.focus();
+            EventUtils.synthesizeKey("VK_RETURN", {}, self.window);
             break;
           default:
             Assert.ok(false, "unknown event: " + aEvent.type);
         }
       }
     };
     tagsField.popup.addEventListener("popupshown", popupListener, true);
     tagsField.popup.addEventListener("popuphidden", popupListener, true);
@@ -209,25 +206,24 @@ gTests.push({
             // Everything worked fine.
             self._cleanShutdown = true;
             self.window.document.documentElement.cancelDialog();
             break;
           case "popupshown":
             tagsField.popup.removeEventListener("popupshown", this, true);
             // In case this test fails the window will close, the test will fail
             // since we didn't set _cleanShutdown.
-            var tree = tagsField.popup.tree;
+            let richlistbox = tagsField.popup.richlistbox;
             // Focus and select first result.
-            Assert.notEqual(tree, null, "Autocomplete results tree exists");
-            Assert.ok(tree.view.rowCount, 1, "We have 1 autocomplete result");
+            Assert.ok(richlistbox.itemCount, 1, "We have 1 autocomplete result");
             tagsField.popup.selectedIndex = 0;
-            Assert.ok(tree.view.selection.count, 1,
+            Assert.ok(richlistbox.selectedItems.length, 1,
                "We have selected a tag from the autocomplete popup");
-            info("About to focus the autocomplete results tree");
-            tree.focus();
+            info("About to focus the autocomplete results");
+            richlistbox.focus();
             EventUtils.synthesizeKey("VK_ESCAPE", {}, self.window);
             break;
           default:
             Assert.ok(false, "unknown event: " + aEvent.type);
         }
       }
     };
     tagsField.popup.addEventListener("popupshown", popupListener, true);
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -72,17 +72,18 @@
 
           let popup = null;
           let popupId = this.getAttribute("autocompletepopup");
           if (popupId) {
             popup = document.getElementById(popupId);
           }
           if (!popup) {
             popup = document.createElement("panel");
-            popup.setAttribute("type", "autocomplete");
+            popup.setAttribute("type", "autocomplete-richlistbox");
+            popup.setAttribute("autogenerated", "true");
             popup.setAttribute("noautofocus", "true");
 
             let popupset = document.getAnonymousElementByAttribute(this, "anonid", "popupset");
             popupset.appendChild(popup);
           }
           popup.mInput = this;
 
           return this._popup = popup;
--- a/toolkit/themes/linux/global/autocomplete.css
+++ b/toolkit/themes/linux/global/autocomplete.css
@@ -135,14 +135,28 @@ html|span.ac-tag {
 .ac-separator-text,
 .ac-url-text,
 .ac-action-text,
 .ac-text-overflow-container {
   padding: 0 !important;
   margin: 0 !important;
 }
 
+/* ::::: simple richlistbox autocomplete ::::: */
+
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-type-icon,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-tags,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-separator,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-url,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-action {
+  display: none;
+}
+
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-site-icon {
+  margin-inline-start: 6px;
+}
+
 /* ::::: textboxes inside toolbarpaletteitems ::::: */
 
 toolbarpaletteitem > toolbaritem > textbox > .textbox-input-box > html|*.textbox-input,
 toolbarpaletteitem > toolbaritem > * > textbox > .textbox-input-box > html|*.textbox-input {
   visibility: hidden;
 }
--- a/toolkit/themes/osx/global/autocomplete.css
+++ b/toolkit/themes/osx/global/autocomplete.css
@@ -122,14 +122,28 @@ html|span.ac-tag {
 .ac-separator-text,
 .ac-url-text,
 .ac-action-text,
 .ac-text-overflow-container {
   padding: 0 !important;
   margin: 0 !important;
 }
 
+/* ::::: simple richlistbox autocomplete ::::: */
+
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-type-icon,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-tags,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-separator,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-url,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-action {
+  display: none;
+}
+
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-site-icon {
+  margin-inline-start: 6px;
+}
+
 /* ::::: textboxes inside toolbarpaletteitems ::::: */
 
 toolbarpaletteitem > toolbaritem > textbox > .textbox-input-box > html|*.textbox-input,
 toolbarpaletteitem > toolbaritem > * > textbox > .textbox-input-box > html|*.textbox-input {
   visibility: hidden;
 }
--- a/toolkit/themes/windows/global/autocomplete.css
+++ b/toolkit/themes/windows/global/autocomplete.css
@@ -133,15 +133,29 @@ html|span.ac-tag {
 .ac-separator-text,
 .ac-url-text,
 .ac-action-text,
 .ac-text-overflow-container {
   padding: 0 !important;
   margin: 0 !important;
 }
 
+/* ::::: simple richlistbox autocomplete ::::: */
+
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-type-icon,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-tags,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-separator,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-url,
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-action {
+  display: none;
+}
+
+panel[type="autocomplete-richlistbox"][autogenerated] > .autocomplete-richlistbox > .autocomplete-richlistitem > .ac-site-icon {
+  margin-inline-start: 6px;
+}
+
 /* ::::: textboxes inside toolbarpaletteitems ::::: */
 
 toolbarpaletteitem > toolbaritem > textbox > .textbox-input-box> html|*.textbox-input,
 toolbarpaletteitem > toolbaritem > * > textbox > .textbox-input-box > html|*.textbox-input {
   visibility: hidden;
 }