Make updating the connection locations called the same way for both renderers

This commit is contained in:
Rachel Fenichel
2019-07-30 13:58:44 -07:00
parent bc49bf849c
commit bcdd691796
3 changed files with 37 additions and 39 deletions

View File

@@ -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

View File

@@ -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_();
}
}
};

View File

@@ -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_();
};