[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-4' - 4 commits - loleaflet/README loleaflet/spec loleaflet/src loolwsd/LOOLSession.cpp loolwsd/protocol.txt

Mihai Varga mihai.varga at collabora.com
Thu Aug 6 23:52:52 PDT 2015


 loleaflet/README                          |    4 +++-
 loleaflet/spec/tilebench/TileBenchSpec.js |   28 +++++++++++++++++-----------
 loleaflet/src/control/Control.Search.js   |    5 +++++
 loleaflet/src/control/Permission.js       |    1 +
 loleaflet/src/layer/tile/TileLayer.js     |    7 ++++++-
 loolwsd/LOOLSession.cpp                   |    6 +++++-
 loolwsd/protocol.txt                      |    5 +++++
 7 files changed, 42 insertions(+), 14 deletions(-)

New commits:
commit 45793d2cb3dcb77da58c26707899afbfee1a1fc1
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Aug 7 09:50:50 2015 +0300

    loleaflet: updated README with alltilesloaded event

diff --git a/loleaflet/README b/loleaflet/README
index 67faeeb..2b35a9e 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -101,11 +101,13 @@ Parts (like slides in presentation, or sheets in spreadsheets):
 Statusindicator (when the document is loading):
     - events
         map.on('statusindicator', function (e) {}) where:
-            + e.statusType = 'start' | 'setvalue' | 'finish' | 'loleafletloaded'
+            + e.statusType = 'start' | 'setvalue' | 'finish' | 'loleafletloaded' | 'alltilesloaded'
             + e.value == a value from 0 to 100 indicating the status
               if the statusType is 'setvalue
             + 'loleafletloaded' is fired when the JS code is initialized and the document
                 load request is sent and we're waiting for the tiles
+            + 'alltilesloaded' is fired when all newly requested (empty tiles) have been loaded
+                it is not fired during pre-fetching and during editing
 
 Save:
     - API:
commit 913ff95717b7d05a3fa22f07c42be4b2b5b39a97
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Aug 7 09:49:20 2015 +0300

    loleaflet: requestLOKSession event handler

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 4011af5..1372443 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -111,6 +111,7 @@ L.TileLayer = L.GridLayer.extend({
 		this._map.on('copy', this._onCopy, this);
 		this._map.on('zoomend', this._onUpdateCursor, this);
 		this._map.on('dragstart', this._onDragStart, this);
+		this._map.on('requestloksession', this._onRequestLOKSession, this);
 		this._startMarker.on('drag dragend', this._onSelectionHandleDrag, this);
 		this._endMarker.on('drag dragend', this._onSelectionHandleDrag, this);
 		this._textArea = this._map._textArea;
@@ -732,6 +733,10 @@ L.TileLayer = L.GridLayer.extend({
 
 	_onDragStart: function () {
 		this._map.on('moveend', this._updateScrollOffset, this);
+	},
+
+	_onRequestLOKSession: function () {
+		this.sendMessage('requestloksession');
 	}
 });
 
commit 2edb9086a0ebfafbc81a0326b13d510a12001b6c
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Aug 7 09:44:10 2015 +0300

    loleaflet: fire 'alltilesloaded' as a statusindicator event
    
    This is fired all the new (empty) tiles have been loaded.
    This is not fire for prefetched tiles

diff --git a/loleaflet/spec/tilebench/TileBenchSpec.js b/loleaflet/spec/tilebench/TileBenchSpec.js
index 28ac2b0..a31a0b6 100644
--- a/loleaflet/spec/tilebench/TileBenchSpec.js
+++ b/loleaflet/spec/tilebench/TileBenchSpec.js
@@ -50,7 +50,7 @@ describe('TileBench', function () {
 	});
 
 	afterEach(function () {
-		map.off('alltilesloaded');
+		map.off('statusindicator');
 	});
 
 	after(function () {
@@ -61,9 +61,11 @@ describe('TileBench', function () {
 
 	describe('Benchmarking', function () {
 		it('Load all new tiles', function (done) {
-			map.on('alltilesloaded', L.bind(function () {
-				loadCount += 1;
-				done();
+			map.on('statusindicator', L.bind(function (e) {
+				if (e.statusType === 'alltilesloaded') {
+					loadCount += 1;
+					done();
+				}
 			}, done));
 
 		});
@@ -75,9 +77,11 @@ describe('TileBench', function () {
 			var aproxTime = keyInput[keyInput.length - 1][0] + 2000;
 
 			setTimeout(L.bind(function () {
-				map.on('alltilesloaded', L.bind(function () {
-					loadCount += 1;
-					getTimes(done);
+				map.on('statusindicator', L.bind(function (e) {
+					if (e.statusType === 'alltilesloaded') {
+						loadCount += 1;
+						getTimes(done);
+					}
 				}, done));
 
 
@@ -115,10 +119,12 @@ describe('TileBench', function () {
 					done();
 				}
 				else {
-					map.on('alltilesloaded', L.bind(function () {
-						loadCount += 1;
-						clearTimeout(this.timeOut);
-						done();
+					map.on('statusindicator', L.bind(function (e) {
+						if (e.statusType === 'alltilesloaded') {
+							loadCount += 1;
+							clearTimeout(this.timeOut);
+							done();
+						}
 					}, done));
 				}
 			}, done), 3200);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index eb8ca81..4011af5 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -418,7 +418,7 @@ L.TileLayer = L.GridLayer.extend({
 				if (!tile.loaded) {
 					this._emptyTilesCount -= 1;
 					if (this._emptyTilesCount === 0) {
-						this._map.fire('alltilesloaded');
+						this._map.fire('statusindicator', {statusType: 'alltilesloaded'});
 					}
 				}
 				tile.el.src = img;
commit 2f355dcee90741d0abde671ec9e8669fc4d7f581
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Thu Aug 6 18:54:45 2015 +0300

    'requestloksession' message that starts a LOK process
    
    Used to predict the user's interaction with the document and to
    provide a better response time

diff --git a/loleaflet/src/control/Control.Search.js b/loleaflet/src/control/Control.Search.js
index 91e3638..c383e02 100644
--- a/loleaflet/src/control/Control.Search.js
+++ b/loleaflet/src/control/Control.Search.js
@@ -46,6 +46,9 @@ L.Control.Search = L.Control.extend({
 			this._updateDisabled();
 			this._refocusOnMap();
 		}
+		else {
+			this._map._docLayer.sendMessage('requestloksession');
+		}
 	},
 
 	_searchResultFound: function (e) {
@@ -82,6 +85,8 @@ L.Control.Search = L.Control.extend({
 		bar.title = title;
 
 		L.DomEvent
+			.on(bar, 'click', L.DomEvent.stop)
+			.on(bar, 'click', fn, this)
 			.on(bar, 'keyup', L.DomEvent.stop)
 			.on(bar, 'keyup', fn, this);
 
diff --git a/loleaflet/src/control/Permission.js b/loleaflet/src/control/Permission.js
index 8d80993..f6ed8ee 100644
--- a/loleaflet/src/control/Permission.js
+++ b/loleaflet/src/control/Permission.js
@@ -21,6 +21,7 @@ L.Map.include({
 		if (this._docLayer._permission === 'edit') {
 			return;
 		}
+		this._docLayer.sendMessage('requestloksession');
 		this.dragging.disable();
 	},
 
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index c74920f..1555017 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -259,6 +259,7 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
              tokens[0] != "invalidatetiles" &&
              tokens[0] != "key" &&
              tokens[0] != "mouse" &&
+             tokens[0] != "requestloksession" &&
              tokens[0] != "resetselection" &&
              tokens[0] != "saveas" &&
              tokens[0] != "selectgraphic" &&
@@ -302,7 +303,10 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
 
         if (_peer.expired())
             dispatchChild();
-        forwardToPeer(buffer, length);
+        if (tokens[0] != "requestloksession")
+        {
+            forwardToPeer(buffer, length);
+        }
 
         if ((tokens.count() > 1 && tokens[0] == "uno" && tokens[1] == ".uno:Save")) {
            _tileCache->documentSaved();
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 10b17f9..734d317 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -43,6 +43,11 @@ mouse type=<type> x=<x> y=<y> count=<count>
 
     <type> is 'buttondown', 'buttonup' or 'move', others are numbers.
 
+requestloksession
+
+    requests the initialization of a LOK process in an attempt to predict the user's
+    interaction with the document
+
 resetselection
 
 saveas url=<url> format=<format> options=<options>


More information about the Libreoffice-commits mailing list