mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Revert "Propagate the visible state when blocks connect (#2003)"
This reverts commit ec78eeb39b.
This commit is contained in:
committed by
Rachel Fenichel
parent
a002621ec2
commit
060c2b34df
@@ -317,10 +317,6 @@ Blockly.BlockSvg.prototype.getHeightWidth = function() {
|
||||
* If true, also render block's parent, grandparent, etc. Defaults to true.
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.render = function(opt_bubble) {
|
||||
if (!this.workspace) {
|
||||
// This block is being deleted so don't try to render it.
|
||||
return;
|
||||
}
|
||||
Blockly.Field.startCache();
|
||||
this.rendered = true;
|
||||
|
||||
|
||||
@@ -444,10 +444,6 @@ Blockly.Connection.prototype.connect = function(otherConnection) {
|
||||
return;
|
||||
}
|
||||
this.checkConnection_(otherConnection);
|
||||
var eventGroup = Blockly.Events.getGroup();
|
||||
if (!eventGroup) {
|
||||
Blockly.Events.setGroup(true);
|
||||
}
|
||||
// Determine which block is superior (higher in the source stack).
|
||||
if (this.isSuperior()) {
|
||||
// Superior block.
|
||||
@@ -456,9 +452,6 @@ Blockly.Connection.prototype.connect = function(otherConnection) {
|
||||
// Inferior block.
|
||||
otherConnection.connect_(this);
|
||||
}
|
||||
if (!eventGroup) {
|
||||
Blockly.Events.setGroup(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -548,16 +541,8 @@ Blockly.Connection.prototype.disconnect = function() {
|
||||
childBlock = this.sourceBlock_;
|
||||
parentConnection = otherConnection;
|
||||
}
|
||||
|
||||
var eventGroup = Blockly.Events.getGroup();
|
||||
if (!eventGroup) {
|
||||
Blockly.Events.setGroup(true);
|
||||
}
|
||||
this.disconnectInternal_(parentBlock, childBlock);
|
||||
parentConnection.respawnShadow_();
|
||||
if (!eventGroup) {
|
||||
Blockly.Events.setGroup(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -226,7 +226,6 @@ Blockly.RenderedConnection.prototype.highlight = function() {
|
||||
* attached to this connection. This happens when a block is expanded.
|
||||
* Also unhides down-stream comments.
|
||||
* @return {!Array.<!Blockly.Block>} List of blocks to render.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.RenderedConnection.prototype.unhideAll = function() {
|
||||
this.setHidden(false);
|
||||
@@ -274,7 +273,6 @@ Blockly.RenderedConnection.prototype.unhighlight = function() {
|
||||
/**
|
||||
* Set whether this connections is hidden (not tracked in a database) or not.
|
||||
* @param {boolean} hidden True if connection is hidden.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.RenderedConnection.prototype.setHidden = function(hidden) {
|
||||
this.hidden_ = hidden;
|
||||
@@ -289,7 +287,6 @@ Blockly.RenderedConnection.prototype.setHidden = function(hidden) {
|
||||
* Hide this connection, as well as all down-stream connections on any block
|
||||
* attached to this connection. This happens when a block is collapsed.
|
||||
* Also hides down-stream comments.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.RenderedConnection.prototype.hideAll = function() {
|
||||
this.setHidden(true);
|
||||
@@ -328,49 +325,6 @@ Blockly.RenderedConnection.prototype.isConnectionAllowed = function(candidate,
|
||||
candidate);
|
||||
};
|
||||
|
||||
/**
|
||||
* Connect this connection to another connection.
|
||||
* @param {!Blockly.Connection} otherConnection Connection to connect to.
|
||||
* @override
|
||||
*/
|
||||
Blockly.RenderedConnection.prototype.connect = function(otherConnection) {
|
||||
Blockly.RenderedConnection.superClass_.connect.call(this, otherConnection);
|
||||
|
||||
// This is a quick check to make sure we aren't doing unecessary work.
|
||||
if (this.hidden_ || otherConnection.hidden_) {
|
||||
var superiorConnection = this.isSuperior() ? this : otherConnection;
|
||||
if (superiorConnection.hidden_) {
|
||||
superiorConnection.hideAll();
|
||||
} else {
|
||||
superiorConnection.unhideAll();
|
||||
}
|
||||
|
||||
var renderedBlock = superiorConnection.targetBlock();
|
||||
var display = superiorConnection.hidden_ ? 'none' : 'block';
|
||||
renderedBlock.getSvgRoot().style.display = display;
|
||||
renderedBlock.rendered = !superiorConnection.hidden_;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Disconnect this connection.
|
||||
* @override
|
||||
*/
|
||||
Blockly.RenderedConnection.prototype.disconnect = function() {
|
||||
var superiorConnection = this.isSuperior() ? this : this.targetConnection;
|
||||
if (this.targetConnection && superiorConnection.hidden_) {
|
||||
superiorConnection.unhideAll();
|
||||
var renderedBlock = superiorConnection.targetBlock();
|
||||
renderedBlock.getSvgRoot().style.display = 'block';
|
||||
renderedBlock.rendered = true;
|
||||
|
||||
// Set the hidden state for the connection back to true so shadow blocks
|
||||
// will be hidden.
|
||||
superiorConnection.setHidden(true);
|
||||
}
|
||||
Blockly.RenderedConnection.superClass_.disconnect.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Disconnect two blocks that are connected by this connection.
|
||||
* @param {!Blockly.Block} parentBlock The superior block.
|
||||
@@ -408,7 +362,7 @@ Blockly.RenderedConnection.prototype.respawnShadow_ = function() {
|
||||
}
|
||||
blockShadow.initSvg();
|
||||
blockShadow.render(false);
|
||||
if (parentBlock.rendered && !this.hidden_) {
|
||||
if (parentBlock.rendered) {
|
||||
parentBlock.render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
suite('Connections', function() {
|
||||
|
||||
suite('Rendered', function() {
|
||||
suite.skip('Rendered', function() {
|
||||
function assertAllConnectionsHiddenState(block, hidden) {
|
||||
var connections = block.getConnections_(true);
|
||||
for (var i = 0; i < connections.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user