[Libreoffice-commits] online.git: 2 commits - kit/Kit.cpp loleaflet/dist loleaflet/src wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp

Pranav Kant pranavk at collabora.co.uk
Thu Nov 9 03:24:32 UTC 2017


 kit/Kit.cpp                                |   11 ++++-------
 loleaflet/dist/loleaflet.css               |    6 +++++-
 loleaflet/src/control/Control.LokDialog.js |   21 +++++++++++++++++----
 loleaflet/src/control/Toolbar.js           |    4 ++--
 wsd/ClientSession.cpp                      |   28 ++--------------------------
 wsd/ClientSession.hpp                      |    2 --
 wsd/DocumentBroker.cpp                     |    8 ++------
 wsd/DocumentBroker.hpp                     |    4 +---
 8 files changed, 33 insertions(+), 51 deletions(-)

New commits:
commit f1d78c7e6268ca43c6a949f61599780a5a8d7d73
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Nov 5 15:57:12 2017 +0530

    lokdialog: send invalidate rectangle in dialog command
    
    Change-Id: Iae00498a0ead1ee65dfce0332721e0d0fd2202fb
    Reviewed-on: https://gerrit.libreoffice.org/44518
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 2cf541ed..d798ce88 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -846,10 +846,11 @@ public:
         ws->sendFrame(output.data(), output.size(), WebSocket::FRAME_BINARY);
     }
 
-    void renderDialog(const std::vector<std::string>& tokens, const std::shared_ptr<LOOLWebSocket>& ws, bool child)
+    void renderDialog(const std::vector<std::string>& tokens, const std::shared_ptr<LOOLWebSocket>& ws)
     {
         assert(ws && "Expected a non-null websocket.");
 
+        const bool child = tokens[0] == "dialogchild";
         const int nCanvasWidth = 800;
         const int nCanvasHeight = 600;
         size_t pixmapDataSize = 4 * nCanvasWidth * nCanvasHeight;
@@ -1733,13 +1734,9 @@ private:
                 {
                     renderCombinedTiles(tokens, _ws);
                 }
-                else if (tokens[0] == "dialog")
+                else if (tokens[0] == "dialog" || tokens[0] == "dialogchild")
                 {
-                    renderDialog(tokens, _ws, false);
-                }
-                else if (tokens[0] == "dialogchild")
-                {
-                    renderDialog(tokens, _ws, true);
+                    renderDialog(tokens, _ws);
                 }
                 else if (LOOLProtocol::getFirstToken(tokens[0], '-') == "child")
                 {
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 96e5388f..65ebf07c 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -19,12 +19,17 @@ L.Control.LokDialog = L.Control.extend({
 	},
 
 	_onDialogMsg: function(e) {
-		// FIXME: core sends a different id for many dialogs in callbacks
 		e.dialogId = e.dialogId.replace('.uno:', '');
 		if (e.action === 'invalidate') {
 			// ignore any invalidate callbacks when we have closed the dialog
 			if (this._isOpen(e.dialogId)) {
-				this._map.sendDialogCommand(e.dialogId);
+				var rect = e.rectangle.match(/\d+g/);
+				if (rect != null && rect.length == 4) {
+					var json = {
+						rectangle: e.rectangle
+					};
+				}
+				this._map.sendDialogCommand(e.dialogId, json);
 			}
 		} else if (e.action === 'close') {
 			this._onDialogClose(e.dialogId);
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 4ec419e3..960c02d4 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -139,14 +139,14 @@ L.Map.include({
 		}
 	},
 
-	sendDialogCommand: function (command, json, child) {
+	sendDialogCommand: function (command, rectangle, child) {
 		if (this._permission === 'edit') {
 			if (!command.startsWith('.uno:'))
 				command = '.uno:' + command;
 			var dialogCmd = 'dialog';
 			if (child)
 				dialogCmd = 'dialogchild';
-			this._socket.sendMessage(dialogCmd + ' ' + command + (json ? ' ' + JSON.stringify(json) : ''));
+			this._socket.sendMessage(dialogCmd + ' ' + command + (rectangle ? ' rectangle=' + rectangle : ''));
 		}
 	},
 
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 544b8497..c6b25f8f 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -221,13 +221,9 @@ bool ClientSession::_handleInput(const char *buffer, int length)
     {
         return sendTile(buffer, length, tokens, docBroker);
     }
-    else if (tokens[0] == "dialog")
+    else if (tokens[0] == "dialog" || tokens[0] == "dialogchild")
     {
-        return sendDialog(buffer, length, tokens, docBroker, false);
-    }
-    else if (tokens[0] == "dialogchild")
-    {
-        return sendDialog(buffer, length, tokens, docBroker, true);
+        docBroker->handleDialogRequest(std::string(buffer, length));
     }
     else if (tokens[0] == "tilecombine")
     {
@@ -428,26 +424,6 @@ bool ClientSession::sendTile(const char * /*buffer*/, int /*length*/, const std:
     return true;
 }
 
-bool ClientSession::sendDialog(const char * /*buffer*/, int /*length*/, const std::vector<std::string>& tokens,
-                               const std::shared_ptr<DocumentBroker>& docBroker, bool child)
-{
-    const std::string dialogCmd = child ? "dialogchild" : "dialog";
-    try
-    {
-        if (child)
-            docBroker->handleDialogRequest(tokens[1], shared_from_this(), true);
-        else
-            docBroker->handleDialogRequest(tokens[1], shared_from_this(), false);
-    }
-    catch (const std::exception& exc)
-    {
-        LOG_ERR("Failed to process " + dialogCmd + " command: " << exc.what());
-        return sendTextFrame("error: cmd=" + dialogCmd + " kind=invalid");
-    }
-
-    return true;
-}
-
 bool ClientSession::sendCombinedTiles(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens,
                                       const std::shared_ptr<DocumentBroker>& docBroker)
 {
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index b16fe448..abadb86d 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -124,8 +124,6 @@ private:
                           const std::shared_ptr<DocumentBroker>& docBroker);
     bool sendTile(const char* buffer, int length, const std::vector<std::string>& tokens,
                   const std::shared_ptr<DocumentBroker>& docBroker);
-    bool sendDialog(const char* buffer, int length, const std::vector<std::string>& tokens,
-                    const std::shared_ptr<DocumentBroker>& docBroker, bool child);
     bool sendCombinedTiles(const char* buffer, int length, const std::vector<std::string>& tokens,
                            const std::shared_ptr<DocumentBroker>& docBroker);
 
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c26c2fd5..06a40c99 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1178,15 +1178,11 @@ void DocumentBroker::handleTileRequest(TileDesc& tile,
     _debugRenderedTileCount++;
 }
 
-void DocumentBroker::handleDialogRequest(const std::string& dialogId,
-                                         const std::shared_ptr<ClientSession>& /*session*/,
-                                         bool child)
+void DocumentBroker::handleDialogRequest(const std::string& dialogCmd)
 {
     assertCorrectThread();
     std::unique_lock<std::mutex> lock(_mutex);
-    const std::string dialogCmd = child ? "dialogchild" : "dialog";
-    LOG_DBG("Sending " + dialogCmd +  " render request for dialog " << dialogId);
-    _childProcess->sendTextFrame(dialogCmd + " " + dialogId);
+    _childProcess->sendTextFrame(dialogCmd);
 }
 
 void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined,
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 0387de20..a56d3332 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -303,9 +303,7 @@ public:
     void invalidateTiles(const std::string& tiles);
     void handleTileRequest(TileDesc& tile,
                            const std::shared_ptr<ClientSession>& session);
-    void handleDialogRequest(const std::string& dialogId,
-                             const std::shared_ptr<ClientSession>& session,
-                             bool child);
+    void handleDialogRequest(const std::string& dialogCmd);
     void handleTileCombinedRequest(TileCombined& tileCombined,
                                    const std::shared_ptr<ClientSession>& session);
     void cancelTileRequests(const std::shared_ptr<ClientSession>& session);
commit 83cb6270da47c789e26279617b7fd0b0b32c8908
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sun Nov 5 14:19:54 2017 +0530

    lokdialog: Strip unnecessary padding from dialog container
    
    No idea yet why there still is a thin padding strip at the bottom of the
    dialog.
    
    Change-Id: Ia1347bafbf647385c1771f7af3e755cbf44dd666
    Reviewed-on: https://gerrit.libreoffice.org/44517
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/loleaflet/dist/loleaflet.css b/loleaflet/dist/loleaflet.css
index b577cafc..5c64f4dd 100644
--- a/loleaflet/dist/loleaflet.css
+++ b/loleaflet/dist/loleaflet.css
@@ -334,9 +334,13 @@ body {
 	text-indent: 1px;
 }
 
-.lokdialog_container.ui-dialog-content.ui-widget-content {
+.lokdialog_container.ui-dialog.ui-widget-content {
         padding: 0px;
 	overflow: hidden;
 	width: auto;
 	height: auto;
 }
+
+.lokdialog.ui-dialog-content.ui-widget-content {
+        padding: 0px;
+}
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index ba5f949c..96e5388f 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -39,7 +39,7 @@ L.Control.LokDialog = L.Control.extend({
 	},
 
 	_launchDialog: function(dialogId, width, height) {
-		var canvas = '<div style="padding: 0px; margin: 0px; overflow: hidden;" id="' + dialogId + '">' +
+		var canvas = '<div class="lokdialog" style="padding: 0px; margin: 0px; overflow: hidden;" id="' + dialogId + '">' +
 		    '<canvas tabindex="0" id="' + dialogId + '-canvas" width="' + width + 'px" height="' + height + 'px"></canvas>' +
 		    '</div>';
 		$(document.body).append(canvas);
@@ -51,6 +51,7 @@ L.Control.LokDialog = L.Control.extend({
 			modal: false,
 			closeOnEscape: true,
 			resizable: false,
+			dialogClass: 'lokdialog_container',
 			close: function() {
 				that._onDialogClose(dialogId);
 			}
@@ -80,6 +81,10 @@ L.Control.LokDialog = L.Control.extend({
 			that._handleDialogKeyEvent(e);
 		});
 
+		$('#' + dialogId + '-canvas').on('contextmenu', function() {
+			return false;
+		});
+
 		this._dialogs[dialogId] = true;
 	},
 
@@ -241,7 +246,7 @@ L.Control.LokDialog = L.Control.extend({
 
 		// remove any existing floating element if there's any
 		$('#' + e.dialogId + '-floating').remove();
-		var floatingCanvas = '<canvas id="' + e.dialogId + '-floating"></canvas>';
+		var floatingCanvas = '<canvas class="lokdialogchild-canvas" id="' + e.dialogId + '-floating"></canvas>';
 		$('#' + e.dialogId).append(floatingCanvas);
 		$('#' + e.dialogId + '-floating').css({position: 'absolute', left: left, top: top});
 
@@ -270,6 +275,9 @@ L.Control.LokDialog = L.Control.extend({
 			that._postDialogChildMouseEvent('move', dialogId, e.offsetX, e.offsetY, 1, 0, 0);
 		});
 
+		$('#' + dialogId + '-floating').on('contextmenu', function() {
+			return false;
+		});
 	},
 
 	_onDialogChildMsg: function(e) {


More information about the Libreoffice-commits mailing list