[Libreoffice-commits] online.git: Branch 'libreoffice-6-2' - 4 commits - loleaflet/html loleaflet/js loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 4 23:49:57 UTC 2019


 loleaflet/html/loleaflet.html.m4        |    6 ++++--
 loleaflet/js/jquery.mCustomScrollbar.js |   16 +++++++++++++---
 loleaflet/src/control/Control.Scroll.js |    3 ++-
 loleaflet/src/core/Socket.js            |    3 ++-
 loleaflet/src/layer/tile/GridLayer.js   |    2 +-
 loleaflet/src/layer/tile/TileLayer.js   |    6 +++---
 loleaflet/src/map/Map.js                |    7 +++++--
 7 files changed, 30 insertions(+), 13 deletions(-)

New commits:
commit 13256fd9a4843f242fde44c3bbc37687fd99b06d
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Nov 22 14:15:38 2018 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Jan 5 00:48:57 2019 +0100

    Fix jumping after touch zooming also for mobile clients of normal Online
    
    Don't check window.ThisIsAMobileApp but instead use a much more
    convoluted test to catch only the cases where we do want the document
    to be scrolled, and ignore the case that causes the irritating
    jumping.
    
    In _onUpdateCursor() in TileLayer.js, we know that the scroll
    parameter is not undefined when and only when _onUpdateCursor() is
    called from _onInvalidateCursorMsg(). We pass that information down to
    the onUpdate callback handler passed to the _tweenTo() function in the
    _scrollTo() function in jquery.mCustomScrollbar.js where it shows up
    as property of the options object.
    
    In that location we also make use of the incidental fact that
    options.timeout==1 only when that code is called from mouse-wheel scrolling.
    
    Quite possibly all this could be done much cleaner.
    
    Change-Id: Iefa257bceb54137f25534ccb6786c1d2e315931c
    (cherry picked from commit e27ae38bebf4b57aa7563357a188e33d0e1e0be8)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js
index 0a933b063..a0d2d325e 100644
--- a/loleaflet/js/jquery.mCustomScrollbar.js
+++ b/loleaflet/js/jquery.mCustomScrollbar.js
@@ -1,4 +1,4 @@
-/* -*- js-indent-level: 8; indent-tabs-mode: t -*- */
+/* -*- js-indent-level: 8; indent-tabs-mode: t; fill-column: 120 -*- */
 /*
 == malihu jquery custom scrollbar plugin == 
 Version: 3.1.3 
@@ -2120,7 +2120,14 @@ and dependencies (minified).
 					}
 				},onUpdate:function(){
 					if(options.callbacks && options.onUpdate){
-						if (!window.ThisIsAMobileApp || options.drag) {
+						// This condition is intended to filter out the case when this gets
+						// invoked from a touch pinch gesture, but let through the cases of
+						// scrolling with mouse-wheel or touchpad, dragging the scrollbar
+						// slider, or implicit scrolling because of editing in a previously
+						// hidden part of the document (for instance when pressing enter on the
+						// last visible line). The options.timeout==1 is a silly way to detect
+						// the mouse-wheel scrolling.
+						if(options.drag || options.timeout===1 || options.calledFromInvalidateCursorMsg==true){
 							/* callbacks: whileScrolling */
 							if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
 						}
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 3f49ec4a0..829ce18ab 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -155,7 +155,7 @@ L.Control.Scroll = L.Control.extend({
 
 	_onScrollTo: function (e) {
 		// triggered by the document (e.g. search result out of the viewing area)
-		$('.scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x]);
+		$('.scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x], {calledFromInvalidateCursorMsg: e.calledFromInvalidateCursorMsg});
 	},
 
 	_onScrollBy: function (e) {
@@ -169,6 +169,7 @@ L.Control.Scroll = L.Control.extend({
 		if (e.x < 0) {
 			x = '-=' + Math.abs(e.x);
 		}
+		// Note: timeout===1 is checked in my extremely ugly hack in jquery.mCustomScrollbar.js.
 		$('.scroll-container').mCustomScrollbar('scrollTo', [y, x], { timeout: 1 });
 	},
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 6147276ff..dab81ba49 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1608,7 +1608,7 @@ L.TileLayer = L.GridLayer.extend({
 			if (!(this._selectionHandles.start && this._selectionHandles.start.isDragged) &&
 			    !(this._selectionHandles.end && this._selectionHandles.end.isDragged) &&
 			    !(docLayer._followEditor || docLayer._followUser)) {
-				this._map.fire('scrollto', {x: center.x, y: center.y});
+				this._map.fire('scrollto', {x: center.x, y: center.y, calledFromInvalidateCursorMsg: scroll !== undefined});
 			}
 		}
 
commit 34759c9cf89072e92509ebc50274b7c353c913f5
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Nov 21 19:08:03 2018 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Jan 5 00:48:44 2019 +0100

    Factor out tile pixel size to a global setting
    
    For now the same as before, 256, for both normal Online and mobile
    app. If you want to experiment with another value, you only need to
    change it in loleaflet.html.m4. I hope.
    
    Note the FIXME in loleaflet/src/core/Socket.js.
    
    Change-Id: Ic881758d7fa70bbfebcf932b7ed6a1da352e375d
    (cherry picked from commit e7523c988844e1178ab8f96c131ce0ad5433d4c9)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index ca9a7452c..702710a51 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -144,7 +144,8 @@ ifelse(MOBILEAPP,[true],
       window.accessHeader = '';
       window.loleafletLogging = 'true';
       window.outOfFocusTimeoutSecs = 1000000;
-      window.idleTimeoutSecs = 1000000;],
+      window.idleTimeoutSecs = 1000000;
+      window.tileSize = 256;],
      [window.host = '%HOST%';
       window.serviceRoot = '%SERVICE_ROOT%';
       window.accessToken = '%ACCESS_TOKEN%';
@@ -152,7 +153,8 @@ ifelse(MOBILEAPP,[true],
       window.accessHeader = '%ACCESS_HEADER%';
       window.loleafletLogging = '%LOLEAFLET_LOGGING%';
       window.outOfFocusTimeoutSecs = %OUT_OF_FOCUS_TIMEOUT_SECS%;
-      window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;])
+      window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;
+      window.tileSize = 256;])
     </script>
   <script>
 
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 80f810926..1d66ce854 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -785,7 +785,8 @@ L.Socket = L.Class.extend({
 					if (command.type === 'presentation' &&
 					    this._map.options.defaultZoom === this._map.options.zoom) {
 						// If we have a presentation document and the zoom level has not been set
-						// in the options, resize the document so that it fits the viewing area
+						// in the options, resize the document so that it fits the viewing area.
+						// FIXME: Should this 256 be window.tileSize? Unclear to me.
 						var verticalTiles = this._map.getSize().y / 256;
 						tileWidthTwips = Math.round(command.height / verticalTiles);
 						tileHeightTwips = Math.round(command.height / verticalTiles);
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index d19e2d440..afca4f8b4 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -8,7 +8,7 @@ L.GridLayer = L.Layer.extend({
 	options: {
 		pane: 'tilePane',
 
-		tileSize: 256,
+		tileSize: window.tileSize,
 		opacity: 1,
 
 		updateWhenIdle: L.Browser.mobile,
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index bbd18f4e3..6147276ff 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1358,8 +1358,8 @@ L.TileLayer = L.GridLayer.extend({
 		else if (tile && typeof(img) == 'object') {
 			// 'Uint8Array' delta
 			var canvas = document.createElement('canvas');
-			canvas.width = 256;
-			canvas.height = 256;
+			canvas.width = window.tileSize;
+			canvas.height = window.tileSize;
 			var ctx = canvas.getContext('2d');
 
 			var oldImg = new Image();
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 2bc7ff561..e24b0205c 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -17,8 +17,11 @@ L.Map = L.Evented.extend({
 		trackResize: true,
 		markerZoomAnimation: true,
 		defaultZoom: 10,
-		tileWidthTwips: 3840,
-		tileHeightTwips: 3840,
+		// 15 = 1440 twips-per-inch / 96 dpi.
+		// Chosen to match previous hardcoded value of 3840 for
+		// the current tile pixel size of 256.
+		tileWidthTwips: window.tileSize * 15,
+		tileHeightTwips: window.tileSize * 15,
 		urlPrefix: 'lool',
 		wopiSrc: '',
 		cursorURL: 'images/cursors'
commit cae97cd0ef08407f65dd83c602b4162c2f1fa878
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Nov 21 19:27:10 2018 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Jan 5 00:48:26 2019 +0100

    Brown paper bag fix
    
    My previous commit broke scrolling for normal Online with touchpad
    (and presumably wheel mouse). So do it only in the mobile app case.
    
    Change-Id: Ia085549b66ed4584c75d5efb78948f19a33c7907
    (cherry picked from commit 0656ed49900e9444a9e1c524969df93810aec517)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js
index fd8b0ed0b..0a933b063 100644
--- a/loleaflet/js/jquery.mCustomScrollbar.js
+++ b/loleaflet/js/jquery.mCustomScrollbar.js
@@ -2120,7 +2120,7 @@ and dependencies (minified).
 					}
 				},onUpdate:function(){
 					if(options.callbacks && options.onUpdate){
-						if (options.drag) {
+						if (!window.ThisIsAMobileApp || options.drag) {
 							/* callbacks: whileScrolling */
 							if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
 						}
commit cf38c952e04fd3d7a31c1e327c5ebc9ac92635cb
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Nov 21 16:27:27 2018 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Jan 5 00:48:07 2019 +0100

    Better hack that seems to fix the jumping after touch zoom gestures
    
    Unlike my previous (reverted) attempt, now scrolling using the
    scroll-bar keeps working.
    
    Seldom has coming up with an one-liner been as painful as in this case.
    But that's how 3rd-party JavaScript is, I guess.
    
    Change-Id: I18c26da7b41d7e12dd63763651010641ca2a0069
    Reviewed-on: https://gerrit.libreoffice.org/63718
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>
    (cherry picked from commit fbce9a443910ed05c09ddd1830470c6010713944)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js
index 38cc715af..fd8b0ed0b 100644
--- a/loleaflet/js/jquery.mCustomScrollbar.js
+++ b/loleaflet/js/jquery.mCustomScrollbar.js
@@ -2014,6 +2014,7 @@ and dependencies (minified).
 		This is where the actual scrolling happens
 		*/
 		_scrollTo=function(el,to,options){
+			// console.log('malihu _scrollTo: options=' + (options==undefined?'UNDEF':JSON.stringify(options)));
 			var d=el.data(pluginPfx),o=d.opt,
 				defaults={
 					trigger:"internal",
@@ -2119,8 +2120,10 @@ and dependencies (minified).
 					}
 				},onUpdate:function(){
 					if(options.callbacks && options.onUpdate){
-						/* callbacks: whileScrolling */
-						if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
+						if (options.drag) {
+							/* callbacks: whileScrolling */
+							if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
+						}
 					}
 				},onComplete:function(){
 					if(options.callbacks && options.onComplete){


More information about the Libreoffice-commits mailing list