From 71066faff692d8ec04ff870d3786a34ac00649d5 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 24 May 2017 13:38:46 -0700 Subject: [PATCH] Move blockSvg.getHeightWidth to block_render_svg.js (#1118) --- core/block_render_svg.js | 22 ++++++++++++++++++++++ core/block_svg.js | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/block_render_svg.js b/core/block_render_svg.js index adc3ca055..4c3bfb33b 100644 --- a/core/block_render_svg.js +++ b/core/block_render_svg.js @@ -255,6 +255,28 @@ Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR = Blockly.BlockSvg.DISTANCE_45_OUTSIDE) + ',' + (Blockly.BlockSvg.DISTANCE_45_OUTSIDE + 0.5); +/** + * Returns a bounding box describing the dimensions of this block + * and any blocks stacked below it. + * @return {!{height: number, width: number}} Object with height and width + * properties in workspace units. + */ +Blockly.BlockSvg.prototype.getHeightWidth = function() { + var height = this.height; + var width = this.width; + // Recursively add size of subsequent blocks. + var nextBlock = this.getNextBlock(); + if (nextBlock) { + var nextHeightWidth = nextBlock.getHeightWidth(); + height += nextHeightWidth.height - 4; // Height of tab. + width = Math.max(width, nextHeightWidth.width); + } else if (!this.nextConnection && !this.outputConnection) { + // Add a bit of margin under blocks with no bottom tab. + height += 2; + } + return {height: height, width: width}; +}; + /** * Render the block. * Lays out and reflows a block based on its contents and settings. diff --git a/core/block_svg.js b/core/block_svg.js index 82e7d767d..74040ff2f 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -420,28 +420,6 @@ Blockly.BlockSvg.prototype.snapToGrid = function() { } }; -/** - * Returns a bounding box describing the dimensions of this block - * and any blocks stacked below it. - * @return {!{height: number, width: number}} Object with height and width - * properties in workspace units. - */ -Blockly.BlockSvg.prototype.getHeightWidth = function() { - var height = this.height; - var width = this.width; - // Recursively add size of subsequent blocks. - var nextBlock = this.getNextBlock(); - if (nextBlock) { - var nextHeightWidth = nextBlock.getHeightWidth(); - height += nextHeightWidth.height - 4; // Height of tab. - width = Math.max(width, nextHeightWidth.width); - } else if (!this.nextConnection && !this.outputConnection) { - // Add a bit of margin under blocks with no bottom tab. - height += 2; - } - return {height: height, width: width}; -}; - /** * Returns the coordinates of a bounding box describing the dimensions of this * block and any blocks stacked below it.