From 075bda45a5db812e607649f2ee4cbfd141eb8a3d Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 13 Oct 2017 17:08:52 -0400 Subject: [PATCH] Block rendering performance (#1363) * Use Blockly.Field.getCachedWidth instead of non-caching method * Check for timeout pid before calling clearTimeout --- core/flyout_button.js | 2 +- core/tooltip.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/flyout_button.js b/core/flyout_button.js index a0280a584..0a3a83414 100644 --- a/core/flyout_button.js +++ b/core/flyout_button.js @@ -155,7 +155,7 @@ Blockly.FlyoutButton.prototype.createDom = function() { this.svgGroup_); svgText.textContent = this.text_; - this.width = svgText.getComputedTextLength(); + this.width = Blockly.Field.getCachedWidth(svgText); this.height = 20; // Can't compute it :( if (!this.isLabel_) { diff --git a/core/tooltip.js b/core/tooltip.js index 17fa45d49..ac5df5e0c 100644 --- a/core/tooltip.js +++ b/core/tooltip.js @@ -248,7 +248,9 @@ Blockly.Tooltip.hide = function() { Blockly.Tooltip.DIV.style.display = 'none'; } } - clearTimeout(Blockly.Tooltip.showPid_); + if (Blockly.Tooltip.showPid_) { + clearTimeout(Blockly.Tooltip.showPid_); + } }; /**