Bug 588630 - "When invoking TabCandy/Panorama with many open blank tabs, Firefox hangs & then pops up "Unresponsive Script" dialog" [r=dietrich, a=blocking]

--HG--
extra : rebase_source : 6a7a920136de79d479dd4ee67060f0274ee26759
This commit is contained in:
Sean Dunn 2010-10-11 11:57:00 -07:00
parent c73e843930
commit 7119f5fc9b
4 changed files with 66 additions and 9 deletions

View File

@ -1047,6 +1047,10 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Parameters:
// options - passed to <Items.arrange> or <_stackArrange>
arrange: function GroupItem_arrange(options) {
if (GroupItems._arrangePaused) {
GroupItems.pushArrange(this, options);
return;
}
if (this.expanded) {
this.topChild = null;
var box = new Rect(this.expanded.bounds);
@ -1490,6 +1494,8 @@ let GroupItems = {
_activeGroupItem: null,
_activeOrphanTab: null,
_cleanupFunctions: [],
_arrangePaused: false,
_arrangesPending: [],
// ----------
// Function: init
@ -1521,6 +1527,51 @@ let GroupItems = {
this.groupItems = null;
},
// ----------
// Function: pauseArrange
// Bypass arrange() calls and collect for resolution in
// resumeArrange()
pauseArrange: function GroupItems_pauseArrange() {
Utils.assert(this._arrangePaused == false,
"pauseArrange has been called while already paused");
Utils.assert(this._arrangesPending.length == 0,
"There are bypassed arrange() calls that haven't been resolved");
this._arrangePaused = true;
},
// ----------
// Function: pushArrange
// Push an arrange() call and its arguments onto an array
// to be resolved in resumeArrange()
pushArrange: function GroupItems_pushArrange(groupItem, options) {
Utils.assert(this._arrangePaused,
"Ensure pushArrange() called while arrange()s aren't paused");
let i;
for (i = 0; i < this._arrangesPending.length; i++)
if (this._arrangesPending[i].groupItem === groupItem)
break;
let arrangeInfo = {
groupItem: groupItem,
options: options
};
if (i < this._arrangesPending.length)
this._arrangesPending[i] = arrangeInfo;
else
this._arrangesPending.push(arrangeInfo);
},
// ----------
// Function: resumeArrange
// Resolve bypassed and collected arrange() calls
resumeArrange: function GroupItems_resumeArrange() {
for (let i = 0; i < this._arrangesPending.length; i++) {
let g = this._arrangesPending[i];
g.groupItem.arrange(g.options);
}
this._arrangesPending = [];
this._arrangePaused = false;
},
// ----------
// Function: _handleAttrModified
// watch for icon changes on app tabs

View File

@ -132,7 +132,7 @@ var TabUtils = {
// Function: favURLOf
// Given a <TabItem> or a <xul:tab> returns the URL of tab's favicon.
faviconURLOf: function TabUtils_faviconURLOf(tab) {
return tab.image != undefined ? tab.image : tab.favEl.src;
return tab.image != undefined ? tab.image : tab.favImgEl.src;
},
// ---------

View File

@ -70,8 +70,10 @@ function TabItem(tab, options) {
this.canvasSizeForced = false;
this.isShowingCachedData = false;
this.favEl = (iQ('.favicon>img', $div))[0];
this.favEl = (iQ('.favicon', $div))[0];
this.favImgEl = (iQ('.favicon>img', $div))[0];
this.nameEl = (iQ('.tab-title', $div))[0];
this.thumbEl = (iQ('.thumb', $div))[0];
this.canvasEl = (iQ('.thumb canvas', $div))[0];
this.cachedThumbEl = (iQ('img.cached-thumb', $div))[0];
@ -194,6 +196,7 @@ function TabItem(tab, options) {
iQ("<div>")
.addClass('close')
.appendTo($div);
this.closeEl = (iQ(".close", $div))[0];
iQ("<div>")
.addClass('expander')
@ -322,10 +325,10 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
this.bounds.copy(rect);
else {
var $container = iQ(this.container);
var $title = iQ('.tab-title', $container);
var $thumb = iQ('.thumb', $container);
var $close = iQ('.close', $container);
var $fav = iQ('.favicon', $container);
var $title = iQ(this.nameEl);
var $thumb = iQ(this.thumbEl);
var $close = iQ(this.closeEl);
var $fav = iQ(this.favEl);
var css = {};
const fontSizeRange = new Range(8,15);
@ -802,8 +805,8 @@ let TabItems = {
if (iconUrl == null)
iconUrl = Utils.defaultFaviconURL;
if (iconUrl != tabItem.favEl.src)
tabItem.favEl.src = iconUrl;
if (iconUrl != tabItem.favImgEl.src)
tabItem.favImgEl.src = iconUrl;
// ___ URL
let tabUrl = tab.linkedBrowser.currentURI.spec;

View File

@ -171,6 +171,7 @@ let UI = {
// ___ Storage
GroupItems.pauseArrange();
GroupItems.init();
let firstTime = true;
@ -221,9 +222,11 @@ let UI = {
// initialized.
let event = document.createEvent("Events");
event.initEvent("tabviewframeinitialized", true, false);
dispatchEvent(event);
dispatchEvent(event);
} catch(e) {
Utils.log(e);
} finally {
GroupItems.resumeArrange();
}
},