[Libreoffice-commits] online.git: loleaflet/src

Mihai Varga mihai.varga at collabora.com
Mon Jun 29 02:50:00 PDT 2015


 loleaflet/src/layer/tile/GridLayer.js |    2 +-
 loleaflet/src/layer/tile/TileLayer.js |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 2e5e63724e9b8f35086a6bb2512e2128ebdedfa3
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Jun 29 12:45:14 2015 +0300

    Restored tile cache and removed invalid tiles from it

diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 6885a01..64e3054 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -587,7 +587,7 @@ L.GridLayer = L.Layer.extend({
 		// FIXME: this _tileCache is used for prev/next slide; but it is
 		// dangerous in connection with typing / invalidation, so let's
 		// comment it out for now
-		//this._tileCache[key] = tile.el.src;
+		this._tileCache[key] = tile.el.src;
 
 		L.DomUtil.remove(tile.el);
 		delete this._tiles[key];
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index a8a51d1..75adc59 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -332,6 +332,22 @@ L.TileLayer = L.GridLayer.extend({
 									'tileheight=' + this._tileHeightTwips);
 				}
 			}
+			for (var key in this._tileCache) {
+				// compute the rectangle that each tile covers in the document based
+				// on the zoom level
+				coords = this._keyToTileCoords(key);
+				var scale = this._map.getZoomScale(coords.z);
+				topLeftTwips = new L.Point(
+						this.options.tileWidthTwips * scale * coords.x,
+						this.options.tileHeightTwips * scale * coords.y);
+				bottomRightTwips = topLeftTwips.add(new L.Point(
+						this.options.tileWidthTwips * scale,
+						this.options.tileHeightTwips * scale));
+				bounds = new L.Bounds(topLeftTwips, bottomRightTwips);
+				if (invalidBounds.intersects(bounds)) {
+					delete this._tileCache[key];
+				}
+			}
 		}
 		else if (textMsg.startsWith('status:')) {
 			command = this._parseServerCmd(textMsg);


More information about the Libreoffice-commits mailing list