diff --git a/lib/minimap-element.js b/lib/minimap-element.js index 9adfefc8..f0869bce 100644 --- a/lib/minimap-element.js +++ b/lib/minimap-element.js @@ -31,7 +31,7 @@ const SPEC_MODE = atom.inSpecMode() */ class MinimapElement { static initClass() { - include(this, CanvasDrawer, EventsDelegation, AncestorsMethods) + include(this, EventsDelegation, AncestorsMethods) return element(this, "atom-text-editor-minimap") } @@ -123,6 +123,21 @@ class MinimapElement { */ this.absoluteMode = undefined + /** + * @access private + */ + this.smoothScrolling = undefined + + /** + * @access private + */ + this.adjustOnlyIfSmaller = undefined + + /** + * @access private + */ + this.adjustAbsoluteModeHeight = undefined + // Elements /** @@ -146,6 +161,14 @@ class MinimapElement { */ this.quickSettingsElement = undefined + /** + * This MinimapElement's CanvasDrawer + */ + this.CanvasDrawer = new CanvasDrawer() + + /** + * @access private + */ this.DecorationManagement = new DecorationManagement() // States @@ -186,6 +209,11 @@ class MinimapElement { */ this.flexBasis = undefined + /** + * @access private + */ + this.intersectionObserver = undefined + this.initializeContent() this.subscriptions.add( @@ -221,7 +249,7 @@ class MinimapElement { }), atom.config.observe("minimap.textOpacity", (textOpacity) => { - this.textOpacity = textOpacity + this.CanvasDrawer.textOpacity = textOpacity if (this.attached) { this.requestForcedUpdate() @@ -229,7 +257,7 @@ class MinimapElement { }), atom.config.observe("minimap.displayCodeHighlights", (displayCodeHighlights) => { - this.displayCodeHighlights = displayCodeHighlights + this.CanvasDrawer.displayCodeHighlights = displayCodeHighlights if (this.attached) { this.requestForcedUpdate() @@ -241,9 +269,9 @@ class MinimapElement { if (this.attached) { if (!this.smoothScrolling) { - this.backLayer.canvas.style.cssText = "" - this.tokensLayer.canvas.style.cssText = "" - this.frontLayer.canvas.style.cssText = "" + this.CanvasDrawer.backLayer.canvas.style.cssText = "" + this.CanvasDrawer.tokensLayer.canvas.style.cssText = "" + this.CanvasDrawer.frontLayer.canvas.style.cssText = "" } else { this.requestUpdate() } @@ -291,7 +319,7 @@ class MinimapElement { }), atom.config.observe("minimap.ignoreWhitespacesInTokens", (ignoreWhitespacesInTokens) => { - this.ignoreWhitespacesInTokens = ignoreWhitespacesInTokens + this.CanvasDrawer.ignoreWhitespacesInTokens = ignoreWhitespacesInTokens if (this.attached) { this.requestForcedUpdate() @@ -493,9 +521,9 @@ class MinimapElement { * @access private */ initializeContent() { - this.initializeCanvas() + this.CanvasDrawer.initializeCanvas() - this.attachCanvases(this) + this.CanvasDrawer.attachCanvases(this) this.createVisibleArea() this.createControls() @@ -514,7 +542,7 @@ class MinimapElement { ), this.subscribeTo( - this.getFrontCanvas(), + this.CanvasDrawer.getFrontCanvas(), { mousedown: (e) => { this.canvasPressed(extractMouseEventData(e)) @@ -663,7 +691,7 @@ class MinimapElement { this.quickSettingsElement = null }) - const { top, left, right } = this.getFrontCanvas().getBoundingClientRect() + const { top, left, right } = this.CanvasDrawer.getFrontCanvas().getBoundingClientRect() this.quickSettingsElement.style.top = `${top}px` this.quickSettingsElement.attach() @@ -726,6 +754,8 @@ class MinimapElement { */ setModel(minimap) { this.minimap = minimap + // TODO: go direct + this.CanvasDrawer.minimap = minimap // set minimapElement for Minimap this.minimap.minimapElement = this @@ -757,16 +787,16 @@ class MinimapElement { }), this.minimap.onDidChange((change) => { - this.pendingChanges.push(change) + this.CanvasDrawer.pendingChanges.push(change) this.requestUpdate() }), this.DecorationManagement.onDidChangeDecorationRange((change) => { const { type } = change if (type === "line" || type === "highlight-under" || type === "background-custom") { - this.pendingBackDecorationChanges.push(change) + this.CanvasDrawer.pendingBackDecorationChanges.push(change) } else { - this.pendingFrontDecorationChanges.push(change) + this.CanvasDrawer.pendingFrontDecorationChanges.push(change) } this.requestUpdate() }), @@ -856,7 +886,7 @@ class MinimapElement { } const minimap = this.minimap minimap.enableCache() - const canvas = this.getFrontCanvas() + const canvas = this.CanvasDrawer.getFrontCanvas() const devicePixelRatio = this.minimap.getDevicePixelRatio() const visibleAreaLeft = minimap.getTextEditorScaledScrollLeft() @@ -894,25 +924,25 @@ class MinimapElement { if (this.smoothScrolling) { if (SPEC_MODE) { - applyStyles(this.backLayer.canvas, { top: `${canvasTop}px` }) - applyStyles(this.tokensLayer.canvas, { top: `${canvasTop}px` }) - applyStyles(this.frontLayer.canvas, { top: `${canvasTop}px` }) + applyStyles(this.CanvasDrawer.backLayer.canvas, { top: `${canvasTop}px` }) + applyStyles(this.CanvasDrawer.tokensLayer.canvas, { top: `${canvasTop}px` }) + applyStyles(this.CanvasDrawer.frontLayer.canvas, { top: `${canvasTop}px` }) } else { let canvasTransform = makeTranslate(0, canvasTop, this.useHardwareAcceleration) if (devicePixelRatio !== 1) { const scale = 1 / devicePixelRatio canvasTransform += ` ${makeScale(scale, scale, this.useHardwareAcceleration)}` } - applyStyles(this.backLayer.canvas, { transform: canvasTransform }) - applyStyles(this.tokensLayer.canvas, { transform: canvasTransform }) - applyStyles(this.frontLayer.canvas, { transform: canvasTransform }) + applyStyles(this.CanvasDrawer.backLayer.canvas, { transform: canvasTransform }) + applyStyles(this.CanvasDrawer.tokensLayer.canvas, { transform: canvasTransform }) + applyStyles(this.CanvasDrawer.frontLayer.canvas, { transform: canvasTransform }) } } else { const scale = 1 / devicePixelRatio const canvasTransform = makeScale(scale, scale, this.useHardwareAcceleration) - applyStyles(this.backLayer.canvas, { transform: canvasTransform }) - applyStyles(this.tokensLayer.canvas, { transform: canvasTransform }) - applyStyles(this.frontLayer.canvas, { transform: canvasTransform }) + applyStyles(this.CanvasDrawer.backLayer.canvas, { transform: canvasTransform }) + applyStyles(this.CanvasDrawer.tokensLayer.canvas, { transform: canvasTransform }) + applyStyles(this.CanvasDrawer.frontLayer.canvas, { transform: canvasTransform }) } if (this.minimapScrollIndicator && !this.scrollIndicator && minimap.canScroll()) { @@ -945,7 +975,7 @@ class MinimapElement { this.updateCanvasesSize() } - this.updateCanvas() + this.CanvasDrawer.updateCanvas() minimap.clearCache() } @@ -956,7 +986,7 @@ class MinimapElement { * highlights or not */ setDisplayCodeHighlights(displayCodeHighlights) { - this.displayCodeHighlights = displayCodeHighlights + this.CanvasDrawer.displayCodeHighlights = displayCodeHighlights if (this.attached) { this.requestForcedUpdate() } @@ -1076,14 +1106,14 @@ class MinimapElement { this.absoluteMode && this.adjustAbsoluteModeHeight ? Math.min(this.minimap.getHeight(), maxCanvasHeight) : maxCanvasHeight - const canvas = this.getFrontCanvas() + const canvas = this.CanvasDrawer.getFrontCanvas() if (canvasWidth == null) { canvasWidth = canvas.width / devicePixelRatio } if (canvasWidth !== canvas.width || newHeight !== canvas.height) { - this.setCanvasesSize(canvasWidth * devicePixelRatio, newHeight * devicePixelRatio) + this.CanvasDrawer.setCanvasesSize(canvasWidth * devicePixelRatio, newHeight * devicePixelRatio) if (this.absoluteMode && this.adjustAbsoluteModeHeight) { this.offscreenFirstRow = null this.offscreenLastRow = null diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 5e8634cf..0c5eef46 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -1,7 +1,6 @@ "use strict" import { escapeRegExp } from "../deps/underscore-plus" -import Mixin from "mixto" import * as Main from "../main" import { domStylesReader } from "../main" @@ -18,16 +17,25 @@ let thisSpec * This mixin is injected in the `MinimapElement` prototype, so all these * methods are available on any `MinimapElement` instance. */ -export default class CanvasDrawer extends Mixin { +export default class CanvasDrawer { + constructor() { + // set in setModel of minimapElement + this.minimap = undefined + + // set by minimapElement + this.displayCodeHighlights = atom.config.get("minimap.displayCodeHighlights") + this.ignoreWhitespacesInTokens = atom.config.get("minimap.ignoreWhitespacesInTokens") + this.textOpacity = atom.config.get("minimap.textOpacity") + } + /** * Initializes the canvas elements needed to perform the `Minimap` rendering. */ initializeCanvas() { + // NOTE "Test Only Code": this code is removed in production code if (SPEC_MODE) { // class methods only used for spying the calls - this.drawLines = (firstLine, lastLine) => { - console.log({ firstLine, lastLine }) - } + this.drawLines = (firstLine, lastLine) => firstLine + lastLine this.drawLineDecoration = drawLineDecoration this.drawGutterDecoration = drawGutterDecoration this.drawHighlightDecoration = drawHighlightDecoration @@ -163,7 +171,7 @@ export default class CanvasDrawer extends Mixin { this.drawLines(firstRow, lastRow) } - const decorations = this.DecorationManagement.decorationsByTypeThenRows(firstRow, lastRow) + const decorations = this.minimap.getDecorationManagement().decorationsByTypeThenRows(firstRow, lastRow) const renderData = { context: this.backLayer.context, diff --git a/spec/minimap-element-spec.js b/spec/minimap-element-spec.js index 81532f46..5c062eec 100644 --- a/spec/minimap-element-spec.js +++ b/spec/minimap-element-spec.js @@ -227,7 +227,7 @@ describe("MinimapElement", () => { describe("when a hue-rotate filter is applied to a rgb color", () => { let [additionnalStyleNode] = [] beforeEach(() => { - minimapElement.DOMStylesReader.invalidateDOMStylesCache() + minimapElement.CanvasDrawer.DOMStylesReader.invalidateDOMStylesCache() additionnalStyleNode = document.createElement("style") additionnalStyleNode.textContent = ` @@ -247,7 +247,7 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() expect( - minimapElement.DOMStylesReader.retrieveStyleFromDom( + minimapElement.CanvasDrawer.DOMStylesReader.retrieveStyleFromDom( [".editor"], "color", minimapElement.minimap.getTextEditorElement(), @@ -262,7 +262,7 @@ describe("MinimapElement", () => { let [additionnalStyleNode] = [] beforeEach(() => { - minimapElement.DOMStylesReader.invalidateDOMStylesCache() + minimapElement.CanvasDrawer.DOMStylesReader.invalidateDOMStylesCache() additionnalStyleNode = document.createElement("style") additionnalStyleNode.textContent = ` @@ -282,7 +282,7 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() expect( - minimapElement.DOMStylesReader.retrieveStyleFromDom( + minimapElement.CanvasDrawer.DOMStylesReader.retrieveStyleFromDom( [".editor"], "color", minimapElement.minimap.getTextEditorElement(), @@ -367,10 +367,10 @@ describe("MinimapElement", () => { atom.config.set("minimap.plugins.fooDecorationsZIndex", 1) const calls = [] - spyOn(minimapElement, "drawLineDecoration").andCallFake((d) => { + spyOn(minimapElement.CanvasDrawer, "drawLineDecoration").andCallFake((d) => { calls.push(d.getProperties().plugin) }) - spyOn(minimapElement, "drawHighlightDecoration").andCallFake((d) => { + spyOn(minimapElement.CanvasDrawer, "drawHighlightDecoration").andCallFake((d) => { calls.push(d.getProperties().plugin) }) @@ -419,7 +419,7 @@ describe("MinimapElement", () => { }) it("renders the visible line decorations", () => { - spyOn(minimapElement, "drawLineDecoration").andCallThrough() + spyOn(minimapElement.CanvasDrawer, "drawLineDecoration").andCallThrough() minimapElement.DecorationManagement.decorateMarker( editor.markBufferRange([ @@ -451,13 +451,13 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.drawLineDecoration).toHaveBeenCalled() - expect(minimapElement.drawLineDecoration.calls.length).toEqual(2) + expect(minimapElement.CanvasDrawer.drawLineDecoration).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.drawLineDecoration.calls.length).toEqual(2) }) }) it("renders the visible gutter decorations", () => { - spyOn(minimapElement, "drawGutterDecoration").andCallThrough() + spyOn(minimapElement.CanvasDrawer, "drawGutterDecoration").andCallThrough() minimapElement.DecorationManagement.decorateMarker( editor.markBufferRange([ @@ -489,13 +489,13 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.drawGutterDecoration).toHaveBeenCalled() - expect(minimapElement.drawGutterDecoration.calls.length).toEqual(2) + expect(minimapElement.CanvasDrawer.drawGutterDecoration).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.drawGutterDecoration.calls.length).toEqual(2) }) }) it("renders the visible highlight decorations", () => { - spyOn(minimapElement, "drawHighlightDecoration").andCallThrough() + spyOn(minimapElement.CanvasDrawer, "drawHighlightDecoration").andCallThrough() minimapElement.DecorationManagement.decorateMarker( editor.markBufferRange([ @@ -527,13 +527,13 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.drawHighlightDecoration).toHaveBeenCalled() - expect(minimapElement.drawHighlightDecoration.calls.length).toEqual(2) + expect(minimapElement.CanvasDrawer.drawHighlightDecoration).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.drawHighlightDecoration.calls.length).toEqual(2) }) }) it("renders the visible outline decorations", () => { - spyOn(minimapElement, "drawHighlightOutlineDecoration").andCallThrough() + spyOn(minimapElement.CanvasDrawer, "drawHighlightOutlineDecoration").andCallThrough() minimapElement.DecorationManagement.decorateMarker( editor.markBufferRange([ @@ -565,13 +565,13 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.drawHighlightOutlineDecoration).toHaveBeenCalled() - expect(minimapElement.drawHighlightOutlineDecoration.calls.length).toEqual(4) + expect(minimapElement.CanvasDrawer.drawHighlightOutlineDecoration).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.drawHighlightOutlineDecoration.calls.length).toEqual(4) }) }) it("renders the visible custom foreground decorations", () => { - spyOn(minimapElement, "drawCustomDecoration").andCallThrough() + spyOn(minimapElement.CanvasDrawer, "drawCustomDecoration").andCallThrough() const renderRoutine = jasmine.createSpy("renderRoutine") @@ -610,8 +610,8 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.drawCustomDecoration).toHaveBeenCalled() - expect(minimapElement.drawCustomDecoration.calls.length).toEqual(4) + expect(minimapElement.CanvasDrawer.drawCustomDecoration).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.drawCustomDecoration.calls.length).toEqual(4) expect(renderRoutine).toHaveBeenCalled() expect(renderRoutine.calls.length).toEqual(4) @@ -619,7 +619,7 @@ describe("MinimapElement", () => { }) it("renders the visible custom background decorations", () => { - spyOn(minimapElement, "drawCustomDecoration").andCallThrough() + spyOn(minimapElement.CanvasDrawer, "drawCustomDecoration").andCallThrough() const renderRoutine = jasmine.createSpy("renderRoutine") @@ -658,8 +658,8 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.drawCustomDecoration).toHaveBeenCalled() - expect(minimapElement.drawCustomDecoration.calls.length).toEqual(4) + expect(minimapElement.CanvasDrawer.drawCustomDecoration).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.drawCustomDecoration.calls.length).toEqual(4) expect(renderRoutine).toHaveBeenCalled() expect(renderRoutine.calls.length).toEqual(4) @@ -733,7 +733,7 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - spyOn(minimapElement, "drawLines").andCallThrough() + spyOn(minimapElement.CanvasDrawer, "drawLines").andCallThrough() editor.insertText("foo") }) }) @@ -745,9 +745,9 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.drawLines).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.drawLines).toHaveBeenCalled() - const [firstLine, lastLine] = minimapElement.drawLines.argsForCall[0] + const [firstLine, lastLine] = minimapElement.CanvasDrawer.drawLines.argsForCall[0] // These tests are very flaky, depending on Atom's version the // measured values can changed so we have @@ -759,8 +759,8 @@ describe("MinimapElement", () => { describe("when the editor visibility change", () => { it("does not modify the size of the canvas", () => { - const canvasWidth = minimapElement.getFrontCanvas().width - const canvasHeight = minimapElement.getFrontCanvas().height + const canvasWidth = minimapElement.CanvasDrawer.getFrontCanvas().width + const canvasHeight = minimapElement.CanvasDrawer.getFrontCanvas().height editorElement.style.display = "none" minimapElement.measureHeightAndWidth() @@ -771,8 +771,8 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() - expect(minimapElement.getFrontCanvas().width).toEqual(canvasWidth) - expect(minimapElement.getFrontCanvas().height).toEqual(canvasHeight) + expect(minimapElement.CanvasDrawer.getFrontCanvas().width).toEqual(canvasWidth) + expect(minimapElement.CanvasDrawer.getFrontCanvas().height).toEqual(canvasHeight) }) }) @@ -867,7 +867,7 @@ describe("MinimapElement", () => { let [canvas, visibleArea, originalLeft, maxScroll] = [] beforeEach(() => { - canvas = minimapElement.getFrontCanvas() + canvas = minimapElement.CanvasDrawer.getFrontCanvas() visibleArea = minimapElement.visibleArea originalLeft = visibleArea.getBoundingClientRect().left maxScroll = minimap.getTextEditorMaxScrollTop() @@ -964,7 +964,7 @@ describe("MinimapElement", () => { atom.config.set("minimap.scrollAnimation", false) - canvas = minimapElement.getFrontCanvas() + canvas = minimapElement.CanvasDrawer.getFrontCanvas() }) it("scrolls the editor to the line below the mouse", () => { @@ -1005,7 +1005,7 @@ describe("MinimapElement", () => { atom.config.set("minimap.scrollAnimation", true) atom.config.set("minimap.scrollAnimationDuration", 300) - canvas = minimapElement.getFrontCanvas() + canvas = minimapElement.CanvasDrawer.getFrontCanvas() }) it("scrolls the editor gradually to the line below the mouse", () => { @@ -1317,7 +1317,7 @@ describe("MinimapElement", () => { atom.config.set("minimap.scrollAnimation", false) - canvas = minimapElement.getFrontCanvas() + canvas = minimapElement.CanvasDrawer.getFrontCanvas() mousedown(canvas) }) @@ -1393,7 +1393,7 @@ describe("MinimapElement", () => { runs(() => { nextAnimationFrame() spyOn(minimapElement, "requestForcedUpdate").andCallThrough() - spyOn(minimapElement.DOMStylesReader, "invalidateDOMStylesCache").andCallThrough() + spyOn(minimapElement.CanvasDrawer.DOMStylesReader, "invalidateDOMStylesCache").andCallThrough() }) }) @@ -1407,7 +1407,7 @@ describe("MinimapElement", () => { runs(() => { expect(minimapElement.requestForcedUpdate).toHaveBeenCalled() - expect(minimapElement.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() }) }) @@ -1421,7 +1421,7 @@ describe("MinimapElement", () => { runs(() => { expect(minimapElement.requestForcedUpdate).toHaveBeenCalled() - expect(minimapElement.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() }) }) @@ -1435,7 +1435,7 @@ describe("MinimapElement", () => { runs(() => { expect(minimapElement.requestForcedUpdate).toHaveBeenCalled() - expect(minimapElement.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() }) }) @@ -1449,7 +1449,7 @@ describe("MinimapElement", () => { runs(() => { expect(minimapElement.requestForcedUpdate).toHaveBeenCalled() - expect(minimapElement.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() + expect(minimapElement.CanvasDrawer.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled() }) }) }) @@ -1612,7 +1612,7 @@ describe("MinimapElement", () => { }) it("adjusts the width of the minimap canvas", () => { - expect(minimapElement.getFrontCanvas().width / devicePixelRatio).toEqual(4) + expect(minimapElement.CanvasDrawer.getFrontCanvas().width / devicePixelRatio).toEqual(4) }) it("offsets the minimap by the difference", () => { @@ -1631,7 +1631,7 @@ describe("MinimapElement", () => { }) runs(() => { nextAnimationFrame() - expect(minimapElement.getFrontCanvas().width / devicePixelRatio).toEqual(4) + expect(minimapElement.CanvasDrawer.getFrontCanvas().width / devicePixelRatio).toEqual(4) }) }) }) @@ -1967,7 +1967,7 @@ describe("MinimapElement", () => { }) it("positions the quick settings view next to the minimap", () => { - const minimapBounds = minimapElement.getFrontCanvas().getBoundingClientRect() + const minimapBounds = minimapElement.CanvasDrawer.getFrontCanvas().getBoundingClientRect() const settingsBounds = quickSettingsElement.getBoundingClientRect() expect(realOffsetTop(quickSettingsElement)).toBeCloseTo(minimapBounds.top, 0) @@ -1994,7 +1994,7 @@ describe("MinimapElement", () => { }) it("positions the quick settings view next to the minimap", () => { - const minimapBounds = minimapElement.getFrontCanvas().getBoundingClientRect() + const minimapBounds = minimapElement.CanvasDrawer.getFrontCanvas().getBoundingClientRect() expect(realOffsetTop(quickSettingsElement)).toBeCloseTo(minimapBounds.top, 0) expect(realOffsetLeft(quickSettingsElement)).toBeCloseTo(minimapBounds.right, 0) @@ -2030,12 +2030,14 @@ describe("MinimapElement", () => { }) it("adjusts the size of the control div to fit in the minimap", () => { - expect(controls.clientWidth).toEqual(minimapElement.getFrontCanvas().clientWidth / devicePixelRatio) + expect(controls.clientWidth).toEqual( + minimapElement.CanvasDrawer.getFrontCanvas().clientWidth / devicePixelRatio + ) }) it("positions the controls div over the canvas", () => { const controlsRect = controls.getBoundingClientRect() - const canvasRect = minimapElement.getFrontCanvas().getBoundingClientRect() + const canvasRect = minimapElement.CanvasDrawer.getFrontCanvas().getBoundingClientRect() expect(controlsRect.left).toEqual(canvasRect.left) expect(controlsRect.right).toEqual(canvasRect.right) }) @@ -2046,12 +2048,14 @@ describe("MinimapElement", () => { }) it("adjusts the size of the control div to fit in the minimap", () => { - expect(controls.clientWidth).toEqual(minimapElement.getFrontCanvas().clientWidth / devicePixelRatio) + expect(controls.clientWidth).toEqual( + minimapElement.CanvasDrawer.getFrontCanvas().clientWidth / devicePixelRatio + ) }) it("positions the controls div over the canvas", () => { const controlsRect = controls.getBoundingClientRect() - const canvasRect = minimapElement.getFrontCanvas().getBoundingClientRect() + const canvasRect = minimapElement.CanvasDrawer.getFrontCanvas().getBoundingClientRect() expect(controlsRect.left).toEqual(canvasRect.left) expect(controlsRect.right).toEqual(canvasRect.right) }) @@ -2072,7 +2076,7 @@ describe("MinimapElement", () => { }) it("positions the quick settings view next to the minimap", () => { - const minimapBounds = minimapElement.getFrontCanvas().getBoundingClientRect() + const minimapBounds = minimapElement.CanvasDrawer.getFrontCanvas().getBoundingClientRect() expect(realOffsetTop(quickSettingsElement)).toBeNear(minimapBounds.top, 1) expect(realOffsetLeft(quickSettingsElement)).toBeNear(minimapBounds.right, 1) @@ -2103,7 +2107,7 @@ describe("MinimapElement", () => { }) it("toggles the code highlights on the minimap element", () => { - expect(minimapElement.displayCodeHighlights).toBeTruthy() + expect(minimapElement.CanvasDrawer.displayCodeHighlights).toBeTruthy() }) it("requests an update", () => { @@ -2280,14 +2284,14 @@ describe("MinimapElement", () => { describe("on the code highlight item", () => { let [initial] = [] beforeEach(() => { - initial = minimapElement.displayCodeHighlights + initial = minimapElement.CanvasDrawer.displayCodeHighlights atom.commands.dispatch(quickSettingsElement, "core:move-down") atom.commands.dispatch(quickSettingsElement, "core:move-down") atom.commands.dispatch(quickSettingsElement, "core:confirm") }) it("toggles the code highlights on the minimap element", () => { - expect(minimapElement.displayCodeHighlights).toEqual(!initial) + expect(minimapElement.CanvasDrawer.displayCodeHighlights).toEqual(!initial) }) })