Bug 520173 - Reset lightweight theme previews when leaving the source page. r=dtownsend

This commit is contained in:
Dão Gottwald 2009-10-22 22:47:59 +02:00
Родитель 2bf15c755e
Коммит c3854b5f2e
1 изменённых файлов: 25 добавлений и 1 удалений

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

@ -7062,6 +7062,14 @@ let gURLBarEmptyText = {
var LightWeightThemeWebInstaller = {
handleEvent: function (event) {
switch (event.type) {
case "InstallBrowserTheme":
case "PreviewBrowserTheme":
case "ResetBrowserThemePreview":
// ignore requests from background tabs
if (event.target.ownerDocument.defaultView.top != content)
return;
}
switch (event.type) {
case "InstallBrowserTheme":
this._installRequest(event);
@ -7072,6 +7080,10 @@ var LightWeightThemeWebInstaller = {
case "ResetBrowserThemePreview":
this._resetPreview(event);
break;
case "pagehide":
case "TabSelect":
this._resetPreview();
break;
}
},
@ -7164,6 +7176,7 @@ var LightWeightThemeWebInstaller = {
});
},
_previewWindow: null,
_preview: function (event) {
if (!this._isAllowed(event.target))
return;
@ -7172,13 +7185,24 @@ var LightWeightThemeWebInstaller = {
if (!data)
return;
this._resetPreview();
this._previewWindow = event.target.ownerDocument.defaultView;
this._previewWindow.addEventListener("pagehide", this, true);
gBrowser.tabContainer.addEventListener("TabSelect", this, false);
this._manager.previewTheme(data);
},
_resetPreview: function (event) {
if (!this._isAllowed(event.target))
if (!this._previewWindow ||
event && !this._isAllowed(event.target))
return;
this._previewWindow.removeEventListener("pagehide", this, true);
this._previewWindow = null;
gBrowser.tabContainer.removeEventListener("TabSelect", this, false);
this._manager.resetPreview();
},