Skip to content

Commit 030e8d6

Browse files
authored
Merge pull request #756 from atom-minimap/import-domstylesreader
2 parents 46974fe + baf6737 commit 030e8d6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/main.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const emitter = new Emitter()
6868
/**
6969
DOMStylesReader cache used for storing token colors
7070
*/
71-
let DOMStylesReaderInstance = null
71+
export let domStylesReader = null
7272

7373
/**
7474
* Activates the minimap package.
@@ -92,7 +92,7 @@ export function activate () {
9292
})
9393

9494
editorsMinimaps = new Map()
95-
DOMStylesReaderInstance = new DOMStylesReader()
95+
domStylesReader = new DOMStylesReader()
9696

9797
subscriptions = new CompositeDisposable()
9898
active = true
@@ -109,8 +109,6 @@ export function activate () {
109109
export function minimapViewProvider (model) {
110110
if (model instanceof Minimap) {
111111
const element = new MinimapElement()
112-
// add DOMStylesReaderInstance
113-
element.DOMStylesReader = DOMStylesReaderInstance;
114112
element.setModel(model)
115113
return element
116114
}
@@ -136,7 +134,7 @@ export function deactivate () {
136134
subscriptionsOfCommands.dispose()
137135
subscriptionsOfCommands = null
138136
editorsMinimaps = undefined
139-
DOMStylesReaderInstance.invalidateDOMStylesCache()
137+
domStylesReader.invalidateDOMStylesCache()
140138
toggled = false
141139
active = false
142140
}
@@ -165,7 +163,7 @@ export function toggle () {
165163
toggled = true
166164
initSubscriptions()
167165
}
168-
DOMStylesReaderInstance.invalidateDOMStylesCache()
166+
domStylesReader.invalidateDOMStylesCache()
169167
}
170168

171169
/**
@@ -373,7 +371,7 @@ function initSubscriptions () {
373371
}),
374372
// empty color cache if the theme changes
375373
atom.themes.onDidChangeActiveThemes(() => {
376-
DOMStylesReaderInstance.invalidateDOMStylesCache()
374+
domStylesReader.invalidateDOMStylesCache()
377375
editorsMinimaps.forEach((minimap) => { atom.views.getView(minimap).requestForcedUpdate() })
378376
}),
379377
treeSitterWarning()

lib/mixins/canvas-drawer.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { escapeRegExp } from 'underscore-plus'
44
import Mixin from 'mixto'
55

66
import * as Main from '../main'
7+
import { domStylesReader } from '../main'
78
import CanvasLayer from '../canvas-layer'
89

910
const SPEC_MODE = atom.inSpecMode()
@@ -28,6 +29,7 @@ export default class CanvasDrawer extends Mixin {
2829
this.drawHighlightDecoration = drawHighlightDecoration
2930
this.drawHighlightOutlineDecoration = drawHighlightOutlineDecoration
3031
this.drawCustomDecoration = drawCustomDecoration
32+
this.DOMStylesReader = domStylesReader
3133
}
3234

3335
/**
@@ -303,7 +305,7 @@ export default class CanvasDrawer extends Mixin {
303305
* @return {string} a CSS color
304306
*/
305307
getDefaultColor (editorElement) {
306-
const color = this.DOMStylesReader.retrieveStyleFromDom(['.editor'], 'color', editorElement, true)
308+
const color = domStylesReader.retrieveStyleFromDom(['.editor'], 'color', editorElement, true)
307309
return transparentize(color, this.textOpacity)
308310
}
309311

@@ -318,7 +320,7 @@ export default class CanvasDrawer extends Mixin {
318320
* @return {string} the CSS color for the provided token
319321
*/
320322
getTokenColor (scopes, editorElement) {
321-
const color = this.DOMStylesReader.retrieveStyleFromDom(scopes, 'color', editorElement, true)
323+
const color = domStylesReader.retrieveStyleFromDom(scopes, 'color', editorElement, true)
322324

323325
return transparentize(color, this.textOpacity)
324326
}
@@ -340,7 +342,7 @@ export default class CanvasDrawer extends Mixin {
340342

341343
if (properties.scope) {
342344
const scopeString = properties.scope.split(oneOrMoreWhiteSpaceRegexp)
343-
return this.DOMStylesReader.retrieveStyleFromDom(scopeString, 'background-color', editorElement, true)
345+
return domStylesReader.retrieveStyleFromDom(scopeString, 'background-color', editorElement, true)
344346
} else {
345347
return this.getDefaultColor(editorElement)
346348
}

0 commit comments

Comments
 (0)