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

Mihai Varga mihai.mv13 at gmail.com
Mon Jun 22 07:48:27 PDT 2015


 loleaflet/src/layer/tile/GridLayer.js |   24 ++++--------
 loleaflet/src/layer/tile/TileLayer.js |   64 ++++++++++++++--------------------
 2 files changed, 37 insertions(+), 51 deletions(-)

New commits:
commit d2124f30781d1e9f553a44c4ec94ffd33ddf79d6
Author: Mihai Varga <mihai.mv13 at gmail.com>
Date:   Mon Jun 22 17:48:05 2015 +0300

    Fixed invalid tiles bounds

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 4093893..88bab85 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -306,6 +306,7 @@ L.TileLayer = L.GridLayer.extend({
 			var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
 			var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
 			var bottomRightTwips = topLeftTwips.add(offset);
+			var invalidBounds = new L.Bounds(topLeftTwips, bottomRightTwips);
 
 			this._map._fadeAnimated = false;
 
@@ -314,7 +315,7 @@ L.TileLayer = L.GridLayer.extend({
 				var point1 = this._coordsToTwips(coords);
 				var point2 = new L.Point(point1.x + this._tileWidthTwips, point1.y + this._tileHeightTwips);
 				var bounds = new L.Bounds(point1, point2);
-				if (bounds.contains(topLeftTwips) || bounds.contains(bottomRightTwips)) {
+				if (invalidBounds.intersects(bounds)) {
 					this._map.socket.send('tile ' +
 									'part=' + coords.part + ' ' +
 									'width=' + this._tileSize + ' ' +
commit c5e950bb41795ada1d4d4097016c7289c77bb5db
Author: Mihai Varga <mihai.mv13 at gmail.com>
Date:   Mon Jun 22 17:45:43 2015 +0300

    Reverted ecfe65b37f9139403817431f36782a2ca57b7e02

diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index afcdd38..48f11e1 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -488,11 +488,14 @@ L.GridLayer = L.Layer.extend({
 				this.fire('loading');
 			}
 
-			// send the requests for tiles (requests only - they are not
-			// created before we actually really get them from the server)
+			// create DOM fragment to append tiles in one batch
+			var fragment = document.createDocumentFragment();
+
 			for (i = 0; i < queue.length; i++) {
-				this._addTile(queue[i]);
+				this._addTile(queue[i], fragment);
 			}
+
+			this._level.el.appendChild(fragment);
 		}
 	},
 
@@ -587,7 +590,7 @@ L.GridLayer = L.Layer.extend({
 		}
 	},
 
-	_addTileToMap: function (coords, fragment, bitmap_src) {
+	_addTile: function (coords, fragment) {
 		var tilePos = this._getTilePos(coords),
 			key = this._tileCoordsToKey(coords);
 		var tile = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords));
@@ -605,9 +608,6 @@ L.GridLayer = L.Layer.extend({
 		// which is slow, and it also fixes gaps between tiles in Safari
 		L.DomUtil.setPosition(tile, tilePos, true);
 
-		// set the bitmap data ('data:image/png;base64,...');
-		tile.src = bitmap_src;
-
 		// save tile in cache
 		this._tiles[key] = {
 			el: tile,
@@ -621,10 +621,6 @@ L.GridLayer = L.Layer.extend({
 			tile: tile,
 			coords: coords
 		});
-	},
-
-	_addTile: function (coords) {
-		var key = this._tileCoordsToKey(coords);
 
 		if (!this._tileCache[key]) {
 			if (this.options.useSocket && this._map.socket) {
@@ -640,9 +636,7 @@ L.GridLayer = L.Layer.extend({
 			}
 		}
 		else {
-			var fragment = document.createDocumentFragment();
-			this._addTileToMap(coords, fragment, this._tileCache[key]);
-			this._level.el.appendChild(fragment);
+			tile.src = this._tileCache[key];
 		}
 	},
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index daf6539..4093893 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -366,10 +366,11 @@ L.TileLayer = L.GridLayer.extend({
 				strBytes += String.fromCharCode(data[i]);
 			}
 
-			// setup the tile
-			var fragment = document.createDocumentFragment();
-			this._addTileToMap(coords, fragment, 'data:image/png;base64,' + window.btoa(strBytes));
-			this._level.el.appendChild(fragment);
+			var key = this._tileCoordsToKey(coords);
+			var tile = this._tiles[key];
+			if (tile) {
+				tile.el.src = 'data:image/png;base64,' + window.btoa(strBytes);
+			}
 		}
 		else if (textMsg.startsWith('textselection:')) {
 			strTwips = textMsg.match(/\d+/g);
commit 9c73ddbd08538810d9d8569dbe18ab510ae9547e
Author: Mihai Varga <mihai.mv13 at gmail.com>
Date:   Mon Jun 22 17:45:10 2015 +0300

    Reverted 73974f7397414b0931b80729ea716387f3c6a130

diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index c2d8b25..afcdd38 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -555,7 +555,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 63b8159..daf6539 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -301,39 +301,29 @@ L.TileLayer = L.GridLayer.extend({
 
 			this._onUpdateGraphicSelection();
 		}
-		else if (textMsg.startsWith('invalidatetiles:')) {
-			if (textMsg.match('EMPTY')) {
-				// invalidate everything
-				this.redraw();
-				for (var key in this._tiles) {
-					this._addTile(this._tiles[key].coords);
-				}
-			}
-			else {
-				strTwips = textMsg.match(/\d+/g);
-
-				// convert to bounds
-				var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
-				var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
-				var bottomRightTwips = topLeftTwips.add(offset);
-				var invalidateBounds = new L.Bounds(topLeftTwips, bottomRightTwips);
-
-				// FIXME - we want the fading when zooming, but not when
-				// typing; we need to modify this so that we fade only
-				// the tiles that do not exist yet
-				this._map._fadeAnimated = false;
-
-				for (var key in this._tiles) {
-					var coords = this._tiles[key].coords;
-					var point1 = this._coordsToTwips(coords);
-					var point2 = new L.Point(point1.x + this._tileWidthTwips, point1.y + this._tileHeightTwips);
-					var tileBounds = new L.Bounds(point1, point2);
+		else if (textMsg.startsWith('invalidatetiles:') && !textMsg.match('EMPTY')) {
+			strTwips = textMsg.match(/\d+/g);
+			var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
+			var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
+			var bottomRightTwips = topLeftTwips.add(offset);
 
-					if (invalidateBounds.intersects(tileBounds)) {
-						this._addTile(coords);
-					}
+			this._map._fadeAnimated = false;
+
+			for (var key in this._tiles) {
+				var coords = this._tiles[key].coords;
+				var point1 = this._coordsToTwips(coords);
+				var point2 = new L.Point(point1.x + this._tileWidthTwips, point1.y + this._tileHeightTwips);
+				var bounds = new L.Bounds(point1, point2);
+				if (bounds.contains(topLeftTwips) || bounds.contains(bottomRightTwips)) {
+					this._map.socket.send('tile ' +
+									'part=' + coords.part + ' ' +
+									'width=' + this._tileSize + ' ' +
+									'height=' + this._tileSize + ' ' +
+									'tileposx=' + point1.x + ' '    +
+									'tileposy=' + point1.y + ' ' +
+									'tilewidth=' + this._tileWidthTwips + ' ' +
+									'tileheight=' + this._tileHeightTwips);
 				}
-				this._update();
 			}
 		}
 		else if (textMsg.startsWith('status:')) {


More information about the Libreoffice-commits mailing list