[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - loleaflet/src
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 13 11:21:24 UTC 2019
loleaflet/src/control/Control.MobileInput.js | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
New commits:
commit 79e3ab8d8426d0294f3e5d28e417a5aaa00c85fa
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Mar 26 01:53:21 2019 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Jun 13 13:21:06 2019 +0200
tdf#124178: Handle non-BMP character input on mobile devices
Sadly, we must split such into a surrogate pair.
Change-Id: I59e493963cf71d14d389c58a94b17d16aec2311e
Reviewed-on: https://gerrit.libreoffice.org/73942
Reviewed-by: Tor Lillqvist <tml at collabora.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 467f44dad..d1f65b240 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -108,6 +108,12 @@ L.Control.MobileInput = L.Control.extend({
.on(this._textArea, 'blur', this.onLostFocus, this);
},
+ _getSurrogatePair: function(codePoint) {
+ var highSurrogate = Math.floor((codePoint - 0x10000) / 0x400) + 0xD800;
+ var lowSurrogate = (codePoint - 0x10000) % 0x400 + 0xDC00;
+ return [highSurrogate, lowSurrogate];
+ },
+
onKeyEvents: function (e) {
var keyCode = e.keyCode,
charCode = e.charCode,
@@ -147,12 +153,27 @@ L.Control.MobileInput = L.Control.extend({
unoKeyCode = handler._toUNOKeyCode(keyCode);
}
- docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
+ if (charCode > 0xFFFF) {
+ // We must handle non-BMP code points as two separate key events
+ // because the sad VCL KeyEvent only takes a 16-bit "characters".
+ var surrogatePair = this._getSurrogatePair(charCode);
+ docLayer._postKeyboardEvent('input', surrogatePair[0], unoKeyCode);
+ docLayer._postKeyboardEvent('up', surrogatePair[0], unoKeyCode);
+ docLayer._postKeyboardEvent('input', surrogatePair[1], unoKeyCode);
+ docLayer._postKeyboardEvent('up', surrogatePair[1], unoKeyCode);
+ }
+ else {
+ docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
+ }
this._lastInput = unoKeyCode;
this._keyHandled = true;
}
else if (e.type === 'keyup') {
- docLayer._postKeyboardEvent('up', charCode, unoKeyCode);
+ if (charCode <= 0xFFFF) {
+ // For non-BMP characters we generated both 'input' and 'up' events
+ // above already.
+ docLayer._postKeyboardEvent('up', charCode, unoKeyCode);
+ }
this._lastInput = null;
this._keyHandled = true;
}
More information about the Libreoffice-commits
mailing list