[Libreoffice-commits] online.git: loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 01:28:59 UTC 2019


 loleaflet/src/control/Control.LokDialog.js |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

New commits:
commit 9162f9710d51ec8ca97763762d33e3c3387fc2d0
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Feb 3 21:33:52 2019 -0500
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Mar 5 02:28:41 2019 +0100

    leaflet: render child windows in HiDPI
    
    Aparently we were not setting the dimensions
    of the child canvas correctly.
    
    This also fixed the issue with horizontal scrollbar
    showing for some child windows (those on the far right)
    and reduces flickering when poping up child windows.
    
    Change-Id: Ie6f2caa25ed2e43e5a3d98ec7148859c727a4916
    Reviewed-on: https://gerrit.libreoffice.org/67502
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 3f5ddbf58..cc4205560 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -585,9 +585,9 @@ L.Control.LokDialog = L.Control.extend({
 
 	// Binary dialog msg recvd from core
 	_onDialogPaint: function (e) {
-		var parent = this._getParentId(e.id);
-		if (parent) {
-			this._paintDialogChild(parent, e.width, e.height, e.rectangle, e.img);
+		var parentId = this._getParentId(e.id);
+		if (parentId) {
+			this._paintDialogChild(parentId, e.img);
 		} else {
 			this._paintDialog(e.id, e.rectangle, e.img);
 		}
@@ -595,18 +595,24 @@ L.Control.LokDialog = L.Control.extend({
 
 	// Dialog Child Methods
 
-	_paintDialogChild: function(parentId, width, height, rectangle, imgData) {
+	_paintDialogChild: function(parentId, imgData) {
 		var strId = this._toStrId(parentId);
 		var canvas = L.DomUtil.get(strId + '-floating');
 		if (!canvas)
 			return; // no floating window to paint to
 
-		this._setCanvasWidthHeight(canvas, width, height);
+		// The image is rendered per the HiDPI scale we used
+		// while requesting rendering the image. Here we
+		// set the canvas to have the actual size, while
+		// the image is rendred with the HiDPI scale.
+		this._setCanvasWidthHeight(canvas, this._dialogs[parentId].childwidth,
+										   this._dialogs[parentId].childheight);
 
 		var ctx = canvas.getContext('2d');
 		var img = new Image();
 		img.onload = function() {
 			ctx.drawImage(img, 0, 0);
+			$(canvas).show();
 		};
 		img.src = imgData;
 	},
@@ -628,6 +634,7 @@ L.Control.LokDialog = L.Control.extend({
 		var strId = this._toStrId(parentId);
 		var dialogContainer = L.DomUtil.get(strId);
 		var floatingCanvas = L.DomUtil.create('canvas', 'lokdialogchild-canvas', dialogContainer);
+		$(floatingCanvas).hide(); // Hide to avoid flickering while we set the dimensions.
 		floatingCanvas.id = strId + '-floating';
 		L.DomUtil.setStyle(floatingCanvas, 'position', 'absolute');
 		L.DomUtil.setStyle(floatingCanvas, 'left', left + 'px'); // yes, it's necessary to append 'px'


More information about the Libreoffice-commits mailing list