Bug 538571 - checkerboard appears after slow pan [r=stuart,vingtetun,froystig]

This commit is contained in:
Benjamin Stover 2010-01-12 10:10:17 -08:00
Родитель bc6de32e26
Коммит 633aee553b
3 изменённых файлов: 46 добавлений и 22 удалений

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

@ -244,6 +244,9 @@ BrowserView.prototype = {
let cacheSize = kBrowserViewCacheSize;
try {
cacheSize = gPrefService.getIntPref("tile.cache.size");
// XXX cacheSize still can be -1 even though new profile sets it to a positive value
if (cacheSize == -1)
cacheSize = kBrowserViewCacheSize;
} catch(e) {}
this._tileManager = new TileManager(this._appendTile, this._removeTile, this, cacheSize);
@ -863,35 +866,32 @@ BrowserView.BrowserViewportState.prototype = {
*/
BrowserView.IdleServiceObserver = function IdleServiceObserver(browserView) {
this._browserView = browserView;
this._crawlStarted = false;
this._idleState = false;
this._idle = false;
this._paused = false;
};
BrowserView.IdleServiceObserver.prototype = {
/** Start prefetching tiles. */
_start: function _start() {
if (!this._crawlStarted) {
let bv = this._browserView;
bv._tileManager.restartPrefetchCrawl();
this._crawlStarted = true;
}
/** No matter what idle is, make sure prefetching is not active. */
pause: function pause() {
this._paused = true;
this._updateTileManager();
},
/** Stop prefetching tiles. */
_stop: function _stop() {
if (this._crawlStarted) {
let bv = this._browserView;
bv._tileManager.stopPrefetchCrawl();
this._crawlStarted = false;
}
/** Prefetch tiles in idle mode. */
resume: function resume() {
this._paused = false;
this._updateTileManager();
},
/** Idle event handler. */
observe: function observe(aSubject, aTopic, aUserIdleTime) {
this._idleState = (aTopic == "idle") ? true : false;
if (this._idleState)
this._start();
else
this._stop();
this._idle = (aTopic == "idle") ? true : false;
this._updateTileManager();
},
_updateTileManager: function _updateTileManager() {
let bv = this._browserView;
bv._tileManager.setPrefetch(this._idle && !this._paused);
}
};

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

@ -136,6 +136,9 @@ function TileManager(appendTile, removeTile, browserView, cacheSize) {
/* remember these values to reduce the recenterEvictionQueue cost */
this._ctr = new Point(0, 0);
/* If true, render dirty tiles outside of a viewport on timer. */
this._prefetch = false;
/* create one Image of the checkerboard to be reused */
this._checkerboard = new Image();
this._checkerboard.src = "chrome://browser/content/checkerboard.png";
@ -360,6 +363,17 @@ TileManager.prototype = {
this.criticalRectPaint();
},
setPrefetch: function setPrefetch(prefetch) {
if (prefetch == this._prefetch)
return;
this._prefetch = prefetch;
if (prefetch)
this.restartPrefetchCrawl();
else
this.stopPrefetchCrawl();
},
restartPrefetchCrawl: function restartPrefetchCrawl(startRectOrQueue) {
if (startRectOrQueue instanceof Array) {
this._crawler = new TileManager.CrawlIterator(this._tileCache);
@ -371,7 +385,7 @@ TileManager.prototype = {
} else {
let cr = this._criticalRect;
this._crawler = new TileManager.CrawlIterator(this._tileCache,
startRectOrQueue || (cr ? cr.clone() : null));
startRectOrQueue || (!cr.isEmpty() ? cr.clone() : null));
}
if (!this._idleTileCrawlerTimeout)
@ -523,6 +537,7 @@ TileManager.prototype = {
if (tile.isDirty()) {
self._renderTile(tile);
}
self._appendTileSafe(tile);
}
if (comeAgain) {

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

@ -1416,6 +1416,12 @@ Browser.MainDragger.prototype = {
this.draggedFrame = element.ownerDocument.defaultView;
this.bv.pauseRendering();
// XXX shouldn't know about observer
// adding pause in pauseRendering isn't so great, because tiles will hardly ever prefetch while
// loading state is going (and already, the idle timer is bigger during loading so it doesn't fit
// into the aggressive flag).
this.bv._idleServiceObserver.pause();
},
dragStop: function dragStop(dx, dy, scroller) {
@ -1425,6 +1431,9 @@ Browser.MainDragger.prototype = {
Browser.tryUnfloatToolbar();
this.bv.resumeRendering();
// XXX shouldn't know about observer
this.bv._idleServiceObserver.resume();
},
dragMove: function dragMove(dx, dy, scroller) {