Bug 1078539 - Part 2: Delay showing a doorhanger to prevent flickering in windows, and call success immediately to prevent duplicates. r=jryans

This commit is contained in:
Jordan Santell 2014-11-07 12:19:00 -05:00
Родитель ee90afcd25
Коммит 5d1a0c888c
1 изменённых файлов: 14 добавлений и 3 удалений

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

@ -76,6 +76,14 @@ exports.showDoorhanger = Task.async(function *({ window, type, anchor }) {
return;
}
// Call success function to set preferences/cleanup immediately,
// so if triggered multiple times, only happens once (Windows/Linux)
success();
// Wait 200ms to prevent flickering where the popup is displayed
// before the underlying window (Windows 7, 64bit)
yield wait(200);
let document = window.document;
let panel = document.createElementNS(XULNS, "panel");
@ -108,9 +116,6 @@ exports.showDoorhanger = Task.async(function *({ window, type, anchor }) {
close();
});
}
// Call success function to set preferences, etc.
success();
});
function setDoorhangerStyle (panel, frame) {
@ -147,3 +152,9 @@ function onFrameLoad (frame) {
function getGBrowser () {
return getMostRecentBrowserWindow().gBrowser;
}
function wait (n) {
let { resolve, promise } = Promise.defer();
setTimeout(resolve, n);
return promise;
}