Skip to content

Commit e0ad963

Browse files
committed
overlays for profile lines
1 parent 267b73a commit e0ad963

File tree

5 files changed

+41
-18
lines changed

5 files changed

+41
-18
lines changed

lib/debugger/stepper-view.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class StepperView
8484

8585
@view.parentElement.style.maxWidth = (window.innerWidth - RESULT_OFFSET - 10 - this.left) + 'px'
8686
@view.style.maxWidth = w + 'px'
87-
setTimeout((() => process.nextTick(() => window.requestAnimationFrame(@widthListener))), 15*1000/60)
87+
setTimeout((() => process.nextTick(() => window.requestAnimationFrame(@widthListener))), 300)
8888

8989
window.requestAnimationFrame(@widthListener)
9090

lib/editor/highlights.coffee

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,24 @@ module.exports =
2424
watch.dispose()
2525
m.destroy() for m in markers
2626

27+
profileLineView: (ed, count) ->
28+
v = document.createElement 'div'
29+
v.classList.add 'ink-profile-line'
30+
v.style.width = count*ed.preferredLineLength/2 + 'em'
31+
v
32+
2733
profileLines: (ls) ->
2834
markers = []
2935
watch = @observeLines ls, (ed, {line, count, classes}) =>
30-
m = ed.markBufferRange [[line, 0], [line, 1+Math.round(count*ed.preferredLineLength)]],
31-
invalidate: 'touch'
36+
m = ed.markBufferRange [[line, 0], [line, 0]],
37+
invalidate: 'never'
3238
markers.push m
3339
ed.decorateMarker m,
34-
type: 'highlight'
40+
type: 'overlay'
41+
item: @profileLineView ed, count
3542
class: "ink-profile-line #{classes.join(' ')}"
43+
avoidOverflow: false
44+
3645
destroy: =>
3746
watch.dispose()
3847
m.destroy() for m in markers

lib/editor/result-view.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ export default class ResultView {
163163
}
164164

165165
// only read from the DOM
166-
decideUpdateWidth (edRect) {
166+
decideUpdateWidth (edRect, winWidth) {
167+
this.edRect = edRect
168+
this.winWidth = winWidth
167169
this.isVisible = false
168170
this.left = 0
169171
this.shouldRedraw = false
@@ -179,7 +181,7 @@ export default class ResultView {
179181
}
180182

181183
// only write to the DOM
182-
updateWidth (edRect, winWidth) {
184+
updateWidth () {
183185
if (!!this.isVisible || this.model.expanded) {
184186
this.getView().style.visibility = 'visible'
185187
this.getView().style.pointerEvents = 'auto'
@@ -188,16 +190,16 @@ export default class ResultView {
188190
this.getView().style.pointerEvents = 'none'
189191
}
190192
if (!!this.isVisible && (this.shouldRedraw || this.modelUpdated)) {
191-
let w = edRect.right - RESULT_OFFSET - 10 - this.left
193+
let w = this.edRect.right - RESULT_OFFSET - 10 - this.left
192194
if (w < MIN_RESULT_WIDTH) w = MIN_RESULT_WIDTH
193-
if (edRect.width > 0 && this.left + RESULT_OFFSET + w > edRect.right) {
194-
this.getView().style.left = (edRect.right - w - 10 - this.left) + 'px'
195+
if (this.edRect.width > 0 && this.left + RESULT_OFFSET + w > this.edRect.right) {
196+
this.getView().style.left = (this.edRect.right - w - 10 - this.left) + 'px'
195197
this.getView().style.opacity = 0.75
196198
} else {
197199
this.getView().style.left = RESULT_OFFSET + 'px'
198200
this.getView().style.opacity = 1.0
199201
}
200-
this.getView().parentElement.style.maxWidth = (winWidth - RESULT_OFFSET - 10 - this.left) + 'px'
202+
this.getView().parentElement.style.maxWidth = (this.winWidth - RESULT_OFFSET - 10 - this.left) + 'px'
201203
this.getView().style.maxWidth = w + 'px'
202204
this.modelUpdated = false
203205
}

lib/editor/result.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ export default class Result {
256256
}))
257257

258258
let listener = () => {
259+
let allresults = []
259260
for (let edid in layers) {
260261
let res = layers[edid].getMarkers().map((m) => m.result)
261262
res = res.filter((r) => r.type === 'inline')
@@ -267,16 +268,19 @@ export default class Result {
267268
}
268269
let winWidth = window.innerWidth;
269270

270-
res.forEach((r) => r.view.decideUpdateWidth(rect))
271-
272-
// DOM writes
273-
res.forEach((r) => r.view.updateWidth(rect, winWidth))
271+
res.forEach((r) => r.view.decideUpdateWidth(rect, winWidth))
272+
allresults.push(...res)
274273
}
275274

275+
// DOM writes
276+
allresults.forEach((r) => r.view.updateWidth())
277+
278+
276279
setTimeout(() => {
277280
process.nextTick(() => window.requestAnimationFrame(listener))
278-
}, 500)
281+
}, 400)
279282
}
283+
280284
window.requestAnimationFrame(listener)
281285
return
282286
}
@@ -288,5 +292,5 @@ export default class Result {
288292

289293
// stopgap for https://github.com/atom/atom/issues/16454
290294
function uniqueEditorID(editor) {
291-
return editor.id + '_' + editor.buffer.id
295+
return editor.id
292296
}

styles/ink.less

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,16 @@
135135
}
136136
}
137137

138-
.ink-profile-line {
139-
background: fade(@background-color-info, 20%);
138+
atom-overlay.ink-profile-overlay{
139+
pointer-events: none;
140+
z-index: 0 !important;
141+
.ink-profile-line {
142+
position: relative;
143+
height: 1.5em;
144+
top: -1.5em;
145+
border-radius: 0px 5px 5px 0px;
146+
background: fade(@background-color-info, 20%);
147+
}
140148
}
141149

142150
atom-text-editor {

0 commit comments

Comments
 (0)