[Libreoffice-commits] online.git: Branch 'libreoffice-5-3' - loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Fri Mar 3 10:44:45 UTC 2017
loleaflet/src/map/handler/Map.Keyboard.js | 36 ++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 9 deletions(-)
New commits:
commit 9cf293d507309ea489de01d87ae93a92a7ad3c13
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Dec 1 15:07:30 2016 +0530
tdf#98484: Fix double-space in chrome when IME enabled
We regressed on chrome with
47699cd9084e4562dd7983f6c4d48cef74b6ba0b as 'textInput' event
clubbed with 'keypress' event started emitting double-spaces.
Tweak the hack to keep IME working on chrome while not regressing
when it is not enabled.
Change-Id: I0901724bf2db1794078fef3eb7283663b6f6a13b
Reviewed-on: https://gerrit.libreoffice.org/31469
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit 2c7f7e8b699401d0b2c374235c353fdf438aeb0e)
Reviewed-on: https://gerrit.libreoffice.org/31474
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/34797
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 1a6988b..078919f 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -235,6 +235,7 @@ L.Map.Keyboard = L.Handler.extend({
var alt = e.originalEvent.altKey ? this.keyModifier.alt : 0;
var cmd = e.originalEvent.metaKey ? this.keyModifier.ctrl : 0;
var location = e.originalEvent.location;
+ this._keyHandled = this._keyHandled || false;
this.modifier = shift | ctrl | alt | cmd;
// On Windows, pressing AltGr = Alt + Ctrl
@@ -286,13 +287,6 @@ L.Map.Keyboard = L.Handler.extend({
var charCode = e.originalEvent.charCode;
var keyCode = e.originalEvent.keyCode;
- // Hack for making space work in chrome when IME is enabled
- // Chrome doesn't fire compositionend event when IME is enabled and user presses <space>.
- // However, it sends 'textInput' event in such a case. treat it like 'compositionend' events
- if (e.type === 'textInput' && e.originalEvent.data === ' ') {
- e.type = 'compositionend';
- }
-
if (e.type === 'compositionend') {
var compCharCodes = [];
for (var i = 0; i < e.originalEvent.data.length; i++) {
@@ -313,8 +307,13 @@ L.Map.Keyboard = L.Handler.extend({
if (this._map._permission === 'edit') {
docLayer._resetPreFetching();
- if (e.type === 'keydown' && this.handleOnKeyDown[keyCode] && charCode === 0) {
- docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
+ if (e.type === 'keydown') {
+ this._keyHandled = false;
+ this._bufferedTextInputEvent = null;
+
+ if (this.handleOnKeyDown[keyCode] && charCode === 0) {
+ docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
+ }
}
else if ((e.type === 'keypress' || e.type === 'compositionend') &&
(!this.handleOnKeyDown[keyCode] || charCode !== 0)) {
@@ -334,9 +333,28 @@ L.Map.Keyboard = L.Handler.extend({
} else {
docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
}
+
+ this._keyHandled = true;
+ }
+ else if (e.type === 'textInput') {
+ // Store the textInput event
+ this._bufferedTextInputEvent = e;
}
else if (e.type === 'keyup') {
+ // Hack for making space work in chrome when IME is enabled
+ // Chrome doesn't fire compositionend event or keypress when
+ // IME is enabled *and* user presses <space>.
+ // However, it sends 'textInput' event in such a case.
+ // Use the buffered textInput event if its the space key and has not been
+ // handled already by 'keypress' or 'compositionend' events above
+ if (!this._keyHandled && this._bufferedTextInputEvent && e.originalEvent.key === this._bufferedTextInputEvent.originalEvent.data) {
+ charCode = e.originalEvent.keyCode;
+ docLayer._postKeyboardEvent('input', charCode, 0);
+ }
docLayer._postKeyboardEvent('up', charCode, unoKeyCode);
+
+ this._keyHandled = true;
+ this._bufferedTextInputEvent = null;
}
if (keyCode === 9) {
// tab would change focus to other DOM elements
More information about the Libreoffice-commits
mailing list