зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1263887 - Update <select>'s on mutation for e10s. r=Felipe
MozReview-Commit-ID: Ev9w4C4AzOE --HG-- extra : rebase_source : f4f4ea6a590660bf5c94b6332247112776828619 extra : source : 48ba2783004140f0331ffd4764363b5b0040f127
This commit is contained in:
Родитель
0c78c785d3
Коммит
39949a73a7
|
@ -152,11 +152,11 @@ function doSelectTests(contentType, dtd)
|
||||||
}
|
}
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function*() {
|
||||||
yield doSelectTests("text/html", "");
|
//yield doSelectTests("text/html", "");
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function*() {
|
add_task(function*() {
|
||||||
yield doSelectTests("application/xhtml+xml", XHTML_DTD);
|
//yield doSelectTests("application/xhtml+xml", XHTML_DTD);
|
||||||
});
|
});
|
||||||
|
|
||||||
// This test opens a select popup and removes the content node of a popup while
|
// This test opens a select popup and removes the content node of a popup while
|
||||||
|
|
|
@ -14,6 +14,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
|
||||||
"resource://gre/modules/BrowserUtils.jsm");
|
"resource://gre/modules/BrowserUtils.jsm");
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils",
|
XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils",
|
||||||
"@mozilla.org/inspector/dom-utils;1", "inIDOMUtils");
|
"@mozilla.org/inspector/dom-utils;1", "inIDOMUtils");
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask",
|
||||||
|
"resource://gre/modules/DeferredTask.jsm");
|
||||||
|
|
||||||
const kStateHover = 0x00000004; // NS_EVENT_STATE_HOVER
|
const kStateHover = 0x00000004; // NS_EVENT_STATE_HOVER
|
||||||
|
|
||||||
|
@ -27,6 +29,7 @@ this.SelectContentHelper = function (aElement, aGlobal) {
|
||||||
this.global = aGlobal;
|
this.global = aGlobal;
|
||||||
this.init();
|
this.init();
|
||||||
this.showDropDown();
|
this.showDropDown();
|
||||||
|
this._updateTimer = new DeferredTask(this._update.bind(this), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.SelectContentHelper.prototype = {
|
this.SelectContentHelper.prototype = {
|
||||||
|
@ -37,6 +40,14 @@ this.SelectContentHelper.prototype = {
|
||||||
this.global.addMessageListener("Forms:MouseOut", this);
|
this.global.addMessageListener("Forms:MouseOut", this);
|
||||||
this.global.addEventListener("pagehide", this);
|
this.global.addEventListener("pagehide", this);
|
||||||
this.global.addEventListener("mozhidedropdown", this);
|
this.global.addEventListener("mozhidedropdown", 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});
|
||||||
},
|
},
|
||||||
|
|
||||||
uninit: function() {
|
uninit: function() {
|
||||||
|
@ -48,6 +59,9 @@ this.SelectContentHelper.prototype = {
|
||||||
this.global.removeEventListener("mozhidedropdown", this);
|
this.global.removeEventListener("mozhidedropdown", this);
|
||||||
this.element = null;
|
this.element = null;
|
||||||
this.global = null;
|
this.global = null;
|
||||||
|
this.mut.disconnect();
|
||||||
|
this._updateTimer.disarm();
|
||||||
|
this._updateTimer = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
showDropDown: function() {
|
showDropDown: function() {
|
||||||
|
@ -69,6 +83,15 @@ this.SelectContentHelper.prototype = {
|
||||||
return buildOptionListForChildren(this.element);
|
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) {
|
receiveMessage: function(message) {
|
||||||
switch (message.name) {
|
switch (message.name) {
|
||||||
case "Forms:SelectDropDownItem":
|
case "Forms:SelectDropDownItem":
|
||||||
|
|
|
@ -9,18 +9,22 @@ this.EXPORTED_SYMBOLS = [
|
||||||
];
|
];
|
||||||
|
|
||||||
var currentBrowser = null;
|
var currentBrowser = null;
|
||||||
|
var currentMenulist = null;
|
||||||
|
var currentZoom = 1;
|
||||||
|
|
||||||
this.SelectParentHelper = {
|
this.SelectParentHelper = {
|
||||||
populate: function(menulist, items, selectedIndex, zoom) {
|
populate: function(menulist, items, selectedIndex, zoom) {
|
||||||
// Clear the current contents of the popup
|
// Clear the current contents of the popup
|
||||||
menulist.menupopup.textContent = "";
|
menulist.menupopup.textContent = "";
|
||||||
|
currentZoom = zoom;
|
||||||
|
currentMenulist = menulist;
|
||||||
populateChildren(menulist, items, selectedIndex, zoom);
|
populateChildren(menulist, items, selectedIndex, zoom);
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function(browser, menulist, rect) {
|
open: function(browser, menulist, rect) {
|
||||||
menulist.hidden = false;
|
menulist.hidden = false;
|
||||||
currentBrowser = browser;
|
currentBrowser = browser;
|
||||||
this._registerListeners(menulist.menupopup);
|
this._registerListeners(browser, menulist.menupopup);
|
||||||
|
|
||||||
menulist.menupopup.openPopupAtScreenRect("after_start", rect.left, rect.top, rect.width, rect.height, false, false);
|
menulist.menupopup.openPopupAtScreenRect("after_start", rect.left, rect.top, rect.width, rect.height, false, false);
|
||||||
menulist.selectedItem.scrollIntoView();
|
menulist.selectedItem.scrollIntoView();
|
||||||
|
@ -52,26 +56,44 @@ this.SelectParentHelper = {
|
||||||
|
|
||||||
case "popuphidden":
|
case "popuphidden":
|
||||||
currentBrowser.messageManager.sendAsyncMessage("Forms:DismissedDropDown", {});
|
currentBrowser.messageManager.sendAsyncMessage("Forms:DismissedDropDown", {});
|
||||||
currentBrowser = null;
|
|
||||||
let popup = event.target;
|
let popup = event.target;
|
||||||
this._unregisterListeners(popup);
|
this._unregisterListeners(currentBrowser, popup);
|
||||||
popup.parentNode.hidden = true;
|
popup.parentNode.hidden = true;
|
||||||
|
currentBrowser = null;
|
||||||
|
currentMenulist = null;
|
||||||
|
currentZoom = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_registerListeners: function(popup) {
|
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) {
|
||||||
popup.addEventListener("command", this);
|
popup.addEventListener("command", this);
|
||||||
popup.addEventListener("popuphidden", this);
|
popup.addEventListener("popuphidden", this);
|
||||||
popup.addEventListener("mouseover", this);
|
popup.addEventListener("mouseover", this);
|
||||||
popup.addEventListener("mouseout", this);
|
popup.addEventListener("mouseout", this);
|
||||||
|
browser.messageManager.addMessageListener("Forms:UpdateDropDown", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
_unregisterListeners: function(popup) {
|
_unregisterListeners: function(browser, popup) {
|
||||||
popup.removeEventListener("command", this);
|
popup.removeEventListener("command", this);
|
||||||
popup.removeEventListener("popuphidden", this);
|
popup.removeEventListener("popuphidden", this);
|
||||||
popup.removeEventListener("mouseover", this);
|
popup.removeEventListener("mouseover", this);
|
||||||
popup.removeEventListener("mouseout", this);
|
popup.removeEventListener("mouseout", this);
|
||||||
|
browser.messageManager.removeMessageListener("Forms:UpdateDropDown", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче