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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 10 11:41:13 UTC 2018


 loleaflet/src/control/Control.MobileInput.js |   75 +++++++++++++++------------
 1 file changed, 44 insertions(+), 31 deletions(-)

New commits:
commit a083c1451fbbc2619bb2eb18481697fd33c5b8cc
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Oct 10 14:00:21 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    Silence eslint warning: error 'i' is already defined

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index be9f404a8..61cf21f6b 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -160,13 +160,14 @@ L.Control.MobileInput = L.Control.extend({
 
 	onInput: function (e) {
 		var backSpace = this._map.keyboard._toUNOKeyCode(8);
+		var i;
 
 		// deferred processing of composition text or normal text; we can get
 		// both in some cases, and based on the input event we need to decide
 		// which one we actually need to use
 		if (e.inputType === 'insertText') {
 			if (this._textData) {
-				for (var i = 0; i < this._textData.length; ++i) {
+				for (i = 0; i < this._textData.length; ++i) {
 					this._map._docLayer._postKeyboardEvent('input', this._textData[i].charCodeAt(), 0);
 				}
 			}
@@ -180,7 +181,7 @@ L.Control.MobileInput = L.Control.extend({
 			// this means we need to delete the entire interim composition;
 			// let's issue backspace that many times
 			if (this._composingData) {
-				for (var i = 0; i < this._composingData.length; ++i) {
+				for (i = 0; i < this._composingData.length; ++i) {
 					this._map._docLayer._postKeyboardEvent('input', 0, backSpace);
 				}
 			}
commit e9293f6954535af93eeaa4e153c335b34edf5c11
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Oct 10 13:49:23 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    Silence eslint warning: error 'map' is not defined
    
    Not sure why it has worked anyway (says kendy), but presumably using
    this._map instead, like at the beginning of the function, works
    identically. Yay for static syntax analysis of a very dynamic
    language.

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 0530cab21..be9f404a8 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -167,13 +167,13 @@ L.Control.MobileInput = L.Control.extend({
 		if (e.inputType === 'insertText') {
 			if (this._textData) {
 				for (var i = 0; i < this._textData.length; ++i) {
-					map._docLayer._postKeyboardEvent('input', this._textData[i].charCodeAt(), 0);
+					this._map._docLayer._postKeyboardEvent('input', this._textData[i].charCodeAt(), 0);
 				}
 			}
 		}
 		else if (e.inputType === 'insertCompositionText') {
 			if (this._composingData) {
-				map._docLayer._postCompositionEvent(0, 'input', this._composingData);
+				this._map._docLayer._postCompositionEvent(0, 'input', this._composingData);
 			}
 		}
 		else if (e.inputType === 'deleteContentBackward' && this._lastInput !== backSpace) {
commit 4cce0e8d0a6355a2fd32b37547bf5b3f9ebc50a2
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Oct 4 00:53:06 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    Cleanup the debugging logging.
    
    Change-Id: I52ba4be4017a1b4d7a2464c078ec2144511f11f7
    Reviewed-on: https://gerrit.libreoffice.org/61338
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit 6baa59678c34ec1e618ba0a2ac2b74983fbbd858)

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 9439f0221..0530cab21 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -89,9 +89,6 @@ L.Control.MobileInput = L.Control.extend({
 		    docLayer = this._map._docLayer,
 		    unoKeyCode = handler._toUNOKeyCode(keyCode);
 
-		console.log('onKeyEvent: e.type === ' + e.type);
-		console.log('onKeyEvent: e.keyCode === "' + e.keyCode + '"');
-		console.log('onKeyEvent: e.charCode === "' + e.charCode + '"');
 		this._keyHandled = this._keyHandled || false;
 		if (this._isComposing) {
 			if (keyCode === 229 && charCode === 0) {
@@ -138,8 +135,7 @@ L.Control.MobileInput = L.Control.extend({
 
 	onCompEvents: function (e) {
 		var map = this._map;
-		console.log('onCompEvents: e.type === ' + e.type);
-		console.log('onCompEvents: e.data === "' + e.data + '"');
+
 		if (e.type === 'compositionstart' || e.type === 'compositionupdate') {
 			this._isComposing = true; // we are starting composing with IME
 			this._composingData = e.data; // cache what we have composed so far
@@ -154,9 +150,6 @@ L.Control.MobileInput = L.Control.extend({
 	},
 
 	onTextInput: function (e) {
-		console.log('onTextInput: e.type === ' + e.type);
-		console.log('onTextInput: e.data === "' + e.data + '"');
-
 		if (!this._keyHandled) {
 			this._textData = e.data;
 			this._textArea.value = '';
@@ -166,9 +159,8 @@ L.Control.MobileInput = L.Control.extend({
 	},
 
 	onInput: function (e) {
-		console.log('onInput: e.inputType === ' + e.inputType);
-
 		var backSpace = this._map.keyboard._toUNOKeyCode(8);
+
 		// deferred processing of composition text or normal text; we can get
 		// both in some cases, and based on the input event we need to decide
 		// which one we actually need to use
commit f3d7e5c6c28e1b2745159157a375a57b18d41cb5
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Oct 4 00:41:34 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    android chrome: Make the insertion of . , ! $ and similar chars work.
    
    The trick is that actually the 'onInput' (the 'input') event decides
    what data we should actually use - if those from compose event, or from
    the text input event.
    
    With this, things finally seem to work reasonably well - I am able to
    insert even emoji :-)
    
    Change-Id: I9f19d1e56e4e638cf88b8497abb8eefd24e82cee
    Reviewed-on: https://gerrit.libreoffice.org/61337
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit 10bfc4b449577590c4de82cb15d73204be053a3c)

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 45920f63a..9439f0221 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -143,9 +143,6 @@ L.Control.MobileInput = L.Control.extend({
 		if (e.type === 'compositionstart' || e.type === 'compositionupdate') {
 			this._isComposing = true; // we are starting composing with IME
 			this._composingData = e.data; // cache what we have composed so far
-			if (e.data) {
-				map._docLayer._postCompositionEvent(0, 'input', e.data);
-			}
 		}
 
 		if (e.type === 'compositionend') {
@@ -161,17 +158,7 @@ L.Control.MobileInput = L.Control.extend({
 		console.log('onTextInput: e.data === "' + e.data + '"');
 
 		if (!this._keyHandled) {
-			// Hack for making space in combination with autocompletion text
-			// input work in Chrome on Andorid.
-			//
-			// Chrome (Android) IME triggers keyup/keydown input with
-			// code 229 when hitting space (as with all composiiton events)
-			// with addition to 'textinput' event, in which we only see that
-			// space was entered.
-			var data = e.data;
-			if (data.length == 1 && data[0] === ' ') {
-				map._docLayer._postKeyboardEvent('input', data[0].charCodeAt(), 0);
-			}
+			this._textData = e.data;
 			this._textArea.value = '';
 		}
 
@@ -179,8 +166,25 @@ L.Control.MobileInput = L.Control.extend({
 	},
 
 	onInput: function (e) {
+		console.log('onInput: e.inputType === ' + e.inputType);
+
 		var backSpace = this._map.keyboard._toUNOKeyCode(8);
-		if (e.inputType && e.inputType === 'deleteContentBackward' && this._lastInput !== backSpace) {
+		// deferred processing of composition text or normal text; we can get
+		// both in some cases, and based on the input event we need to decide
+		// which one we actually need to use
+		if (e.inputType === 'insertText') {
+			if (this._textData) {
+				for (var i = 0; i < this._textData.length; ++i) {
+					map._docLayer._postKeyboardEvent('input', this._textData[i].charCodeAt(), 0);
+				}
+			}
+		}
+		else if (e.inputType === 'insertCompositionText') {
+			if (this._composingData) {
+				map._docLayer._postCompositionEvent(0, 'input', this._composingData);
+			}
+		}
+		else if (e.inputType === 'deleteContentBackward' && this._lastInput !== backSpace) {
 			// this means we need to delete the entire interim composition;
 			// let's issue backspace that many times
 			if (this._composingData) {
@@ -189,6 +193,7 @@ L.Control.MobileInput = L.Control.extend({
 				}
 			}
 		}
+
 		L.DomEvent.stopPropagation(e);
 	}
 });
commit 2bb3e5955cd17c9cf8989ba256a187a7556a6f78
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Oct 3 23:49:45 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    android chrome: Move the onTextInput handling to a separate method.
    
    Change-Id: I1cf091ed9bf82b719ff7bd5170b9e75ecb999d01
    Reviewed-on: https://gerrit.libreoffice.org/61336
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit ea5165794338a05837cc14257ebfcf0fa437c2ab)

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 94084371b..45920f63a 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -75,7 +75,8 @@ L.Control.MobileInput = L.Control.extend({
 		this._textArea.setAttribute('spellcheck', 'false');
 		L.DomEvent.on(this._textArea, stopEvents, L.DomEvent.stopPropagation)
 			.on(this._textArea, 'keydown keypress keyup', this.onKeyEvents, this)
-			.on(this._textArea, 'compositionstart compositionupdate compositionend textInput', this.onCompEvents, this)
+			.on(this._textArea, 'compositionstart compositionupdate compositionend', this.onCompEvents, this)
+			.on(this._textArea, 'textInput', this.onTextInput, this)
 			.on(this._textArea, 'input', this.onInput, this)
 			.on(this._textArea, 'focus', this.onGotFocus, this)
 			.on(this._textArea, 'blur', this.onLostFocus, this);
@@ -152,7 +153,14 @@ L.Control.MobileInput = L.Control.extend({
 			map._docLayer._postCompositionEvent(0, 'end', '');
 		}
 
-		if (e.type === 'textInput' && !this._keyHandled) {
+		L.DomEvent.stopPropagation(e);
+	},
+
+	onTextInput: function (e) {
+		console.log('onTextInput: e.type === ' + e.type);
+		console.log('onTextInput: e.data === "' + e.data + '"');
+
+		if (!this._keyHandled) {
 			// Hack for making space in combination with autocompletion text
 			// input work in Chrome on Andorid.
 			//
@@ -166,6 +174,7 @@ L.Control.MobileInput = L.Control.extend({
 			}
 			this._textArea.value = '';
 		}
+
 		L.DomEvent.stopPropagation(e);
 	},
 
commit bd2bd137497aad77d4ea1c65eb6b919767fcf28a
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Oct 3 21:52:59 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    android chrome: Stop composing when we get an actual key event.
    
    So that it is possible to press Enter while still in composition.
    It is necessary to stop the composing itself, because otherwise the word
    gets duplicated on the new line as soon as the user presses a key.
    
    Change-Id: I78951a423715e71533f1a73d5bbe3b0f0f05e6cd
    Reviewed-on: https://gerrit.libreoffice.org/61334
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit f42e0bb4d1c99c1d229a638e59061ef7985d01e8)

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 3fab3bf56..94084371b 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -88,10 +88,19 @@ L.Control.MobileInput = L.Control.extend({
 		    docLayer = this._map._docLayer,
 		    unoKeyCode = handler._toUNOKeyCode(keyCode);
 
+		console.log('onKeyEvent: e.type === ' + e.type);
+		console.log('onKeyEvent: e.keyCode === "' + e.keyCode + '"');
+		console.log('onKeyEvent: e.charCode === "' + e.charCode + '"');
 		this._keyHandled = this._keyHandled || false;
 		if (this._isComposing) {
+			if (keyCode === 229 && charCode === 0) {
+				return;
+			}
+			// stop the composing - so that we handle eg. Enter even during
+			// composition
+			this._isComposing = false;
 			this._lastInput = null;
-			return;
+			this._textArea.value = '';
 		}
 
 		docLayer._resetPreFetching();
commit d99736cc9a0fd9305dd13c4e2d4f3e2820861710
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Oct 3 19:46:07 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    android chrome: We have to delete the interim results sometimes.
    
    When we are autocorrecting a word, we get a deleteContentBackward event;
    in that case we have to delete everything we have composed so far.
    
    Change-Id: I36f3d1afcb9b74ac75dee7d64832cc5a3d346045
    Reviewed-on: https://gerrit.libreoffice.org/61333
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit f176bb1e81b5f3769cb56752c7102f93f2eca024)

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 25b0addff..3fab3bf56 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -128,14 +128,13 @@ L.Control.MobileInput = L.Control.extend({
 
 	onCompEvents: function (e) {
 		var map = this._map;
+		console.log('onCompEvents: e.type === ' + e.type);
+		console.log('onCompEvents: e.data === "' + e.data + '"');
 		if (e.type === 'compositionstart' || e.type === 'compositionupdate') {
 			this._isComposing = true; // we are starting composing with IME
-			var txt = '';
-			for (var i = 0; i < e.data.length; i++) {
-				txt += e.data[i];
-			}
-			if (txt) {
-				map._docLayer._postCompositionEvent(0, 'input', txt);
+			this._composingData = e.data; // cache what we have composed so far
+			if (e.data) {
+				map._docLayer._postCompositionEvent(0, 'input', e.data);
 			}
 		}
 
@@ -152,11 +151,6 @@ L.Control.MobileInput = L.Control.extend({
 			// code 229 when hitting space (as with all composiiton events)
 			// with addition to 'textinput' event, in which we only see that
 			// space was entered.
-			//
-			// TODO: Maybe make sure this is only triggered when keydown has
-			// 229 code. Also we need to detect that composition was overriden
-			// (part or whole word deleted) with the spell-checked word. (for
-			// example: enter 'tar' and with spell-check correct that to 'rat')
 			var data = e.data;
 			if (data.length == 1 && data[0] === ' ') {
 				map._docLayer._postKeyboardEvent('input', data[0].charCodeAt(), 0);
@@ -169,7 +163,13 @@ L.Control.MobileInput = L.Control.extend({
 	onInput: function (e) {
 		var backSpace = this._map.keyboard._toUNOKeyCode(8);
 		if (e.inputType && e.inputType === 'deleteContentBackward' && this._lastInput !== backSpace) {
-			this._map._docLayer._postKeyboardEvent('input', 0, backSpace);
+			// this means we need to delete the entire interim composition;
+			// let's issue backspace that many times
+			if (this._composingData) {
+				for (var i = 0; i < this._composingData.length; ++i) {
+					this._map._docLayer._postKeyboardEvent('input', 0, backSpace);
+				}
+			}
 		}
 		L.DomEvent.stopPropagation(e);
 	}
commit a346d690faf1bb495bd49bcd2b8322a5ad3a21c5
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Oct 3 17:39:38 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 10 14:38:37 2018 +0300

    android chrome: When autocompleting a word, don't enter it twice.
    
    Most of the text input on Android in Chrome works via the composition;
    only the space has to be entered via textInput.
    
    Change-Id: Icd6cea54a962f324215bb6438265e6500f28421d
    Reviewed-on: https://gerrit.libreoffice.org/61332
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit 04b858d90fb1de00f312efcbf131bacda5479e7c)

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index f03b7ddc9..25b0addff 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -145,24 +145,21 @@ L.Control.MobileInput = L.Control.extend({
 		}
 
 		if (e.type === 'textInput' && !this._keyHandled) {
-			// Hack for making space and spell-check text insert work
-			// in Chrome (on Andorid) or Chrome with IME.
+			// Hack for making space in combination with autocompletion text
+			// input work in Chrome on Andorid.
 			//
 			// Chrome (Android) IME triggers keyup/keydown input with
 			// code 229 when hitting space (as with all composiiton events)
 			// with addition to 'textinput' event, in which we only see that
-			// space was entered. Similar situation is also when inserting
-			// a soft-keyboard spell-check item - it is visible only with
-			// 'textinput' event (no composition event is fired).
-			// To make this work we need to insert textinput.data here..
+			// space was entered.
 			//
 			// TODO: Maybe make sure this is only triggered when keydown has
 			// 229 code. Also we need to detect that composition was overriden
 			// (part or whole word deleted) with the spell-checked word. (for
 			// example: enter 'tar' and with spell-check correct that to 'rat')
 			var data = e.data;
-			for (var idx = 0; idx < data.length; idx++) {
-				map._docLayer._postKeyboardEvent('input', data[idx].charCodeAt(), 0);
+			if (data.length == 1 && data[0] === ' ') {
+				map._docLayer._postKeyboardEvent('input', data[0].charCodeAt(), 0);
 			}
 			this._textArea.value = '';
 		}


More information about the Libreoffice-commits mailing list