[Libreoffice-commits] online.git: loleaflet/src
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 20 10:45:43 UTC 2020
loleaflet/src/control/Ruler.js | 54 +++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 21 deletions(-)
New commits:
commit ad19d910caf70eacd547172a06d105d2410ef633
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Apr 20 09:59:34 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Apr 20 12:45:22 2020 +0200
ruler: make sure touch and mouse events don't cause an error
We need to make sure we don't accidentally get into either a
touch or mouse event codepath, which would cause an error as the
events and cases differe a bit. For example touch event has no
'button' member, which means a touch 'panstart' event would be
ignored in every case, which would then cause an error in
'panmove' and 'panend' because some variable wouldn't be set.
Change-Id: I08e4850b735f753639f7001b736c2883cf2d683f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92550
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js
index e4251fd4d..7d41d7e66 100644
--- a/loleaflet/src/control/Ruler.js
+++ b/loleaflet/src/control/Ruler.js
@@ -406,27 +406,30 @@ L.Control.Ruler = L.Control.extend({
tabstopContainer = event.currentTarget;
pointX = event.layerX;
}
-
- if (event.button === 2) {
- this.currentPositionInTwips = this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
-
- $.contextMenu({
- selector: '.loleaflet-ruler-tabstopcontainer',
- className: 'loleaflet-font',
- items: {
- inserttabstop: {
- name: _('Insert tabstop'),
- callback: (this._insertTabstop).bind(this)
+ tabstopContainer.tabStopMarkerBeingDragged = null;
+
+ // Check what to do when a mouse buttons is clicked, ignore touch
+ if (event.type !== 'panstart') {
+ // right-click inside tabstop container
+ if (event.button === 2) {
+ this.currentPositionInTwips = this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
+ $.contextMenu({
+ selector: '.loleaflet-ruler-tabstopcontainer',
+ className: 'loleaflet-font',
+ items: {
+ inserttabstop: {
+ name: _('Insert tabstop'),
+ callback: (this._insertTabstop).bind(this)
+ }
}
- }
- });
-
- event.stopPropagation();
- return;
- }
- else if (event.button !== 0) {
- event.stopPropagation(); // prevent handling of the mother event elsewhere
- return;
+ });
+ event.stopPropagation();
+ return;
+ }
+ else if (event.button !== 0) {
+ event.stopPropagation(); // prevent handling of the mother event elsewhere
+ return;
+ }
}
// check if we hit any tabstop
@@ -473,10 +476,15 @@ L.Control.Ruler = L.Control.extend({
pointX = event.layerX;
}
+ if (tabstopContainer === null)
+ return;
+ var marker = tabstopContainer.tabStopMarkerBeingDragged;
+ if (marker === null)
+ return;
+
//console.log('===> _moveTabstop ' + event.type);
var pixelDiff = pointX - tabstopContainer.tabStopInitialPosiiton;
- var marker = tabstopContainer.tabStopMarkerBeingDragged;
marker.style.left = (marker.tabStopLocation.left + pixelDiff) + 'px';
},
@@ -494,7 +502,11 @@ L.Control.Ruler = L.Control.extend({
pointX = event.layerX;
}
+ if (tabstopContainer === null)
+ return;
var marker = tabstopContainer.tabStopMarkerBeingDragged;
+ if (marker === null)
+ return;
if (event.type == 'mouseout') {
marker.style.left = (marker.tabStopLocation.left) + 'px';
More information about the Libreoffice-commits
mailing list