[Libreoffice-commits] online.git: loleaflet/src

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 5 07:57:47 UTC 2020


 loleaflet/src/layer/tile/CalcTileLayer.js |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 1744ae64156c08746c413f23d8c8a87163a6ae58
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Thu May 14 23:11:07 2020 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Sun Jul 5 09:57:28 2020 +0200

    Round down when computing row/col index from tile-twips position
    
    And lets not unnecessarily extend the cellrange in the view as the
    computation is accurate.
    
    Change-Id: I62de80ce42430c62a399d4e39bafab7896217bf1
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97943
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>

diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 974c1daae..6ed8ae4b4 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -975,6 +975,7 @@ L.SheetDimension = L.Class.extend({
 		});
 	},
 
+	// computes element index from tile-twips position.
 	_getIndexFromTileTwipsPos: function (pos) {
 		var span = this._visibleSizes.getSpanDataByCustomDataField(pos, 'postiletwips');
 		var elementCount = span.end - span.start + 1;
@@ -982,16 +983,17 @@ L.SheetDimension = L.Class.extend({
 			this._devPixelsPerCssPixel * this._twipsPerCSSPixel);
 		var posEnd = span.data.postiletwips;
 		var sizeOne = (posEnd - posStart) / elementCount;
-		var relativeIndex = Math.round((pos - posStart) / sizeOne);
+
+		// always round down as relativeIndex is zero-based.
+		var relativeIndex = Math.floor((pos - posStart) / sizeOne);
 
 		return span.start + relativeIndex;
 	},
 
 	setViewLimits: function (startPosTileTwips, endPosTileTwips) {
 
-		// Extend the range a bit, to compensate for rounding errors.
-		this._viewStartIndex = Math.max(0, this._getIndexFromTileTwipsPos(startPosTileTwips) - 2);
-		this._viewEndIndex = Math.min(this._maxIndex, this._getIndexFromTileTwipsPos(endPosTileTwips) + 2);
+		this._viewStartIndex = Math.max(0, this._getIndexFromTileTwipsPos(startPosTileTwips));
+		this._viewEndIndex = Math.min(this._maxIndex, this._getIndexFromTileTwipsPos(endPosTileTwips));
 	},
 
 	getViewElementRange: function () {


More information about the Libreoffice-commits mailing list