Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: migrate svg math utils to new svgMath namespace #5470

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/block_drag_surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ goog.module.declareLegacyNamespace();
const Coordinate = goog.require('Blockly.utils.Coordinate');
const Svg = goog.require('Blockly.utils.Svg');
const dom = goog.require('Blockly.utils.dom');
const utils = goog.require('Blockly.utils');
const svgMath = goog.require('Blockly.utils.svgMath');


/**
Expand Down Expand Up @@ -192,7 +192,7 @@ BlockDragSurfaceSvg.prototype.translateSurface = function(x, y) {
* @return {!Coordinate} Current translation of the surface.
*/
BlockDragSurfaceSvg.prototype.getSurfaceTranslation = function() {
const xy = utils.getRelativeXY(/** @type {!SVGElement} */ (this.SVG_));
const xy = svgMath.getRelativeXY(/** @type {!SVGElement} */ (this.SVG_));
return new Coordinate(xy.x / this.scale_, xy.y / this.scale_);
};

Expand Down
5 changes: 3 additions & 2 deletions core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const deprecation = goog.require('Blockly.utils.deprecation');
const dom = goog.require('Blockly.utils.dom');
const internalConstants = goog.require('Blockly.internalConstants');
const object = goog.require('Blockly.utils.object');
const svgMath = goog.require('Blockly.utils.svgMath');
const userAgent = goog.require('Blockly.utils.userAgent');
const utils = goog.require('Blockly.utils');
/** @suppress {extraRequire} */
Expand Down Expand Up @@ -143,7 +144,7 @@ const BlockSvg = function(workspace, prototypeName, opt_id) {
* @private
*/
this.useDragSurface_ =
utils.is3dSupported() && !!workspace.getBlockDragSurface();
svgMath.is3dSupported() && !!workspace.getBlockDragSurface();

const svgPath = this.pathObject.svgPath;
svgPath.tooltip = this;
Expand Down Expand Up @@ -456,7 +457,7 @@ BlockSvg.prototype.getRelativeToSurfaceXY = function() {
if (element) {
do {
// Loop through this block and every parent.
const xy = utils.getRelativeXY(element);
const xy = svgMath.getRelativeXY(element);
x += xy.x;
y += xy.y;
// If this element is the current element on the drag surface, include
Expand Down
4 changes: 2 additions & 2 deletions core/bubble_dragger.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const IDragTarget = goog.requireType('Blockly.IDragTarget');
const WorkspaceCommentSvg = goog.requireType('Blockly.WorkspaceCommentSvg');
/* eslint-disable-next-line no-unused-vars */
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const utils = goog.require('Blockly.utils');
const svgMath = goog.require('Blockly.utils.svgMath');
/** @suppress {extraRequire} */
goog.require('Blockly.Bubble');
/** @suppress {extraRequire} */
Expand Down Expand Up @@ -89,7 +89,7 @@ const BubbleDragger = function(bubble, workspace) {
* @private
*/
this.dragSurface_ =
utils.is3dSupported() && !!workspace.getBlockDragSurface() ?
svgMath.is3dSupported() && !!workspace.getBlockDragSurface() ?
workspace.getBlockDragSurface() :
null;
};
Expand Down
3 changes: 2 additions & 1 deletion core/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const aria = goog.require('Blockly.utils.aria');
const browserEvents = goog.require('Blockly.browserEvents');
const dom = goog.require('Blockly.utils.dom');
const internalConstants = goog.require('Blockly.internalConstants');
const svgMath = goog.require('Blockly.utils.svgMath');
const userAgent = goog.require('Blockly.utils.userAgent');
const utils = goog.require('Blockly.utils');
/* eslint-disable-next-line no-unused-vars */
Expand Down Expand Up @@ -144,7 +145,7 @@ const populate_ = function(options, rtl) {
*/
const position_ = function(menu, e, rtl) {
// Record windowSize and scrollOffset before adding menu.
const viewportBBox = utils.getViewportBBox();
const viewportBBox = svgMath.getViewportBBox();
// This one is just a point, but we'll pretend that it's a rect so we can use
// some helper functions.
const anchorBBox = new Rect(
Expand Down
3 changes: 2 additions & 1 deletion core/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Size = goog.require('Blockly.utils.Size');
const Svg = goog.require('Blockly.utils.Svg');
const browserEvents = goog.require('Blockly.browserEvents');
const dom = goog.require('Blockly.utils.dom');
const svgMath = goog.require('Blockly.utils.svgMath');
const utils = goog.require('Blockly.utils');


Expand Down Expand Up @@ -167,7 +168,7 @@ Icon.prototype.setIconLocation = function(xy) {
Icon.prototype.computeIconLocation = function() {
// Find coordinates for the centre of the icon and update the arrow.
const blockXY = this.block_.getRelativeToSurfaceXY();
const iconXY = utils.getRelativeXY(
const iconXY = svgMath.getRelativeXY(
/** @type {!SVGElement} */ (this.iconGroup_));
const newXY = new Coordinate(
blockXY.x + iconXY.x + this.SIZE / 2,
Expand Down
4 changes: 2 additions & 2 deletions core/rendered_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const dom = goog.require('Blockly.utils.dom');
const internalConstants = goog.require('Blockly.internalConstants');
const object = goog.require('Blockly.utils.object');
const svgPaths = goog.require('Blockly.utils.svgPaths');
const utils = goog.require('Blockly.utils');
const svgMath = goog.require('Blockly.utils.svgMath');


/**
Expand Down Expand Up @@ -266,7 +266,7 @@ RenderedConnection.prototype.tighten = function() {
throw Error('block is not rendered.');
}
// Workspace coordinates.
const xy = utils.getRelativeXY(svgRoot);
const xy = svgMath.getRelativeXY(svgRoot);
block.getSvgRoot().setAttribute(
'transform', 'translate(' + (xy.x - dx) + ',' + (xy.y - dy) + ')');
block.moveConnections(-dx, -dy);
Expand Down
3 changes: 2 additions & 1 deletion core/scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Svg = goog.require('Blockly.utils.Svg');
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const browserEvents = goog.require('Blockly.browserEvents');
const dom = goog.require('Blockly.utils.dom');
const svgMath = goog.require('Blockly.utils.svgMath');
const utils = goog.require('Blockly.utils');


Expand Down Expand Up @@ -690,7 +691,7 @@ Scrollbar.prototype.onMouseDownBar_ = function(e) {
e, this.workspace_.getParentSvg(), this.workspace_.getInverseScreenCTM());
const mouseLocation = this.horizontal_ ? mouseXY.x : mouseXY.y;

const handleXY = utils.getInjectionDivXY_(this.svgHandle_);
const handleXY = svgMath.getInjectionDivXY(this.svgHandle_);
const handleStart = this.horizontal_ ? handleXY.x : handleXY.y;
let handlePosition = this.handlePosition_;

Expand Down
Loading