diff --git a/core/block_svg.ts b/core/block_svg.ts index 0da93ef5b..bbf2a3d2a 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -196,8 +196,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, * Whether to move the block to the drag surface when it is dragged. * True if it should move, false if it should be translated directly. */ - this.useDragSurface_ = - svgMath.is3dSupported() && !!workspace.getBlockDragSurface(); + this.useDragSurface_ = !!workspace.getBlockDragSurface(); const svgPath = this.pathObject.svgPath; (svgPath as AnyDuringMigration).tooltip = this; diff --git a/core/bubble_dragger.ts b/core/bubble_dragger.ts index 769fcf4a1..1ac916fc4 100644 --- a/core/bubble_dragger.ts +++ b/core/bubble_dragger.ts @@ -20,7 +20,6 @@ import type {IBubble} from './interfaces/i_bubble.js'; import type {IDeleteArea} from './interfaces/i_delete_area.js'; import type {IDragTarget} from './interfaces/i_drag_target.js'; import {Coordinate} from './utils/coordinate.js'; -import * as svgMath from './utils/svg_math.js'; import {WorkspaceCommentSvg} from './workspace_comment_svg.js'; import type {WorkspaceSvg} from './workspace_svg.js'; @@ -56,10 +55,7 @@ export class BubbleDragger { * The drag surface to move bubbles to during a drag, or null if none should * be used. Block dragging and bubble dragging use the same surface. */ - this.dragSurface_ = - svgMath.is3dSupported() && !!workspace.getBlockDragSurface() ? - workspace.getBlockDragSurface() : - null; + this.dragSurface_ = workspace.getBlockDragSurface(); } /** diff --git a/core/utils/svg_math.ts b/core/utils/svg_math.ts index 4b7668487..5fbdd0483 100644 --- a/core/utils/svg_math.ts +++ b/core/utils/svg_math.ts @@ -117,57 +117,10 @@ export function getInjectionDivXY(element: Element): Coordinate { * @alias Blockly.utils.svgMath.is3dSupported */ export function is3dSupported(): boolean { - // AnyDuringMigration because: Property 'cached_' does not exist on type '() - // => boolean'. - if ((is3dSupported as AnyDuringMigration).cached_ !== undefined) { - // AnyDuringMigration because: Property 'cached_' does not exist on type - // '() => boolean'. - return (is3dSupported as AnyDuringMigration).cached_; - } - // CC-BY-SA Lorenzo Polidori - // stackoverflow.com/questions/5661671/detecting-transform-translate3d-support - if (!globalThis['getComputedStyle']) { - return false; - } - - const el = document.createElement('p'); - let has3d = 'none'; - const transforms = { - 'webkitTransform': '-webkit-transform', - 'OTransform': '-o-transform', - 'msTransform': '-ms-transform', - 'MozTransform': '-moz-transform', - 'transform': 'transform', - }; - - // Add it to the body to get the computed style. - document.body.insertBefore(el, null); - - for (const t in transforms) { - if ((el.style as AnyDuringMigration)[t] !== undefined) { - (el.style as AnyDuringMigration)[t] = 'translate3d(1px,1px,1px)'; - const computedStyle = globalThis['getComputedStyle'](el); - if (!computedStyle) { - // getComputedStyle in Firefox returns null when Blockly is loaded - // inside an iframe with display: none. Returning false and not - // caching is3dSupported means we try again later. This is most likely - // when users are interacting with blocks which should mean Blockly is - // visible again. - // See https://bugzilla.mozilla.org/show_bug.cgi?id=548397 - document.body.removeChild(el); - return false; - } - has3d = - computedStyle.getPropertyValue((transforms as AnyDuringMigration)[t]); - } - } - document.body.removeChild(el); - // AnyDuringMigration because: Property 'cached_' does not exist on type '() - // => boolean'. - (is3dSupported as AnyDuringMigration).cached_ = has3d !== 'none'; - // AnyDuringMigration because: Property 'cached_' does not exist on type '() - // => boolean'. - return (is3dSupported as AnyDuringMigration).cached_; + // All browsers support translate3d in 2022. + deprecation.warn( + 'Blockly.utils.svgMath.is3dSupported', 'version 9.0.0', 'version 10.0.0'); + return true; } /** diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index 769a4f707..96eccc7cc 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -124,8 +124,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * Whether to move the comment to the drag surface when it is dragged. * True if it should move, false if it should be translated directly. */ - this.useDragSurface_ = - svgMath.is3dSupported() && !!workspace.getBlockDragSurface(); + this.useDragSurface_ = !!workspace.getBlockDragSurface(); this.render(); } diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 7e4186b43..e10ab85d4 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -373,8 +373,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { this.workspaceDragSurface_ = opt_wsDragSurface; } - this.useWorkspaceDragSurface_ = - !!this.workspaceDragSurface_ && svgMath.is3dSupported(); + this.useWorkspaceDragSurface_ = !!this.workspaceDragSurface_; /** * Object in charge of loading, storing, and playing audio for a workspace.