Backed out changeset 48ba27830041 (bug 1263887)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 22 Apr 2016 00:39:29 +0200
changeset 332265 4b16c1609af583175b109386fa5d4c2afc74e206
parent 332264 c550088d726eeaa1b4c0399a8d00f70bfa20e4b9
child 332266 78b83b86b1aabf320f34a2c2942499864867530b
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1263887
milestone48.0a1
backs out48ba2783004140f0331ffd4764363b5b0040f127
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
Backed out changeset 48ba27830041 (bug 1263887)
toolkit/modules/SelectContentHelper.jsm
toolkit/modules/SelectParentHelper.jsm
--- a/toolkit/modules/SelectContentHelper.jsm
+++ b/toolkit/modules/SelectContentHelper.jsm
@@ -9,62 +9,50 @@ const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
                                   "resource://gre/modules/BrowserUtils.jsm");
 XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils",
                                    "@mozilla.org/inspector/dom-utils;1", "inIDOMUtils");
-XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask",
-                                  "resource://gre/modules/DeferredTask.jsm");
 
 const kStateHover = 0x00000004; // NS_EVENT_STATE_HOVER
 
 this.EXPORTED_SYMBOLS = [
   "SelectContentHelper"
 ];
 
 this.SelectContentHelper = function (aElement, aGlobal) {
   this.element = aElement;
   this.initialSelection = aElement[aElement.selectedIndex] || null;
   this.global = aGlobal;
   this.init();
   this.showDropDown();
-  this._updateTimer = new DeferredTask(this._update.bind(this), 0);
 }
 
 this.SelectContentHelper.prototype = {
   init: function() {
     this.global.addMessageListener("Forms:SelectDropDownItem", this);
     this.global.addMessageListener("Forms:DismissedDropDown", this);
     this.global.addMessageListener("Forms:MouseOver", this);
     this.global.addMessageListener("Forms:MouseOut", this);
     this.global.addEventListener("pagehide", this);
-    let MutationObserver = this.element.ownerDocument.defaultView.MutationObserver;
-    this.mut = new MutationObserver(mutations => {
-      // Something changed the <select> while it was open, so
-      // we'll poke a DeferredTask to update the parent sometime
-      // in the very near future.
-      this._updateTimer.arm();
-    });
-    this.mut.observe(this.element, {childList: true, subtree: true});
+    this.global.addEventListener("mozhidedropdown", this);
   },
 
   uninit: function() {
     this.global.removeMessageListener("Forms:SelectDropDownItem", this);
     this.global.removeMessageListener("Forms:DismissedDropDown", this);
     this.global.removeMessageListener("Forms:MouseOver", this);
     this.global.removeMessageListener("Forms:MouseOut", this);
     this.global.removeEventListener("pagehide", this);
+    this.global.removeEventListener("mozhidedropdown", this);
     this.element = null;
     this.global = null;
-    this.mut.disconnect();
-    this._updateTimer.disarm();
-    this._updateTimer = null;
   },
 
   showDropDown: function() {
     let rect = this._getBoundingContentRect();
 
     this.global.sendAsyncMessage("Forms:ShowDropDown", {
       rect: rect,
       options: this._buildOptionList(),
@@ -76,25 +64,16 @@ this.SelectContentHelper.prototype = {
   _getBoundingContentRect: function() {
     return BrowserUtils.getElementBoundingScreenRect(this.element);
   },
 
   _buildOptionList: function() {
     return buildOptionListForChildren(this.element);
   },
 
-  _update() {
-    // The <select> was updated while the dropdown was open.
-    // Let's send up a new list of options.
-    this.global.sendAsyncMessage("Forms:UpdateDropDown", {
-      options: this._buildOptionList(),
-      selectedIndex: this.element.selectedIndex,
-    });
-  },
-
   receiveMessage: function(message) {
     switch (message.name) {
       case "Forms:SelectDropDownItem":
         this.element.selectedIndex = message.data.value;
         break;
 
       case "Forms:DismissedDropDown":
         if (this.initialSelection != this.element.item(this.element.selectedIndex)) {
--- a/toolkit/modules/SelectParentHelper.jsm
+++ b/toolkit/modules/SelectParentHelper.jsm
@@ -4,32 +4,28 @@
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "SelectParentHelper"
 ];
 
 var currentBrowser = null;
-var currentMenulist = null;
-var currentZoom = 1;
 
 this.SelectParentHelper = {
   populate: function(menulist, items, selectedIndex, zoom) {
     // Clear the current contents of the popup
     menulist.menupopup.textContent = "";
-    currentZoom = zoom;
-    currentMenulist = menulist;
     populateChildren(menulist, items, selectedIndex, zoom);
   },
 
   open: function(browser, menulist, rect) {
     menulist.hidden = false;
     currentBrowser = browser;
-    this._registerListeners(browser, menulist.menupopup);
+    this._registerListeners(menulist.menupopup);
 
     menulist.menupopup.openPopupAtScreenRect("after_start", rect.left, rect.top, rect.width, rect.height, false, false);
     menulist.selectedItem.scrollIntoView();
   },
 
   hide: function(menulist, browser) {
     if (currentBrowser == browser) {
       menulist.menupopup.hidePopup();
@@ -51,54 +47,36 @@ this.SelectParentHelper = {
           currentBrowser.messageManager.sendAsyncMessage("Forms:SelectDropDownItem", {
             value: event.target.value
           });
         }
         break;
 
       case "popuphidden":
         currentBrowser.messageManager.sendAsyncMessage("Forms:DismissedDropDown", {});
+        currentBrowser = null;
         let popup = event.target;
-        this._unregisterListeners(currentBrowser, popup);
+        this._unregisterListeners(popup);
         popup.parentNode.hidden = true;
-        currentBrowser = null;
-        currentMenulist = null;
-        currentZoom = 1;
         break;
     }
   },
 
-  receiveMessage(msg) {
-    if (msg.name == "Forms:UpdateDropDown") {
-      // Sanity check - we'd better know what the currently
-      // opened menulist is, and what browser it belongs to...
-      if (!currentMenulist || !currentBrowser) {
-        return;
-      }
-
-      let options = msg.data.options;
-      let selectedIndex = msg.data.selectedIndex;
-      this.populate(currentMenulist, options, selectedIndex, currentZoom);
-    }
-  },
-
-  _registerListeners: function(browser, popup) {
+  _registerListeners: function(popup) {
     popup.addEventListener("command", this);
     popup.addEventListener("popuphidden", this);
     popup.addEventListener("mouseover", this);
     popup.addEventListener("mouseout", this);
-    browser.messageManager.addMessageListener("Forms:UpdateDropDown", this);
   },
 
-  _unregisterListeners: function(browser, popup) {
+  _unregisterListeners: function(popup) {
     popup.removeEventListener("command", this);
     popup.removeEventListener("popuphidden", this);
     popup.removeEventListener("mouseover", this);
     popup.removeEventListener("mouseout", this);
-    browser.messageManager.removeMessageListener("Forms:UpdateDropDown", this);
   },
 
 };
 
 function populateChildren(menulist, options, selectedIndex, zoom,
                           isInGroup = false, isGroupDisabled = false, adjustedTextSize = -1) {
   let element = menulist.menupopup;