mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
fix: bump neighbours performance regression (#7748)
* fix: move bumping neighbours to the end of rendering * chore: remove scheduleSnapAndBump * chore: remove references to bumpNeighbours * chore: work on fixing tests * fix: bump neighbours event grouping * chore: format * chore: readd deprecation import * fix: move event ordering * chore: undeprecate bumpNeighbours * fix: bumping during drag due to insertion markers * chore: tests * chore: PR feedback * chore: docs * chore: typo
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import {BlockSvg} from './block_svg.js';
|
||||
import * as userAgent from './utils/useragent.js';
|
||||
import * as eventUtils from './events/utils.js';
|
||||
|
||||
/** The set of all blocks in need of rendering which don't have parents. */
|
||||
const rootBlocks = new Set<BlockSvg>();
|
||||
@@ -13,6 +14,9 @@ const rootBlocks = new Set<BlockSvg>();
|
||||
/** The set of all blocks in need of rendering. */
|
||||
let dirtyBlocks = new WeakSet<BlockSvg>();
|
||||
|
||||
/** A map from queued blocks to the event group from when they were queued. */
|
||||
let eventGroups = new WeakMap<BlockSvg, string>();
|
||||
|
||||
/**
|
||||
* The promise which resolves after the current set of renders is completed. Or
|
||||
* null if there are no queued renders.
|
||||
@@ -100,6 +104,7 @@ function alwaysImmediatelyRender() {
|
||||
*/
|
||||
function queueBlock(block: BlockSvg) {
|
||||
dirtyBlocks.add(block);
|
||||
eventGroups.set(block, eventUtils.getGroup());
|
||||
const parent = block.getParent();
|
||||
if (parent) {
|
||||
queueBlock(parent);
|
||||
@@ -124,9 +129,19 @@ function doRenders() {
|
||||
const blockOrigin = block.getRelativeToSurfaceXY();
|
||||
block.updateComponentLocations(blockOrigin);
|
||||
}
|
||||
for (const block of blocks) {
|
||||
const oldGroup = eventUtils.getGroup();
|
||||
const newGroup = eventGroups.get(block);
|
||||
if (newGroup) eventUtils.setGroup(newGroup);
|
||||
|
||||
block.bumpNeighbours();
|
||||
|
||||
eventUtils.setGroup(oldGroup);
|
||||
}
|
||||
|
||||
rootBlocks.clear();
|
||||
dirtyBlocks = new Set();
|
||||
dirtyBlocks = new WeakSet();
|
||||
eventGroups = new WeakMap();
|
||||
afterRendersPromise = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user