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

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 6 16:56:22 UTC 2020


 loleaflet/src/geometry/Bounds.js |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

New commits:
commit abe2a81e1f397e63f3e86d59015bf51be3629ae5
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Fri Jun 5 16:55:18 2020 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Mon Jul 6 18:56:04 2020 +0200

    introduce clone(), add(), _add() members to L.Bounds
    
    like we have for L.Point.
    
    Change-Id: Ic7d1bf7d41f8d3e2cec2dab05ba0742342840775
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98147
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>

diff --git a/loleaflet/src/geometry/Bounds.js b/loleaflet/src/geometry/Bounds.js
index 212089d86..b671c0ad5 100644
--- a/loleaflet/src/geometry/Bounds.js
+++ b/loleaflet/src/geometry/Bounds.js
@@ -30,6 +30,10 @@ L.Bounds.prototype = {
 		return this;
 	},
 
+	clone: function () { // -> Bounds
+		return new L.Bounds(this.min, this.max);
+	},
+
 	getCenter: function (round) { // (Boolean) -> Point
 		return new L.Point(
 		        (this.min.x + this.max.x) / 2,
@@ -91,6 +95,18 @@ L.Bounds.prototype = {
 		return xIntersects && yIntersects;
 	},
 
+	// non-destructive, returns a new Bounds
+	add: function (point) { // (Point) -> Bounds
+		return this.clone()._add(point);
+	},
+
+	// destructive, used directly for performance in situations where it's safe to modify existing Bounds
+	_add: function (point) { // (Point) -> Bounds
+		this.min._add(point);
+		this.max._add(point);
+		return this;
+	},
+
 	toString: function () {
 		return '[' +
 		        this.min.toString() + ', ' +


More information about the Libreoffice-commits mailing list