Avoid IE and Edge re-rendering ()

* Fix wrong width of field_dropdown with an image on Edge / IE

* Avoid re-rendering on IE and Edge by using getBBox().width to compute the text width on those browsers
This commit is contained in:
Sam El-Husseini 2017-09-19 15:04:25 -07:00 committed by Paul Kaplan
parent c2e7f6dfe8
commit c55824d619
4 changed files with 7 additions and 40 deletions

View file

@ -953,21 +953,8 @@ Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) {
Blockly.Events.disable();
try {
var block = Blockly.Xml.domToBlock(xmlBlock, this);
// Scratch-specific: Give shadow dom new IDs to prevent duplicating on paste
Blockly.utils.changeObscuredShadowIds(block);
var blocks = block.getDescendants();
for (var i = blocks.length - 1; i >= 0; i--) {
var descendant = blocks[i];
// Rerender to get around problem with IE and Edge not measuring text
// correctly when it is hidden.
if (goog.userAgent.IE || goog.userAgent.EDGE) {
descendant.render(false);
}
}
// Move the duplicate to original position.
Blockly.utils.changeObscuredShadowIds(block); // Move the duplicate to original position.
var blockX = parseInt(xmlBlock.getAttribute('x'), 10);
var blockY = parseInt(xmlBlock.getAttribute('y'), 10);
if (!isNaN(blockX) && !isNaN(blockY)) {