[Libreoffice-commits] online.git: loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Fri Nov 25 09:13:27 UTC 2016
loleaflet/src/map/Map.js | 4 ++--
loleaflet/src/map/handler/Map.Keyboard.js | 13 +++++++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
New commits:
commit 47699cd9084e4562dd7983f6c4d48cef74b6ba0b
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Nov 25 14:39:13 2016 +0530
tdf#98484: Handle spaces in chrome when IME is enabled
When IME is enabled and user presses the space button, firefox
sends 'compositionend' event with data = ' '. However, chrome
instead fires 'textInput'
event. Lets listen for 'textInput' event too and treat it like
'compositionend' event when data = ' '.
Change-Id: Icbebdf2e89f608f790e6ce68c49f474364e7d5ab
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 75e20fc..40961cb 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -721,7 +721,7 @@ L.Map = L.Evented.extend({
L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
'mouseover mouseout mousemove contextmenu dragover drop ' +
'keydown keypress keyup trplclick qdrplclick', this._handleDOMEvent, this);
- L.DomEvent[onOff](this._textArea, 'copy cut paste keydown keypress keyup compositionend', this._handleDOMEvent, this);
+ L.DomEvent[onOff](this._textArea, 'copy cut paste keydown keypress keyup compositionstart compositionupdate compositionend textInput', this._handleDOMEvent, this);
if (this.options.trackResize && this._resizeDetector.contentWindow) {
L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
@@ -941,7 +941,7 @@ L.Map = L.Evented.extend({
};
if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown' &&
e.type !== 'copy' && e.type !== 'cut' && e.type !== 'paste' &&
- e.type !== 'compositionend') {
+ e.type !== 'compositionstart' && e.type !== 'compositionupdate' && e.type !== 'compositionend' && e.type !== 'textInput') {
data.containerPoint = target instanceof L.Marker ?
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index e7b638e..1a6988b 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -171,13 +171,13 @@ L.Map.Keyboard = L.Handler.extend({
this._map.on('mousedown', this._onMouseDown, this);
this._map.on('keydown keyup keypress', this._onKeyDown, this);
- this._map.on('compositionend', this._onKeyDown, this);
+ this._map.on('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
},
removeHooks: function () {
this._map.off('mousedown', this._onMouseDown, this);
this._map.off('keydown keyup keypress', this._onKeyDown, this);
- this._map.off('compositionend', this._onKeyDown, this);
+ this._map.off('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
},
_setPanOffset: function (pan) {
@@ -285,6 +285,14 @@ 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++) {
@@ -357,6 +365,7 @@ L.Map.Keyboard = L.Handler.extend({
map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
}
}
+
L.DomEvent.stopPropagation(e.originalEvent);
},
More information about the Libreoffice-commits
mailing list