Compare commits

...

3 Commits

Author SHA1 Message Date
Bart van den Eijnden
f4a4090814 set correct VERSION_NUMBER 2013-07-09 11:26:12 +02:00
ahocevar
49dd5a4fd8 Merge pull request #1019 from ahocevar/chrome-optimized
Deal with recent Chrome optimizations to avoid failing TileManager and tests
2013-07-09 11:23:27 +02:00
ahocevar
d020e8f666 Merge pull request #1018 from ahocevar/tilemanager-image-only
UTFGrid examples broken because of TileManager. r=@bartvde
2013-07-09 11:22:52 +02:00
7 changed files with 65 additions and 61 deletions

View File

@@ -426,4 +426,4 @@
* When asking questions or reporting issues, make sure to include the output of
* OpenLayers.VERSION_NUMBER in the question or issue-description.
*/
OpenLayers.VERSION_NUMBER="Release 2.13";
OpenLayers.VERSION_NUMBER="Release 2.13.1";

View File

@@ -7,7 +7,7 @@ var OpenLayers = {
/**
* Constant: VERSION_NUMBER
*/
VERSION_NUMBER: "Release 2.13",
VERSION_NUMBER: "Release 2.13.1",
/**
* Constant: singleFile

View File

@@ -314,11 +314,17 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
* Creates the content for the frame on the tile.
*/
initImage: function() {
if (!this.url && !this.imgDiv) {
// fast path out - if there is no tile url and no previous image
this.isLoading = false;
return;
}
this.events.triggerEvent('beforeload');
this.layer.div.appendChild(this.getTile());
this.events.triggerEvent(this._loadEvent);
var img = this.getImage();
if (this.url && OpenLayers.Util.isEquivalentUrl(img.src, this.url)) {
var src = img.getAttribute('src') || '';
if (this.url && OpenLayers.Util.isEquivalentUrl(src, this.url)) {
this._loadTimeout = window.setTimeout(
OpenLayers.Function.bind(this.onImageLoad, this), 0
);

View File

@@ -8,6 +8,8 @@
* @requires OpenLayers/Util.js
* @requires OpenLayers/BaseTypes.js
* @requires OpenLayers/BaseTypes/Element.js
* @requires OpenLayers/Layer/Grid.js
* @requires OpenLayers/Tile/Image.js
*/
/**
@@ -221,7 +223,7 @@ OpenLayers.TileManager = OpenLayers.Class({
for (j=layer.grid[i].length-1; j>=0; --j) {
tile = layer.grid[i][j];
this.addTile({tile: tile});
if (tile.url) {
if (tile.url && !tile.imgDiv) {
this.manageTileCache({object: tile});
}
}
@@ -253,9 +255,6 @@ OpenLayers.TileManager = OpenLayers.Class({
for (j=layer.grid[i].length-1; j>=0; --j) {
tile = layer.grid[i][j];
this.unloadTile({object: tile});
if (tile.url) {
this.manageTileCache({object: tile});
}
}
}
}
@@ -300,6 +299,7 @@ OpenLayers.TileManager = OpenLayers.Class({
* evt - {Object} The listener argument
*/
addTile: function(evt) {
if (evt.tile instanceof OpenLayers.Tile.Image) {
evt.tile.events.on({
beforedraw: this.queueTileDraw,
beforeload: this.manageTileCache,
@@ -307,6 +307,10 @@ OpenLayers.TileManager = OpenLayers.Class({
unload: this.unloadTile,
scope: this
});
} else {
// Layer has the wrong tile type, so don't handle it any longer
this.removeLayer({layer: evt.tile.layer});
}
},
/**
@@ -383,26 +387,24 @@ OpenLayers.TileManager = OpenLayers.Class({
manageTileCache: function(evt) {
var tile = evt.object;
var img = this.tileCache[tile.url];
// only use image from cache if it is not on a layer already
if (img && (!img.parentNode ||
OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer'))) {
if (tile.layer.backBuffer) {
if (tile.layer.backBuffer === img.parentNode) {
// cached image is on the target layer's backbuffer already,
// so nothing to do here
return;
}
img.style.opacity = 0;
img.style.visibility = 'hidden';
}
// Only backbuffer tiles have an id, so we don't want one here
if (img) {
// if image is on its layer's backbuffer, remove it from backbuffer
if (img.parentNode &&
OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer')) {
img.parentNode.removeChild(img);
img.id = null;
}
// only use image from cache if it is not on a layer already
if (!img.parentNode) {
img.style.visibility = 'hidden';
img.style.opacity = 0;
tile.setImage(img);
// LRU - move tile to the end of the array to mark it as the most
// recently used
OpenLayers.Util.removeItem(this.tileCacheIndex, tile.url);
this.tileCacheIndex.push(tile.url);
}
}
},
/**

View File

@@ -1135,7 +1135,7 @@
map.addLayer(layer);
map.zoomToMaxExtent();
t.delay_call(1, function() {
layer.grid[1][1].onImageLoad();
layer.mergeNewParams({foo: 'bar'});
var tile = layer.grid[1][1];
t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olTileReplacing'), 'tile is marked for being replaced');
@@ -1155,7 +1155,6 @@
tile.onImageLoad();
t.ok(!OpenLayers.Element.hasClass(tile.imgDiv, 'olTileReplacing'), 'tile replaced, no longer marked');
t.ok(document.getElementById(tile.id + '_bb'), 'backbuffer not removed for visible tile');
});
}
function test_backbuffer_replace_singleTile(t) {

View File

@@ -382,12 +382,9 @@
t.delay_call(5, function() {
var tile = layer.grid[0][0];
if (tile.isLoading) {
t.ok(false, "test_getCanvasContext timeout");
} else {
tile.onImageLoad();
t.ok(tile.getCanvasContext() instanceof CanvasRenderingContext2D,
"getCanvasContext() returns CanvasRenderingContext2D instance");
}
map.destroy();
});
}

View File

@@ -231,7 +231,7 @@
<li>Tile/Image.html</li>
<li>Tile/Image/IFrame.html</li>
<li>Tile/UTFGrid.html</li>
<li>TileManager.html?visible</li>
<li>TileManager.html</li>
<li>Tween.html</li>
<li>Kinetic.html</li>
<li>Util.html?visible</li>