Bug 739171 - Don't save tabItem data while updating tabItems; r=dietrich

This commit is contained in:
Tim Taubert 2012-03-27 12:59:09 +02:00
Родитель 218ffbaae7
Коммит 6dd34f7f87
2 изменённых файлов: 61 добавлений и 27 удалений

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

@ -123,6 +123,20 @@ let Storage = {
return existingData;
},
// ----------
// Function: getTabState
// Returns the current state of the given tab.
getTabState: function Storage_getTabState(tab) {
Utils.assert(tab, "tab");
let tabState;
try {
tabState = JSON.parse(this._sessionStore.getTabState(tab));
} catch (e) {}
return tabState;
},
// ----------
// Function: saveGroupItem
// Saves the data for a single groupItem, associated with a specific window.

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

@ -96,7 +96,6 @@ function TabItem(tab, options) {
this._reconnected = false;
this.isDragging = false;
this.isStacked = false;
this.url = "";
// Read off the total vertical and horizontal padding on the tab container
// and cache this value, as it must be the same for every TabItem.
@ -200,21 +199,14 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// be called at browser startup with the cached data avaliable.
//
// Parameters:
// tabData - the tab data
// imageData - the image data
showCachedData: function TabItem_showCachedData(tabData, imageData) {
showCachedData: function TabItem_showCachedData(imageData) {
this._cachedImageData = imageData;
this.$cachedThumb.attr("src", this._cachedImageData).show();
this.$canvas.css({opacity: 0});
let label = "";
let title;
if (tabData.title) {
label = tabData.title;
title = label + "\n" + tabData.url;
} else {
title = tabData.url;
}
this.$tabTitle.text(label).attr("title", title);
let {title, url} = this.getTabState();
this.$tabTitle.text(title).attr("title", title ? title + "\n" + url : url);
this._sendToSubscribers("showingCachedData");
},
@ -234,9 +226,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Get data to be used for persistent storage of this object.
getStorageData: function TabItem_getStorageData() {
let data = {
url: this.tab.linkedBrowser.currentURI.spec,
groupID: (this.parent ? this.parent.id : 0),
title: this.tab.label
groupID: (this.parent ? this.parent.id : 0)
};
if (this.parent && this.parent.getActiveTab() == this)
data.active = true;
@ -260,12 +250,46 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
}
},
// ----------
// Function: _getCurrentTabStateEntry
// Returns the current tab state's active history entry.
_getCurrentTabStateEntry: function TabItem__getCurrentTabStateEntry() {
let tabState = Storage.getTabState(this.tab);
if (tabState) {
let index = (tabState.index || tabState.entries.length) - 1;
if (index in tabState.entries)
return tabState.entries[index];
}
return null;
},
// ----------
// Function: getTabState
// Returns the current tab state, i.e. the title and URL of the active
// history entry.
getTabState: function TabItem_getTabState() {
let entry = this._getCurrentTabStateEntry();
let title = "";
let url = "";
if (entry) {
if (entry.title)
title = entry.title;
url = entry.url;
} else {
url = this.tab.linkedBrowser.currentURI.spec;
}
return {title: title, url: url};
},
// ----------
// Function: loadThumbnail
// Loads the tabItems thumbnail.
loadThumbnail: function TabItem_loadThumbnail(tabData) {
Utils.assert(tabData, "invalid or missing argument <tabData>");
loadThumbnail: function TabItem_loadThumbnail() {
let self = this;
function TabItem_loadThumbnail_callback(error, imageData) {
@ -285,11 +309,11 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// what the cache is from, OR the loaded URL is blank, which means
// that the page hasn't loaded yet.
let currentUrl = self.tab.linkedBrowser.currentURI.spec;
if (tabData.url == currentUrl || currentUrl == "about:blank")
self.showCachedData(tabData, imageData);
if (self.getTabState().url == currentUrl || currentUrl == "about:blank")
self.showCachedData(imageData);
}
ThumbnailStorage.loadThumbnail(tabData.url, TabItem_loadThumbnail_callback);
ThumbnailStorage.loadThumbnail(this.getTabState().url, TabItem_loadThumbnail_callback);
},
// ----------
@ -370,7 +394,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
let groupItem;
if (tabData && TabItems.storageSanity(tabData)) {
this.loadThumbnail(tabData);
this.loadThumbnail();
if (this.parent)
this.parent.remove(this, {immediately: true});
@ -934,7 +958,7 @@ let TabItems = {
return (
tab.linkedBrowser.contentDocument.readyState == 'complete' &&
!(tab.linkedBrowser.contentDocument.URL == 'about:blank' &&
tab._tabViewTabItem.url != 'about:blank')
tab._tabViewTabItem.getTabState().url != 'about:blank')
);
},
@ -1013,10 +1037,6 @@ let TabItems = {
// ___ URL
let tabUrl = tab.linkedBrowser.currentURI.spec;
if (tabUrl != tabItem.url) {
tabItem.url = tabUrl;
tabItem.save();
}
tabItem.$container.attr("title", label + "\n" + tabUrl);
// ___ Make sure the tab is complete and ready for updating.