loleaflet/src/layer/tile/GridLayer.js     |   31 ++++++++++++++++++-----
 loleaflet/src/layer/tile/TileLayer.js     |   39 +++++++++++++-----------------
 loleaflet/src/map/handler/Map.Keyboard.js |    1 
 loleaflet/src/map/handler/Map.Mouse.js    |    1 
 loolwsd/LOOLSession.cpp                   |    9 +++---
 5 files changed, 48 insertions(+), 33 deletions(-)

New commits:
commit a6091f9f6bb20a72b0f7e6e985e172c0790e8252
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Wed Jul 29 11:39:35 2015 +0300

    loolwsd: don't decode the url in the saveAs command

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 737435a..7e029f8 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -982,10 +982,7 @@ bool ChildProcessSession::saveAs(const char *buffer, int 
length, StringTokenizer
         return false;
     }
 
-    URI::decode(url, url, true);
-    if (getTokenString(tokens[2], "format", format)) {
-        URI::decode(format, format, true);
-    }
+    getTokenString(tokens[2], "format", format);
 
     if (getTokenString(tokens[3], "options", filterOptions)) {
         if (tokens.count() > 4) {
@@ -993,7 +990,9 @@ bool ChildProcessSession::saveAs(const char *buffer, int 
length, StringTokenizer
         }
     }
 
-    _loKitDocument->pClass->saveAs(_loKitDocument, url.c_str(), 
format.c_str(), filterOptions.c_str());
+    _loKitDocument->pClass->saveAs(_loKitDocument, url.c_str(),
+            format.size() == 0 ? NULL :format.c_str(),
+            filterOptions.size() == 0 ? NULL : filterOptions.c_str());
 
     return true;
 }
commit 932ffaad68cb2934b7e5e3460c5b7b46b6352736
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Tue Jul 28 12:11:56 2015 +0300

    loleaflet: delete invalid tiles outside of the visible area

diff --git a/loleaflet/src/layer/tile/GridLayer.js 
b/loleaflet/src/layer/tile/GridLayer.js
index aa1bca6..70f3c10 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -576,6 +576,9 @@ L.GridLayer = L.Layer.extend({
                        this._tileCache[key] = tile.el.src;
                }
 
+               if (!tile.loaded && this._emptyTilesCount > 0) {
+                       this._emptyTilesCount -= 1;
+               }
                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 36534c3..83d489c 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -265,6 +265,9 @@ L.TileLayer = L.GridLayer.extend({
                        offset = new L.Point(command.width, command.height);
                        bottomRightTwips = topLeftTwips.add(offset);
                        var invalidBounds = new L.Bounds(topLeftTwips, 
bottomRightTwips);
+                       var visibleTopLeft = 
this._latLngToTwips(this._map.getBounds().getNorthWest());
+                       var visibleBottomRight = 
this._latLngToTwips(this._map.getBounds().getSouthEast());
+                       var visibleArea = new L.Bounds(visibleTopLeft, 
visibleBottomRight);
 
                        for (var key in this._tiles) {
                                var coords = this._tiles[key].coords;
@@ -278,14 +281,21 @@ L.TileLayer = L.GridLayer.extend({
                                        else {
                                                this._tiles[key]._invalidCount 
= 1;
                                        }
-                                       this.sendMessage('tile ' +
-                                                                       'part=' 
+ coords.part + ' ' +
-                                                                       
'width=' + this._tileSize + ' ' +
-                                                                       
'height=' + this._tileSize + ' ' +
-                                                                       
'tileposx=' + tileTopLeft.x + ' '    +
-                                                                       
'tileposy=' + tileTopLeft.y + ' ' +
-                                                                       
'tilewidth=' + this._tileWidthTwips + ' ' +
-                                                                       
'tileheight=' + this._tileHeightTwips, key);
+                                       if (visibleArea.intersects(bounds)) {
+                                               this.sendMessage('tile ' +
+                                                                               
'part=' + coords.part + ' ' +
+                                                                               
'width=' + this._tileSize + ' ' +
+                                                                               
'height=' + this._tileSize + ' ' +
+                                                                               
'tileposx=' + tileTopLeft.x + ' '    +
+                                                                               
'tileposy=' + tileTopLeft.y + ' ' +
+                                                                               
'tilewidth=' + this._tileWidthTwips + ' ' +
+                                                                               
'tileheight=' + this._tileHeightTwips, key);
+                                       }
+                                       else {
+                                               // tile outside of the visible 
area, just remove it
+                                               this._preFetchBorder = null;
+                                               this._removeTile(key);
+                                       }
                                }
                        }
                        for (key in this._tileCache) {
@@ -391,9 +401,6 @@ L.TileLayer = L.GridLayer.extend({
                                }
                                tile.el.src = img;
                        }
-                       else {
-                               this._tileCache[key] = img;
-                       }
                        L.Log.log(textMsg, L.INCOMING, key);
                }
                else if (textMsg.startsWith('textselection:')) {
commit f36431571e88e258ca807955b801ea4d111bbc08
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Tue Jul 28 10:31:51 2015 +0300

    loleaflet: start prefetching after 5s of inactivity
    
    After 5s of inactivity request new tiles every 0.75s

diff --git a/loleaflet/src/layer/tile/GridLayer.js 
b/loleaflet/src/layer/tile/GridLayer.js
index b8c5e53..aa1bca6 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -434,16 +434,12 @@ L.GridLayer = L.Layer.extend({
        },
 
        _moveStart: function () {
-               clearInterval(this._tilesPrefetcher);
-               this._tilesPrefetcher = null;
-               this._preFetchBorder = null;
+               this._resetPreFetching();
        },
 
        _move: function () {
                this._update();
-               if (!this._tilesPreFetcher) {
-                       this._tilesPreFetcher = 
setInterval(L.bind(this._preFetchTiles, this), 2000);
-               }
+               this._resetPreFetching(true);
        },
 
        _update: function (center, zoom) {
@@ -746,7 +742,7 @@ L.GridLayer = L.Layer.extend({
        },
 
        _preFetchTiles: function () {
-               if (this._permission === 'edit' || this._emptyTilesCount > 0) {
+               if (this._emptyTilesCount > 0) {
                        return;
                }
                var center = this._map.getCenter();
@@ -754,6 +750,11 @@ L.GridLayer = L.Layer.extend({
                var tilesToFetch = 10;
                var maxBorderWidth = 5;
 
+               if (this._permission === 'edit') {
+                       tilesToFetch = 5;
+                       maxBorderWidth = 3;
+               }
+
                if (!this._preFetchBorder) {
                        var pixelBounds = this._map.getPixelBounds(center, 
zoom),
                                tileBorder = 
this._pxBoundsToTileRange(pixelBounds);
@@ -873,6 +874,19 @@ L.GridLayer = L.Layer.extend({
                        }
                        this._level.el.appendChild(fragment);
                }
+       },
+
+       _resetPreFetching: function (resetBorder) {
+               clearInterval(this._tilesPreFetcher);
+               clearTimeout(this._preFetchIdle);
+               if (resetBorder) {
+                       this._preFetchBorder = null;
+               }
+               var interval = 750;
+               var idleTime = 5000;
+               this._preFetchIdle = setTimeout(L.bind( function () {
+                       this._tilesPreFetcher = 
setInterval(L.bind(this._preFetchTiles, this), interval);
+               }, this), idleTime);
        }
 });
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 423a1c2..36534c3 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -106,7 +106,6 @@ L.TileLayer = L.GridLayer.extend({
                this._map.on('zoomstart zoomend', this._onZoom, this);
                this._map.on('clearselection', this._clearSelections, this);
                this._map.on('copy', this._onCopy, this);
-               this._map.on('alltilesloaded', this._preFetchTiles, this);
                this._startMarker.on('drag dragend', 
this._onSelectionHandleDrag, this);
                this._endMarker.on('drag dragend', this._onSelectionHandleDrag, 
this);
                this._textArea = this._map._textArea;
@@ -342,9 +341,6 @@ L.TileLayer = L.GridLayer.extend({
                                        this._preFetchPart = this._currentPart;
                                        this._preFetchBorder = null;
                                }
-                               if (!this._tilesPreFetcher) {
-                                       this._tilesPreFetcher = 
setInterval(L.bind(this._preFetchTiles, this), 2000);
-                               }
                        }
                }
                else if (textMsg.startsWith('statusindicatorstart:')) {
@@ -693,15 +689,9 @@ L.TileLayer = L.GridLayer.extend({
 
        _onZoom: function (e) {
                if (e.type === 'zoomstart') {
-                       clearInterval(this._tilesPrefetcher);
-                       this._tilesPrefetcher = null;
-                       this._preFetchBorder = null;
                }
                else if (e.type === 'zoomend') {
                        this._onUpdateCursor();
-                       if (!this._tilesPreFetcher) {
-                               this._tilesPreFetcher = 
setInterval(L.bind(this._preFetchTiles, this), 2000);
-                       }
                }
        }
 });
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js 
b/loleaflet/src/map/handler/Map.Keyboard.js
index f1454b5..7217c5e 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -177,6 +177,7 @@ L.Map.Keyboard = L.Handler.extend({
                }
 
                if (docLayer._permission === 'edit') {
+                       docLayer._resetPreFetching();
                        var charCode = e.originalEvent.charCode;
                        var keyCode = e.originalEvent.keyCode;
                        if (e.type === 'keydown' && 
this.handleOnKeyDown[keyCode] && charCode === 0) {
diff --git a/loleaflet/src/map/handler/Map.Mouse.js 
b/loleaflet/src/map/handler/Map.Mouse.js
index ddd4d8d..ba15651 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -29,6 +29,7 @@ L.Map.Mouse = L.Handler.extend({
                }
 
                if (e.type === 'mousedown') {
+                       docLayer._resetPreFetching();
                        this._mouseDown = true;
                        if (this._holdMouseEvent) {
                                clearTimeout(this._holdMouseEvent);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to