From bcdd691796b01a396bd176f073833a951ab4fb2f Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 30 Jul 2019 13:58:44 -0700 Subject: [PATCH] Make updating the connection locations called the same way for both renderers --- core/block_render_svg.js | 36 ------------------ core/block_svg.js | 37 +++++++++++++++++++ .../block_rendering.js | 3 -- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/core/block_render_svg.js b/core/block_render_svg.js index 8b6ac81fb..13d9a6fb5 100644 --- a/core/block_render_svg.js +++ b/core/block_render_svg.js @@ -333,7 +333,6 @@ Blockly.BlockSvg.prototype.renderInternal = function() { var inputRows = this.renderCompute_(cursorX); this.renderDraw_(cursorX, inputRows); - this.renderMoveConnections_(); }; /** @@ -615,41 +614,6 @@ Blockly.BlockSvg.prototype.setPaths_ = function(pathObject) { } }; -/** - * Update all of the connections on this block with the new locations calculated - * in renderCompute. Also move all of the connected blocks based on the new - * connection locations. - * @private - */ -Blockly.BlockSvg.prototype.renderMoveConnections_ = function() { - var blockTL = this.getRelativeToSurfaceXY(); - // Don't tighten previous or output connections because they are inferior - // connections. - if (this.previousConnection) { - this.previousConnection.moveToOffset(blockTL); - } - if (this.outputConnection) { - this.outputConnection.moveToOffset(blockTL); - } - - for (var i = 0; i < this.inputList.length; i++) { - var conn = this.inputList[i].connection; - if (conn) { - conn.moveToOffset(blockTL); - if (conn.isConnected()) { - conn.tighten_(); - } - } - } - - if (this.nextConnection) { - this.nextConnection.moveToOffset(blockTL); - if (this.nextConnection.isConnected()) { - this.nextConnection.tighten_(); - } - } -}; - /** * Render the top edge of the block. * @param {!Blockly.BlockSvg.PathObject} pathObject The object containing diff --git a/core/block_svg.js b/core/block_svg.js index cbb9891e7..f2674f507 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -1547,6 +1547,8 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) { } else { this.renderInternal(); } + // No matter how we rendered, connections locations should now be correct. + this.updateConnectionLocations_(); if (opt_bubble !== false) { // Render all blocks above this one (propagate a reflow). var parentBlock = this.getParent(); @@ -1559,3 +1561,38 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) { } Blockly.Field.stopCache(); }; + +/** + * Update all of the connections on this block with the new locations calculated + * during rendering. Also move all of the connected blocks based on the new + * connection locations. + * @private + */ +Blockly.BlockSvg.prototype.updateConnectionLocations_ = function() { + var blockTL = this.getRelativeToSurfaceXY(); + // Don't tighten previous or output connections because they are inferior + // connections. + if (this.previousConnection) { + this.previousConnection.moveToOffset(blockTL); + } + if (this.outputConnection) { + this.outputConnection.moveToOffset(blockTL); + } + + for (var i = 0; i < this.inputList.length; i++) { + var conn = this.inputList[i].connection; + if (conn) { + conn.moveToOffset(blockTL); + if (conn.isConnected()) { + conn.tighten_(); + } + } + } + + if (this.nextConnection) { + this.nextConnection.moveToOffset(blockTL); + if (this.nextConnection.isConnected()) { + this.nextConnection.tighten_(); + } + } +}; diff --git a/core/renderers/block_rendering_rewrite/block_rendering.js b/core/renderers/block_rendering_rewrite/block_rendering.js index 8a967b37b..705d7d16f 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering.js +++ b/core/renderers/block_rendering_rewrite/block_rendering.js @@ -47,7 +47,4 @@ Blockly.blockRendering.render = function(block) { } var info = new Blockly.blockRendering.RenderInfo(block); new Blockly.blockRendering.Drawer(block, info).draw_(); - - // TODO: Fix moving connections in the new rendering code. - block.renderMoveConnections_(); };