loleaflet/src/core/Socket.js          |    4 +++-
 loleaflet/src/layer/tile/GridLayer.js |   30 ++++++++++++++++++++----------
 2 files changed, 23 insertions(+), 11 deletions(-)

New commits:
commit ea2dc76b2212567446a1ad0ff5cd5473015c442b
Author:     Tamás Zolnai <[email protected]>
AuthorDate: Wed Sep 5 13:20:56 2018 +0200
Commit:     Jan Holesovsky <[email protected]>
CommitDate: Fri Sep 7 13:24:29 2018 +0200

    Reset client visible area members by connection lost / reloading
    
    Change-Id: I28eb32d7c667a1a2b71de4bfcb348f5fab020123
    (cherry picked from commit 8af096eb634d17c6937ff33fc4361c95d5e92fd5)
    Reviewed-on: https://gerrit.libreoffice.org/60028
    Reviewed-by: Jan Holesovsky <[email protected]>
    Tested-by: Jan Holesovsky <[email protected]>

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index b07e4c098..13bc243f6 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -516,6 +516,7 @@ L.Socket = L.Class.extend({
 
                        if (this._map._docLayer) {
                                this._map._docLayer.removeAllViews();
+                               this._map._docLayer._resetClientVisArea();
                        }
                        this.close();
 
@@ -748,7 +749,7 @@ L.Socket = L.Class.extend({
                        else if (this._reconnecting) {
                                // we are reconnecting ...
                                this._reconnecting = false;
-                               this._map._docLayer.viewReset();
+                               this._map._docLayer._resetClientVisArea();
                                
this._map._docLayer._onMessage('invalidatetiles: EMPTY', null);
                                this._map.fire('statusindicator', {statusType: 
'reconnected'});
                                
this._map.setPermission(this._map.options.permission);
@@ -792,6 +793,7 @@ L.Socket = L.Class.extend({
 
                if (this._map._docLayer) {
                        this._map._docLayer.removeAllViews();
+                       this._map._docLayer._resetClientVisArea();
                }
 
                if (isActive && this._reconnecting) {
diff --git a/loleaflet/src/layer/tile/GridLayer.js 
b/loleaflet/src/layer/tile/GridLayer.js
index 3bd563639..3ef87b2d6 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -334,6 +334,7 @@ L.GridLayer = L.Layer.extend({
                    tileZoomChanged = this._tileZoom !== tileZoom;
 
                if (!noUpdate && (hard || tileZoomChanged)) {
+                       this._resetClientVisArea();
 
                        if (this._abortLoading) {
                                this._abortLoading();
@@ -359,6 +360,11 @@ L.GridLayer = L.Layer.extend({
                this._setZoomTransforms(center, zoom);
        },
 
+       _resetClientVisArea: function ()  {
+               this._clientZoom = '';
+               this._clientVisibleArea = '';
+       },
+
        _updateTileTwips: function () {
                // smaller zoom = zoom in
                var factor = Math.pow(1.2, (this._map.options.zoom - 
this._tileZoom));
@@ -542,9 +548,9 @@ L.GridLayer = L.Layer.extend({
                        }
                }
 
-               this._sendClientVisibleArea();
+               this._sendClientVisibleArea(true);
 
-               this._sendClientZoom();
+               this._sendClientZoom(true);
 
                if (queue.length !== 0) {
                        if (newView) {
@@ -692,7 +698,7 @@ L.GridLayer = L.Layer.extend({
                }
        },
 
-       _sendClientVisibleArea: function () {
+       _sendClientVisibleArea: function (forceUpdate) {
                var visibleTopLeft = 
this._latLngToTwips(this._map.getBounds().getNorthWest());
                var visibleBottomRight = 
this._latLngToTwips(this._map.getBounds().getSouthEast());
                var visibleArea = new L.Bounds(visibleTopLeft, 
visibleBottomRight);
@@ -700,10 +706,11 @@ L.GridLayer = L.Layer.extend({
                var newClientVisibleArea = 'clientvisiblearea x=' + 
Math.round(visibleTopLeft.x) + ' y=' + Math.round(visibleTopLeft.y) +
                        ' width=' + Math.round(size.x) + ' height=' + 
Math.round(size.y);
 
-               if (this._clientVisibleArea !== newClientVisibleArea) {
+               if (this._clientVisibleArea !== newClientVisibleArea || 
forceUpdate) {
                        // Visible area is dirty, update it on the server
-                       this._clientVisibleArea = newClientVisibleArea
-                       this._map._socket.sendMessage(this._clientVisibleArea);
+                       this._map._socket.sendMessage(newClientVisibleArea);
+                       if (!this._map._fatal && this._map._active && 
this._map._socket.connected())
+                               this._clientVisibleArea = newClientVisibleArea
                        if (this._debug) {
                                this._debugInfo.clearLayers();
                                for (var key in this._tiles) {
@@ -714,16 +721,19 @@ L.GridLayer = L.Layer.extend({
                }
        },
 
-       _sendClientZoom: function () {
+       _sendClientZoom: function (forceUpdate) {
+
                var newClientZoom = 'tilepixelwidth=' + this._tileWidthPx + ' ' 
+
                        'tilepixelheight=' + this._tileHeightPx + ' ' +
                        'tiletwipwidth=' + this._tileWidthTwips + ' ' +
                        'tiletwipheight=' + this._tileHeightTwips;
 
-               if (this._clientZoom !== newClientZoom) {
+               if (this._clientZoom !== newClientZoom || forceUpdate) {
                        // the zoom level has changed
-                       this._clientZoom = newClientZoom;
-                       this._map._socket.sendMessage('clientzoom ' + 
this._clientZoom);
+                       this._map._socket.sendMessage('clientzoom ' + 
newClientZoom);
+
+                       if (!this._map._fatal && this._map._active && 
this._map._socket.connected())
+                               this._clientZoom = newClientZoom;
                }
        },
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to