[Libreoffice-commits] online.git: loleaflet/src
Dennis Francis (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 8 15:06:20 UTC 2020
loleaflet/src/geo/LatLngBounds.js | 15 +++++++++-
loleaflet/src/layer/tile/CalcTileLayer.js | 26 ++---------------
loleaflet/src/layer/tile/TileLayer.js | 44 ++++++++++++++++++++++--------
3 files changed, 51 insertions(+), 34 deletions(-)
New commits:
commit 732e440018011491ddf34113335f6f0b979e8237
Author: Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Tue Jul 7 21:52:27 2020 +0530
Commit: Dennis Francis <dennis.francis at collabora.com>
CommitDate: Wed Jul 8 17:06:01 2020 +0200
make _onUpdateCursor work correctly for split-panes
Change-Id: Ib81a4530a48686fb2e2e31aee9941aab654f0868
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98359
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Tested-by: Jenkins
Reviewed-by: Dennis Francis <dennis.francis at collabora.com>
diff --git a/loleaflet/src/geo/LatLngBounds.js b/loleaflet/src/geo/LatLngBounds.js
index 80e059750..1241da361 100644
--- a/loleaflet/src/geo/LatLngBounds.js
+++ b/loleaflet/src/geo/LatLngBounds.js
@@ -189,7 +189,20 @@ L.LatLngBounds.prototype = {
isValid: function () {
return !!(this._southWest && this._northEast);
- }
+ },
+
+ isInAny: function (latLngBoundsArray) {
+ console.assert(Array.isArray(latLngBoundsArray), 'invalid argument type');
+
+ for (var i = 0; i < latLngBoundsArray.length; ++i) {
+ if (latLngBoundsArray[i].contains(this)) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
};
L.LatLngBounds.createDefault = function() {
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 70fbe3dd0..1dfd7811c 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -931,7 +931,7 @@ L.CalcTileLayer = L.TileLayer.extend({
return this._twipsToPixels(this._cellCursorTwips.getTopLeft());
},
- _calculateScrollForNewCursor: function () {
+ _calculateScrollForNewCellCursor: function () {
var scroll = new L.LatLng(0, 0);
@@ -940,28 +940,10 @@ L.CalcTileLayer = L.TileLayer.extend({
}
var map = this._map;
- var paneRects = this._splitPanesContext ?
- this._splitPanesContext.getPxBoundList() : undefined;
-
- console.assert(paneRects === undefined || paneRects.length, 'number of panes cannot be zero!');
-
- var paneRectsInLatLng = paneRects ? paneRects.map(function (pxBound) {
- return new L.LatLngBounds(
- map.unproject(pxBound.getTopLeft()),
- map.unproject(pxBound.getBottomRight())
- );
- }) : [ map.getBounds() ];
-
- var scrollNeeded = true;
- for (var i = 0; i < paneRectsInLatLng.length; ++i) {
- if (paneRectsInLatLng[i].contains(this._cellCursor)) {
- scrollNeeded = false;
- break;
- }
- }
+ var paneRectsInLatLng = this.getPaneLatLngRectangles();
- if (!scrollNeeded) {
- return scroll; // zero scroll.
+ if (this._cellCursor.isInAny(paneRectsInLatLng)) {
+ return scroll; // no scroll needed.
}
var freePaneBounds = paneRectsInLatLng[paneRectsInLatLng.length - 1];
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index e5f73a10c..438476c26 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2250,18 +2250,22 @@ L.TileLayer = L.GridLayer.extend({
if (!zoom
&& scroll !== false
- && !this._map.getBounds().contains(this._visibleCursor)
&& this._map._isCursorVisible
&& (!this._map._clip || this._map._clip._selectionType !== 'complex')) {
- var center = this._map.project(cursorPos);
- center = center.subtract(this._map.getSize().divideBy(2));
- center.x = Math.round(center.x < 0 ? 0 : center.x);
- center.y = Math.round(center.y < 0 ? 0 : center.y);
- if (!(this._selectionHandles.start && this._selectionHandles.start.isDragged) &&
- !(this._selectionHandles.end && this._selectionHandles.end.isDragged) &&
- !(docLayer._followEditor || docLayer._followUser)) {
- this._map.fire('scrollto', {x: center.x, y: center.y, calledFromInvalidateCursorMsg: scroll !== undefined});
+ var paneRectsInLatLng = this.getPaneLatLngRectangles();
+
+ if (!this._visibleCursor.isInAny(paneRectsInLatLng)) {
+ var center = this._map.project(cursorPos);
+ center = center.subtract(this._map.getSize().divideBy(2));
+ center.x = Math.round(center.x < 0 ? 0 : center.x);
+ center.y = Math.round(center.y < 0 ? 0 : center.y);
+
+ if (!(this._selectionHandles.start && this._selectionHandles.start.isDragged) &&
+ !(this._selectionHandles.end && this._selectionHandles.end.isDragged) &&
+ !(docLayer._followEditor || docLayer._followUser)) {
+ this._map.fire('scrollto', {x: center.x, y: center.y, calledFromInvalidateCursorMsg: scroll !== undefined});
+ }
}
}
@@ -2963,8 +2967,8 @@ L.TileLayer = L.GridLayer.extend({
}
var mapBounds = this._map.getBounds();
if (!this._cellCursorXY.equals(this._prevCellCursorXY)) {
- var scroll = this._calculateScrollForNewCursor();
- console.assert(scroll instanceof L.LatLng, '_calculateScrollForNewCursor returned wrong type');
+ var scroll = this._calculateScrollForNewCellCursor();
+ console.assert(scroll instanceof L.LatLng, '_calculateScrollForNewCellCursor returned wrong type');
if (scroll.lng !== 0 || scroll.lat !== 0) {
var newCenter = mapBounds.getCenter();
newCenter.lng += scroll.lng;
@@ -3422,6 +3426,24 @@ L.TileLayer = L.GridLayer.extend({
return new L.Point(0, 0);
},
+ getPaneLatLngRectangles: function () {
+ var map = this._map;
+
+ if (!this._splitPanesContext) {
+ return [ map.getBounds() ];
+ }
+
+ var paneRects = this._splitPanesContext.getPxBoundList();
+ console.assert(paneRects.length, 'number of panes cannot be zero!');
+
+ return paneRects.map(function (pxBound) {
+ return new L.LatLngBounds(
+ map.unproject(pxBound.getTopLeft()),
+ map.unproject(pxBound.getBottomRight())
+ );
+ });
+ },
+
_debugGetTimeArray: function() {
return {count: 0, ms: 0, best: Number.MAX_SAFE_INTEGER, worst: 0, date: 0};
},
More information about the Libreoffice-commits
mailing list