[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - loleaflet/src

Pranav Kant pranavk at collabora.co.uk
Tue Mar 13 16:54:15 UTC 2018


 loleaflet/src/map/handler/Map.Keyboard.js |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 2b434d85419a9eeba8e5f504b3cdf2b6b8727813
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Mar 12 17:41:36 2018 +0530

    loleaflet: firefox emits 'keypress' for shift+insert too
    
    So, we need to ignore the key event in the start of the handler.
    Otherwise, in the case of firefox, us ignoring it in 'keydown' gets it
    handled in 'keypress' which does double copy/paste.
    
    Change-Id: I93f0e5c7db8817fab42764d0f0d3b12b50d62f81
    Reviewed-on: https://gerrit.libreoffice.org/51133
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 11c9d57b0..cb0d42f40 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -180,17 +180,16 @@ L.Map.Keyboard = L.Handler.extend({
 		this._map.off('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
 	},
 
-	_handleOnKeyDown: function (keyCode, modifier) {
-		if (modifier & this.keyModifier.shift) {
+	_ignoreKeyEvent: function(e) {
+		var shift = e.originalEvent.shiftKey ? this.keyModifier.shift : 0;
+		if (shift && (e.originalEvent.keyCode === 45 || e.originalEvent.keyCode === 46)) {
 			// don't handle shift+insert, shift+delete
 			// These are converted to 'cut', 'paste' events which are
 			// automatically handled by us, so avoid double-handling
-			if (keyCode === 45 || keyCode === 46) {
-				return false;
-			}
+			return true;
 		}
 
-		return this.handleOnKeyDownKeys[keyCode];
+		return false;
 	},
 
 	_setPanOffset: function (pan) {
@@ -334,16 +333,19 @@ L.Map.Keyboard = L.Handler.extend({
 		if (this._map._permission === 'edit') {
 			docLayer._resetPreFetching();
 
-			if (e.type === 'keydown') {
+			if (this._ignoreKeyEvent(e)) {
+				// key ignored
+			}
+			else if (e.type === 'keydown') {
 				this._keyHandled = false;
 				this._bufferedTextInputEvent = null;
 
-				if (this._handleOnKeyDown(keyCode, this.modifier) && charCode === 0) {
+				if (this.handleOnKeyDownKeys[keyCode] && charCode === 0) {
 					keyEventFn('input', charCode, unoKeyCode);
 				}
 			}
 			else if ((e.type === 'keypress' || e.type === 'compositionend') &&
-			         (!this._handleOnKeyDown(keyCode, this.modifier) || charCode !== 0)) {
+			         (!this.handleOnKeyDownKeys[keyCode] || charCode !== 0)) {
 				if (charCode === keyCode && charCode !== 13) {
 					// Chrome sets keyCode = charCode for printable keys
 					// while LO requires it to be 0


More information about the Libreoffice-commits mailing list