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
libreoffice-5-3
Pranav Kant 2016-11-25 14:39:13 +05:30
parent e9dbfa3953
commit 47699cd908
2 changed files with 13 additions and 4 deletions

View File

@ -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);

View File

@ -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);
},