Skip to content

Commit

Permalink
chore: remove old render management system
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Jul 19, 2023
1 parent 8f5b8e1 commit 1d8425c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 51 deletions.
46 changes: 8 additions & 38 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1549,44 +1549,14 @@ export class BlockSvg
* Immediately lays out and reflows a block based on its contents and
* settings.
*
* @param opt_bubble If false, just render this block.
* If true, also render block's parent, grandparent, etc. Defaults to true.
*/
render(opt_bubble?: boolean) {
if (this.renderIsInProgress_) {
return; // Don't allow recursive renders.
}
this.renderIsInProgress_ = true;
try {
this.rendered = true;
dom.startTextWidthCache();

if (!this.isEnabled()) {
// Apply disabled styles if needed.
this.updateDisabled();
}

if (this.isCollapsed()) {
this.updateCollapsed_();
}
this.workspace.getRenderer().render(this);
this.updateConnectionAndIconLocations();

if (opt_bubble !== false) {
const parentBlock = this.getParent();
if (parentBlock) {
parentBlock.render(true);
} else {
// Top-most block. Fire an event to allow scrollbars to resize.
this.workspace.resizeContents();
}
}

dom.stopTextWidthCache();
this.updateMarkers_();
} finally {
this.renderIsInProgress_ = false;
}
* @deprecated Renders are triggered automatically when the block is modified
* (e.g. fields are modified or inputs are added). Any calls to render()
* are no longer necessary. To be removed in v11.
*/
render() {
deprecation.warn('Blockly.BlockSvg.prototype.render', 'v10', 'v11');
this.queueRender();
renderManagement.triggerQueuedRenders();
}

/**
Expand Down
23 changes: 10 additions & 13 deletions core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import * as Xml from './xml.js';
import {ZoomControls} from './zoom_controls.js';
import {ContextMenuOption} from './contextmenu_registry.js';
import * as renderManagement from './render_management.js';
import * as deprecation from './utils/deprecation.js';

/** Margin around the top/bottom/left/right after a zoomToFit call. */
const ZOOM_TO_FIT_MARGIN = 20;
Expand Down Expand Up @@ -1224,24 +1225,20 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
// Currently does not support toolboxes in mutators.
this.toolbox_.setVisible(isVisible);
}
if (isVisible) {
const blocks = this.getAllBlocks(false);
// Tell each block on the workspace to mark its fields as dirty.
for (let i = blocks.length - 1; i >= 0; i--) {
blocks[i].markDirty();
}

this.render();
if (this.toolbox_) {
this.toolbox_.position();
}
} else {
if (!isVisible) {
this.hideChaff(true);
}
}

/** Render all blocks in workspace. */
/**
* Render all blocks in workspace.
*
* @deprecated Renders are triggered automatically when the block is modified
* (e.g. fields are modified or inputs are added). Any calls to render()
* are no longer necessary. To be removed in v11.
*/
render() {
deprecation.warn('Blockly.WorkspaceSvg.prototype.render', 'v10', 'v11');
// Generate list of all blocks.
const blocks = this.getAllBlocks(false);
// Render each block.
Expand Down

0 comments on commit 1d8425c

Please sign in to comment.