mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 1217969 - Highlight the memory tool tab when recording allocations. r=fitzgen
This commit is contained in:
parent
a5c5dae2ae
commit
210dc6fb6c
@ -19,16 +19,39 @@ const Store = require("devtools/client/memory/store");
|
|||||||
*/
|
*/
|
||||||
var gToolbox, gTarget, gFront, gHeapAnalysesClient;
|
var gToolbox, gTarget, gFront, gHeapAnalysesClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Variables set by `initialize()`
|
||||||
|
*/
|
||||||
|
var gStore, unsubscribe, isHighlighted;
|
||||||
|
|
||||||
function initialize () {
|
function initialize () {
|
||||||
return Task.spawn(function*() {
|
return Task.spawn(function*() {
|
||||||
let root = document.querySelector("#app");
|
let root = document.querySelector("#app");
|
||||||
let store = Store();
|
gStore = Store();
|
||||||
let app = createElement(App, { front: gFront, heapWorker: gHeapAnalysesClient });
|
let app = createElement(App, { front: gFront, heapWorker: gHeapAnalysesClient });
|
||||||
let provider = createElement(Provider, { store }, app);
|
let provider = createElement(Provider, { store: gStore }, app);
|
||||||
render(provider, root);
|
render(provider, root);
|
||||||
|
unsubscribe = gStore.subscribe(onStateChange);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy () {
|
function destroy () {
|
||||||
return Task.spawn(function*(){});
|
return Task.spawn(function*(){
|
||||||
|
unsubscribe();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired on any state change, currently only handles toggling
|
||||||
|
* the highlighting of the tool when recording allocations.
|
||||||
|
*/
|
||||||
|
function onStateChange () {
|
||||||
|
let isRecording = gStore.getState().allocations.recording;
|
||||||
|
|
||||||
|
if (isRecording !== isHighlighted) {
|
||||||
|
isRecording ?
|
||||||
|
gToolbox.highlightTool("memory") :
|
||||||
|
gToolbox.unhighlightTool("memory");
|
||||||
|
isHighlighted = isRecording;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user