[Libreoffice-commits] online.git: loleaflet/src
László Németh
laszlo.nemeth at collabora.com
Tue Sep 20 11:25:13 UTC 2016
loleaflet/src/layer/tile/CalcTileLayer.js | 3 ++
loleaflet/src/layer/tile/ImpressTileLayer.js | 3 ++
loleaflet/src/layer/tile/TileLayer.js | 38 +++++++++++++++++++++++++++
loleaflet/src/layer/tile/WriterTileLayer.js | 3 ++
4 files changed, 47 insertions(+)
New commits:
commit fb351f2c1af04e784b66aefb2d1fd2bd696df6c1
Author: László Németh <laszlo.nemeth at collabora.com>
Date: Tue Sep 20 13:16:02 2016 +0200
add client-side tile debugging mode
Extending the document URL with debug=1 option will switch
- visible tile boundaries
- update numbers over tiles
and invalidated tiles will be blue during waiting for an update.
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index b3ac37f..1d51cf8 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -64,6 +64,9 @@ L.CalcTileLayer = L.TileLayer.extend({
}
tilePositionsY += tileTopLeft.y;
needsNewTiles = true;
+ if (this._debug && this._tiles[key]._debugTile) {
+ this._tiles[key]._debugTile.setStyle({fillOpacity: 0.5});
+ }
}
else {
// tile outside of the visible area, just remove it
diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js
index 8f2358a..96934d6 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -48,6 +48,9 @@ L.ImpressTileLayer = L.TileLayer.extend({
}
tilePositionsY += tileTopLeft.y;
needsNewTiles = true;
+ if (this._debug && this._tiles[key]._debugTile) {
+ this._tiles[key]._debugTile.setStyle({fillOpacity: 0.5});
+ }
}
else {
// tile outside of the visible area, just remove it
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 4317e17..b9e0afb 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -12,6 +12,12 @@ if (typeof String.prototype.startsWith !== 'function') {
};
}
+function getParameterByName(name) {
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
+ var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(location.search);
+ return results === null ? '' : results[1].replace(/\+/g, ' ');
+}
+
L.Compatibility = {
clipboardGet: function (event) {
var text = null;
@@ -146,6 +152,12 @@ L.TileLayer = L.GridLayer.extend({
map.addLayer(this._viewSelectionsGroup);
this._viewSelections = {};
+ this._debug = (getParameterByName('debug') == '1');
+ if (this._debug) {
+ this._debugInfo = new L.LayerGroup();
+ map.addLayer(this._debugInfo);
+ }
+
this._searchResultsLayer = new L.LayerGroup();
map.addLayer(this._searchResultsLayer);
@@ -982,6 +994,25 @@ L.TileLayer = L.GridLayer.extend({
coords.part = command.part;
var key = this._tileCoordsToKey(coords);
var tile = this._tiles[key];
+ if (this._debug && tile) {
+ var tileBound = this._keyToBounds(key);
+ if (tile._debugLoadCount) {
+ tile._debugLoadCount += 1;
+ } else {
+ tile._debugLoadCount = 1;
+ }
+ if (!tile._debugPopup) {
+ tile._debugPopup = L.popup({offset: new L.Point(0, 0), autoPan: false, closeButton: false, closeOnClick: false})
+ .setLatLng(new L.LatLng(tileBound.getSouth(), tileBound.getCenter().lng)).setContent('-');
+ this._debugInfo.addLayer(tile._debugPopup);
+ tile._debugTile = L.rectangle(tileBound, {color: 'blue', weight: 1, fillOpacity: 0, pointerEvents: 'none'});
+ this._debugInfo.addLayer(tile._debugTile);
+ }
+ tile._debugPopup.setContent('' + this._tiles[key]._debugLoadCount);
+ if (tile._debugTile) {
+ tile._debugTile.setStyle({fillOpacity: 0});
+ }
+ }
if (command.id !== undefined) {
this._map.fire('tilepreview', {
tile: img,
@@ -1701,6 +1732,13 @@ L.TileLayer = L.GridLayer.extend({
},
_invalidateClientVisibleArea: function() {
+ if (this._debug) {
+ this._debugInfo.clearLayers();
+ for (var key in this._tiles) {
+ this._tiles[key]._debugPopup = null;
+ this._tiles[key]._debugTile = null;
+ }
+ }
this._clientVisibleArea = true;
}
});
diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js
index ab604aa..d29c3d5 100644
--- a/loleaflet/src/layer/tile/WriterTileLayer.js
+++ b/loleaflet/src/layer/tile/WriterTileLayer.js
@@ -49,6 +49,9 @@ L.WriterTileLayer = L.TileLayer.extend({
}
tilePositionsY += tileTopLeft.y;
needsNewTiles = true;
+ if (this._debug && this._tiles[key]._debugTile) {
+ this._tiles[key]._debugTile.setStyle({fillOpacity: 0.5});
+ }
}
else {
// tile outside of the visible area, just remove it
More information about the Libreoffice-commits
mailing list