From c9afdd095efb7431678ca83215aa81e375220bbd Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Thu, 3 Jun 2021 16:44:07 -0700 Subject: [PATCH] Fix drag surface (#4863) * Return copy * Run clang format * Address PR Comment * update chrome version --- core/block_drag_surface.js | 25 +++++++++++++++---------- tests/scripts/selenium-config.js | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/core/block_drag_surface.js b/core/block_drag_surface.js index a0e8fd31a..c694fd138 100644 --- a/core/block_drag_surface.js +++ b/core/block_drag_surface.js @@ -100,9 +100,10 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom = function() { 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'class': 'blocklyBlockDragSurface' - }, this.container_); - this.dragGroup_ = Blockly.utils.dom.createSvgElement( - Blockly.utils.Svg.G, {}, this.SVG_); + }, + this.container_); + this.dragGroup_ = + Blockly.utils.dom.createSvgElement(Blockly.utils.Svg.G, {}, this.SVG_); }; /** @@ -128,8 +129,8 @@ Blockly.BlockDragSurfaceSvg.prototype.setBlocksAndShow = function(blocks) { * @param {number} y Y translation in pixel coordinates. * @param {number} scale Scale of the group. */ -Blockly.BlockDragSurfaceSvg.prototype.translateAndScaleGroup = function(x, y, - scale) { +Blockly.BlockDragSurfaceSvg.prototype.translateAndScaleGroup = function( + x, y, scale) { this.scale_ = scale; // This is a work-around to prevent a the blocks from rendering // fuzzy while they are being dragged on the drag surface. @@ -139,7 +140,8 @@ Blockly.BlockDragSurfaceSvg.prototype.translateAndScaleGroup = function(x, y, this.childSurfaceXY_.x = parseInt(fixedX, 10); this.childSurfaceXY_.y = parseInt(fixedY, 10); - this.dragGroup_.setAttribute('transform', + this.dragGroup_.setAttribute( + 'transform', 'translate(' + fixedX + ',' + fixedY + ') scale(' + scale + ')'); }; @@ -156,8 +158,8 @@ Blockly.BlockDragSurfaceSvg.prototype.translateSurfaceInternal_ = function() { y = y.toFixed(0); this.SVG_.style.display = 'block'; - Blockly.utils.dom.setCssTransform(this.SVG_, - 'translate3d(' + x + 'px, ' + y + 'px, 0px)'); + Blockly.utils.dom.setCssTransform( + this.SVG_, 'translate3d(' + x + 'px, ' + y + 'px, 0px)'); }; /** @@ -181,7 +183,8 @@ Blockly.BlockDragSurfaceSvg.prototype.translateBy = function(deltaX, deltaY) { * @param {number} y Y translation for the entire surface. */ Blockly.BlockDragSurfaceSvg.prototype.translateSurface = function(x, y) { - this.surfaceXY_ = new Blockly.utils.Coordinate(x * this.scale_, y * this.scale_); + this.surfaceXY_ = + new Blockly.utils.Coordinate(x * this.scale_, y * this.scale_); this.translateSurfaceInternal_(); }; @@ -229,7 +232,9 @@ Blockly.BlockDragSurfaceSvg.prototype.getCurrentBlock = function() { * @return {!Blockly.utils.Coordinate} The amount the workspace has been moved. */ Blockly.BlockDragSurfaceSvg.prototype.getWsTranslation = function() { - return this.childSurfaceXY_; + // Returning a copy so the coordinate can not be changed outside this class. + return new Blockly.utils.Coordinate( + this.childSurfaceXY_.x, this.childSurfaceXY_.y); }; /** diff --git a/tests/scripts/selenium-config.js b/tests/scripts/selenium-config.js index 28aaca919..b0e2ab7c4 100644 --- a/tests/scripts/selenium-config.js +++ b/tests/scripts/selenium-config.js @@ -9,7 +9,7 @@ module.exports = { chrome: { // check for more recent versions of chrome driver here: // https://chromedriver.storage.googleapis.com/index.html - version: '89.0.4389.23', + version: '91.0.4472.19', arch: process.arch, baseURL: 'https://chromedriver.storage.googleapis.com' },