loleaflet/src/layer/tile/GridLayer.js |   16 ++++++++++++++--
 loleaflet/src/layer/tile/TileLayer.js |   11 ++++++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit d3fe7a2eb9093bd2cf80184a06ef3cd4f206d9fe
Author: Marco Cecchetti <marco.cecche...@collabora.com>
Date:   Wed Dec 13 18:09:36 2017 +0100

    calc: do not scroll to cell cursor when position is not changed
    
    Old behaviour: when a cell cursor message is handled the document is
    always scrolled in order to make the cell cursor visible.
    
    New behaviour: as the old one except when the position of the cell
    cursor is unchanged: in that case no scroll occurs.
    
    Change-Id: Iee9b8e2d9fc8cb72d0292fb48a20cadeedeb015b
    Reviewed-on: https://gerrit.libreoffice.org/46538
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 421ad445..2cfd27cb 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -649,6 +649,13 @@ L.TileLayer = L.GridLayer.extend({
                if (!this._prevCellCursor) {
                        this._prevCellCursor = L.LatLngBounds.createDefault();
                }
+               if (!this._cellCursorXY) {
+                       this._cellCursorXY = new L.Point(-1, -1);
+               }
+               if (!this._prevCellCursorXY) {
+                       this._prevCellCursorXY = new L.Point(-1, -1);
+               }
+
                if (textMsg.match('EMPTY')) {
                        this._cellCursorTwips = new L.Bounds(new L.Point(0, 0), 
new L.Point(0, 0));
                        this._cellCursor = L.LatLngBounds.createDefault();
@@ -662,6 +669,7 @@ L.TileLayer = L.GridLayer.extend({
                        this._cellCursor = new L.LatLngBounds(
                                                        
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
                                                        
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
+                       this._cellCursorXY = new L.Point(parseInt(strTwips[4]), 
parseInt(strTwips[5]));
                }
 
                var horizontalDirection = 0;
@@ -1671,7 +1679,7 @@ L.TileLayer = L.GridLayer.extend({
        _onUpdateCellCursor: function (horizontalDirection, verticalDirection, 
onPgUpDn) {
                if (this._cellCursor && 
!this._isEmptyRectangle(this._cellCursor)) {
                        var mapBounds = this._map.getBounds();
-                       if (!mapBounds.contains(this._cellCursor)) {
+                       if (!mapBounds.contains(this._cellCursor) && 
!this._cellCursorXY.equals(this._prevCellCursorXY)) {
                                var scrollX = 0, scrollY = 0;
                                if (onPgUpDn) {
                                        var mapHalfHeight = 
(mapBounds.getNorth() - mapBounds.getSouth()) / 2;
@@ -1709,6 +1717,7 @@ L.TileLayer = L.GridLayer.extend({
                                        center.y = Math.round(center.y < 0 ? 0 
: center.y);
                                        this._map.fire('scrollto', {x: 
center.x, y: center.y});
                                }
+                               this._prevCellCursorXY = this._cellCursorXY;
                        }
 
                        if (onPgUpDn) {
commit 8eff413c7ed953deb1206cbb415d56db6081a493
Author: Marco Cecchetti <marco.cecche...@collabora.com>
Date:   Mon Dec 11 11:35:49 2017 +0100

    missing to update a tile content
    
    When a tile has been invalidated, and the new tile content has not yet
    been fetched and in the between a `canceltiles` message occurs, the
    new tile content will never be fetched;
    example: a tile is invalidated but a sudden scroll to the cell cursor
    position causes to move the tile out of the visible area before the
    new content is fetched, so when the tile is back inside the visible
    area its content would be the old invalidated one;
    
    Change-Id: Ib5f2605490cb9b15fba146e185f683cb7b8d31b6
    Reviewed-on: https://gerrit.libreoffice.org/46537
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/layer/tile/GridLayer.js 
b/loleaflet/src/layer/tile/GridLayer.js
index 407f6612..d080cdfe 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -544,7 +544,13 @@ L.GridLayer = L.Layer.extend({
                                // so we're able to cancel the previous 
requests that are being processed
                                this._map._socket.sendMessage('canceltiles');
                                for (key in this._tiles) {
-                                       if (!this._tiles[key].loaded) {
+                                       // When _invalidCount > 0 the tile has 
been invalidated, however the new tile content
+                                       // has not yet been fetched and because 
of `canceltiles` message it will never be
+                                       // so we need to remove the tile, or 
when the tile is back inside the visible area
+                                       // its content would be the old 
invalidated one;
+                                       // example: a tile is invalidated but a 
sudden scroll to the cell cursor position causes
+                                       // to move the tile out of the visible 
area before the new content is fetched
+                                       if (!this._tiles[key].loaded || 
this._tiles[key]._invalidCount > 0) {
                                                
L.DomUtil.remove(this._tiles[key].el);
                                                delete this._tiles[key];
                                                if (this._debug) {
@@ -617,7 +623,13 @@ L.GridLayer = L.Layer.extend({
                                this._map._socket.sendMessage('canceltiles');
                                for (key in this._tiles) {
                                        tile = this._tiles[key];
-                                       if (!tile.loaded) {
+                                       // When _invalidCount > 0 the tile has 
been invalidated, however the new tile content
+                                       // has not yet been fetched and because 
of `canceltiles` message it will never be
+                                       // so we need to remove the tile, or 
when the tile is back inside the visible area
+                                       // its content would be the old 
invalidated one;
+                                       // example: a tile is invalidated but a 
sudden scroll to the cell cursor position causes
+                                       // to move the tile out of the visible 
area before the new content is fetched
+                                       if (!tile.loaded || tile._invalidCount 
> 0) {
                                                L.DomUtil.remove(tile.el);
                                                delete this._tiles[key];
                                                if (this._debug && 
this._debugDataCancelledTiles) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to