Bug 1310957 - listen to XUL Panel wrapper hidden event to hide HTML tooltip;r=gl

MozReview-Commit-ID: 7iyc2QY0KbP

--HG--
extra : rebase_source : 84d6d664b274354387c239a84b4b7b4244c619ce
This commit is contained in:
Julian Descottes 2016-10-19 00:08:00 +02:00
Родитель 4a6a9cdc8b
Коммит 8e6296997a
2 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -43,14 +43,7 @@ add_task(function* () {
info("Run tests for a Tooltip with a XUL panel");
useXulWrapper = true;
let isLinux = Services.appinfo.OS === "Linux";
if (!isLinux) {
// Skip these tests on linux when using a XUL Panel wrapper because some linux window
// manager don't support nicely XUL Panels with noautohide _and_ noautofocus.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1301342#c11
yield runTests(doc);
}
yield runTests(doc);
});
function* runTests(doc) {

Просмотреть файл

@ -229,6 +229,7 @@ function HTMLTooltip(toolboxDoc, {
this._position = null;
this._onClick = this._onClick.bind(this);
this._onXulPanelHidden = this._onXulPanelHidden.bind(this);
this._toggle = new TooltipToggle(this);
this.startTogglingOnHover = this._toggle.start.bind(this._toggle);
@ -539,6 +540,12 @@ HTMLTooltip.prototype = {
return false;
},
_onXulPanelHidden: function () {
if (this.isVisible()) {
this.hide();
}
},
/**
* If the tootlip is configured to autofocus and a focusable element can be found,
* focus it.
@ -572,7 +579,6 @@ HTMLTooltip.prototype = {
panel.setAttribute("animate", false);
panel.setAttribute("consumeoutsideclicks", false);
panel.setAttribute("noautofocus", true);
panel.setAttribute("noautohide", true);
panel.setAttribute("ignorekeys", true);
panel.setAttribute("tooltip", "aHTMLTooltip");
@ -586,12 +592,20 @@ HTMLTooltip.prototype = {
},
_showXulWrapperAt: function (left, top) {
this.xulPanelWrapper.addEventListener("popuphidden", this._onXulPanelHidden);
let onPanelShown = listenOnce(this.xulPanelWrapper, "popupshown");
this.xulPanelWrapper.openPopupAtScreen(left, top, false);
return onPanelShown;
},
_hideXulWrapper: function () {
this.xulPanelWrapper.removeEventListener("popuphidden", this._onXulPanelHidden);
if (this.xulPanelWrapper.state === "closed") {
// XUL panel is already closed, resolve immediately.
return Promise.resolve();
}
let onPanelHidden = listenOnce(this.xulPanelWrapper, "popuphidden");
this.xulPanelWrapper.hidePopup();
return onPanelHidden;