From 8854340908459eb4593ac605b5eb0d27d3d57572 Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 14 Jun 2021 11:56:02 -0700 Subject: [PATCH 1/3] Update positionable jsdoc --- core/interfaces/i_positionable.js | 3 ++- core/trashcan.js | 3 ++- core/zoom_controls.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/interfaces/i_positionable.js b/core/interfaces/i_positionable.js index 89f4c8094c6..356510c816d 100644 --- a/core/interfaces/i_positionable.js +++ b/core/interfaces/i_positionable.js @@ -37,6 +37,7 @@ Blockly.IPositionable.prototype.position; /** * Returns the bounding rectangle of the UI element in pixel units relative to * the Blockly injection div. - * @return {!Blockly.utils.Rect} The UI elements’s bounding box. + * @return {?Blockly.utils.Rect} The UI elements’s bounding box. Null if + * bounding box should be ignored by other UI elements. */ Blockly.IPositionable.prototype.getBoundingRectangle; diff --git a/core/trashcan.js b/core/trashcan.js index 968ee916c1d..f6ad48ba469 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -506,7 +506,8 @@ Blockly.Trashcan.prototype.position = function(metrics, savedPositions) { /** * Returns the bounding rectangle of the UI element in pixel units relative to * the Blockly injection div. - * @return {!Blockly.utils.Rect} The UI elements’s bounding box. + * @return {?Blockly.utils.Rect} The UI elements’s bounding box. Null if + * bounding box should be ignored by other UI elements. */ Blockly.Trashcan.prototype.getBoundingRectangle = function() { var bottom = this.top_ + this.BODY_HEIGHT_ + this.LID_HEIGHT_; diff --git a/core/zoom_controls.js b/core/zoom_controls.js index b86111a3bb8..07c63e90407 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -228,7 +228,8 @@ Blockly.ZoomControls.prototype.dispose = function() { /** * Returns the bounding rectangle of the UI element in pixel units relative to * the Blockly injection div. - * @return {!Blockly.utils.Rect} The UI elements’s bounding box. + * @return {?Blockly.utils.Rect} The UI elements’s bounding box. Null if + * bounding box should be ignored by other UI elements. */ Blockly.ZoomControls.prototype.getBoundingRectangle = function() { var height = this.SMALL_SPACING_ + 2 * this.HEIGHT_; From 225e743d0980fd65f52b4d526602d12c6f29dc2c Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 14 Jun 2021 12:09:18 -0700 Subject: [PATCH 2/3] Add check for clientRect --- core/workspace_svg.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/workspace_svg.js b/core/workspace_svg.js index ea06193bcea..a2d4b271cea 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1148,7 +1148,10 @@ Blockly.WorkspaceSvg.prototype.resize = function() { var savedPositions = []; for (var i = 0, positionable; (positionable = positionables[i]); i++) { positionable.position(metrics, savedPositions); - savedPositions.push(positionable.getBoundingRectangle()); + var clientRect = positionable.getBoundingRectangle(); + if (clientRect) { + savedPositions.push(clientRect); + } } if (this.scrollbar) { From 58b09b05a31bc7f5945806a2369f19348c309456 Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 14 Jun 2021 12:23:42 -0700 Subject: [PATCH 3/3] update variable name to boundingRect --- core/workspace_svg.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/workspace_svg.js b/core/workspace_svg.js index a2d4b271cea..95618dbefd6 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1148,9 +1148,9 @@ Blockly.WorkspaceSvg.prototype.resize = function() { var savedPositions = []; for (var i = 0, positionable; (positionable = positionables[i]); i++) { positionable.position(metrics, savedPositions); - var clientRect = positionable.getBoundingRectangle(); - if (clientRect) { - savedPositions.push(clientRect); + var boundingRect = positionable.getBoundingRectangle(); + if (boundingRect) { + savedPositions.push(boundingRect); } }