From 7118dd3e4fb0e0ec23823b4e832b01e0bb948a70 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 27 Jul 2023 16:08:45 -0700 Subject: [PATCH] chore: remove old render management system (#7308) --- core/block_svg.ts | 44 +++++++------------------------------------ core/workspace_svg.ts | 23 ++++++++++------------ 2 files changed, 17 insertions(+), 50 deletions(-) diff --git a/core/block_svg.ts b/core/block_svg.ts index ebcf2bb25..e4053de0a 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -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. + * @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(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; - } + render() { + deprecation.warn('Blockly.BlockSvg.prototype.render', 'v10', 'v11'); + this.queueRender(); + renderManagement.triggerQueuedRenders(); } /** diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 86bfec5ea..01888e55f 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -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; @@ -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.