Bug 1512432 - convert richlistitem binding to Custom Element, r=bgrins
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 30 May 2019 14:12:47 +0000
changeset 476224 e09471d136599b68f40f6bb9ec7fcc419732948e
parent 476223 54163a6e927cfbcbb9ecb28e5e8cbef7998ec311
child 476225 f5b8f8b186660ba03d4e48b0df79c068524c3f74
child 476383 d2daa18c6b20e021ad3c93cd949ae11de02a0b53
push id36089
push usernbeleuzu@mozilla.com
push dateThu, 30 May 2019 21:48:30 +0000
treeherdermozilla-central@e09471d13659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1512432
milestone69.0a1
first release with
nightly linux32
e09471d13659 / 69.0a1 / 20190530214830 / files
nightly linux64
e09471d13659 / 69.0a1 / 20190530214830 / files
nightly mac
e09471d13659 / 69.0a1 / 20190530214830 / files
nightly win32
e09471d13659 / 69.0a1 / 20190530214830 / files
nightly win64
e09471d13659 / 69.0a1 / 20190530214830 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1512432 - convert richlistitem binding to Custom Element, r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D32474
toolkit/content/tests/chrome/test_richlistbox.xul
toolkit/content/widgets/richlistbox.js
toolkit/content/xul.css
--- a/toolkit/content/tests/chrome/test_richlistbox.xul
+++ b/toolkit/content/tests/chrome/test_richlistbox.xul
@@ -93,15 +93,26 @@ function test_richlistbox()
   richListBox.clearSelection();
   richListBox.selectedItem = richListBox.firstChild;
   richListBox.firstChild.nextSibling.setAttribute("disabled", true);
   richListBox.focus();
   synthesizeKey("KEY_ArrowDown", {}, window);
   is(richListBox.selectedItems.length, 1, "one item selected");
   is(richListBox.selectedItems[0], richListBox.firstChild, "first item selected");
 
+  // Selected item re-insertion should keep the item selected.
+  richListBox.clearSelection();
+  item = richListBox.firstElementChild;
+  richListBox.selectedItem = item;
+  is(richListBox.selectedItems.length, 1, "one item selected");
+  is(richListBox.selectedItems[0], item, "first item selected");
+  item.remove();
+  richListBox.append(item);
+  is(richListBox.selectedItems.length, 1, "one item selected");
+  is(richListBox.selectedItems[0], item, "last (previosly first) item selected");
+
   SimpleTest.finish();
 }
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/widgets/richlistbox.js
+++ b/toolkit/content/widgets/richlistbox.js
@@ -976,29 +976,18 @@ MozElements.MozRichlistitem = class MozR
     else
       this.removeAttribute("current");
     return val;
   }
 
   get current() {
     return this.getAttribute("current") == "true";
   }
-  disconnectedCallback() {
-    var control = this.control;
-    if (!control)
-      return;
-    // When we are destructed and we are current or selected, unselect ourselves
-    // so that richlistbox's selection doesn't point to something not in the DOM.
-    // We don't want to reset last-selected, so we set _suppressOnSelect.
-    if (this.selected) {
-      var suppressSelect = control._suppressOnSelect;
-      control._suppressOnSelect = true;
-      control.removeItemFromSelection(this);
-      control._suppressOnSelect = suppressSelect;
-    }
-    if (this.current)
-      control.currentItem = null;
-  }
 };
 
 MozXULElement.implementCustomInterface(
   MozElements.MozRichlistitem, [Ci.nsIDOMXULSelectControlItemElement]
 );
+
+// Remove documentURI check when new about:addons interface is finished, see 1554238.
+if (document.documentURI != "about:addons") {
+  customElements.define("richlistitem", MozElements.MozRichlistitem);
+}
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -604,21 +604,16 @@ wizardpage {
 
 /********** Rich Listbox ********/
 
 richlistbox {
   -moz-user-focus: normal;
   -moz-box-orient: vertical;
 }
 
-richlistitem {
-  -moz-binding: url('chrome://global/content/bindings/richlistbox.xml#richlistitem');
-}
-
-
 /*********** findbar ************/
 findbar {
   overflow-x: hidden;
 }
 
 /*********** tabmodalprompt ************/
 tabmodalprompt {
   overflow: hidden;