fix: switch most remaining render calls to queueRender (#7024)

* chore: remove render call from procedure blocks

* chore: have workspace queue renders when unhiding

* chore: remove forced rendering from flyouts

* chore: change mutators to use queueing

* chore: change shadows to use queueing

* chore: add comments about icon rendering
This commit is contained in:
Beka Westberg
2023-05-09 16:57:11 -07:00
committed by GitHub
parent 39cdd8a67a
commit af991f5e1b
7 changed files with 9 additions and 18 deletions

View File

@@ -756,9 +756,6 @@ const PROCEDURE_CALL_COMMON = {
this.quarkConnections_ = {};
this.quarkIds_ = [];
}
// Switch off rendering while the block is rebuilt.
const savedRendered = this.rendered;
this.rendered = false;
// Update the quarkConnections_ with existing connections.
for (let i = 0; i < this.arguments_.length; i++) {
const input = this.getInput('ARG' + i);
@@ -798,11 +795,6 @@ const PROCEDURE_CALL_COMMON = {
}
}
}
// Restore rendering and show the changes.
this.rendered = savedRendered;
if (this.rendered) {
this.render();
}
},
/**
* Modify this block to have the correct number of arguments.

View File

@@ -1000,6 +1000,8 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
this.comment = null; // For backwards compatibility.
}
if (this.rendered) {
// Icons must force an immediate render so that bubbles can be opened
// immedately at the correct position.
this.render();
// Adding or removing a comment icon will cause the block to change shape.
this.bumpNeighbours();
@@ -1078,6 +1080,8 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
}
}
if (changedState && this.rendered) {
// Icons must force an immediate render so that bubbles can be opened
// immedately at the correct position.
this.render();
// Adding or removing a warning icon will cause the block to change shape.
this.bumpNeighbours();
@@ -1099,6 +1103,8 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
mutator.createIcon();
}
if (this.rendered) {
// Icons must force an immediate render so that bubbles can be opened
// immedately at the correct position.
this.render();
// Adding or removing a mutator icon will cause the block to change shape.
this.bumpNeighbours();

View File

@@ -244,7 +244,6 @@ export class HorizontalFlyout extends Flyout {
// a block.
child.isInFlyout = true;
}
block!.render();
const root = block!.getSvgRoot();
const blockHW = block!.getHeightWidth();
// Figure out where to place the block.

View File

@@ -225,7 +225,6 @@ export class VerticalFlyout extends Flyout {
// a block.
child.isInFlyout = true;
}
block!.render();
const root = block!.getSvgRoot();
const blockHW = block!.getHeightWidth();
const moveX =

View File

@@ -335,7 +335,7 @@ export class Mutator extends Icon {
this.rootBlock = block.decompose!(ws)!;
const blocks = this.rootBlock.getDescendants(false);
for (let i = 0, child; child = blocks[i]; i++) {
child.render();
child.queueRender();
}
// The root block should not be draggable or deletable.
this.rootBlock.setMovable(false);

View File

@@ -514,12 +514,7 @@ export class RenderedConnection extends Connection {
return;
}
blockShadow.initSvg();
blockShadow.render(false);
const parentBlock = this.getSourceBlock();
if (parentBlock.rendered) {
parentBlock.queueRender();
}
blockShadow.queueRender();
}
/**

View File

@@ -1301,7 +1301,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
const blocks = this.getAllBlocks(false);
// Render each block.
for (let i = blocks.length - 1; i >= 0; i--) {
blocks[i].render(false);
blocks[i].queueRender();
}
if (this.currentGesture_) {