Bug 1382581 - Adapt webaudioeditor code to the EventEmitter change in devtools/client/framework; r=sole.

MozReview-Commit-ID: 1lmzZZSyO7c

--HG--
extra : rebase_source : c7c7ad935358ad50d4fbb93b95ee824f5f8b5a5d
This commit is contained in:
Nicolas Chevobbe 2018-03-14 18:16:28 +01:00
parent 22c45c6645
commit 9f6614f23d

View File

@ -44,11 +44,10 @@ var WebAudioEditorController = {
* Listen for events emitted by the current tab target. * Listen for events emitted by the current tab target.
*/ */
async initialize() { async initialize() {
this._onTabNavigated = this._onTabNavigated.bind(this); this._onTabWillNavigate = this._onTabWillNavigate.bind(this);
this._onThemeChange = this._onThemeChange.bind(this); this._onThemeChange = this._onThemeChange.bind(this);
gTarget.on("will-navigate", this._onTabNavigated); gTarget.on("will-navigate", this._onTabWillNavigate);
gTarget.on("navigate", this._onTabNavigated);
gFront.on("start-context", this._onStartContext); gFront.on("start-context", this._onStartContext);
gFront.on("create-node", this._onCreateNode); gFront.on("create-node", this._onCreateNode);
gFront.on("connect-node", this._onConnectNode); gFront.on("connect-node", this._onConnectNode);
@ -85,8 +84,7 @@ var WebAudioEditorController = {
* Remove events emitted by the current tab target. * Remove events emitted by the current tab target.
*/ */
destroy: function () { destroy: function () {
gTarget.off("will-navigate", this._onTabNavigated); gTarget.off("will-navigate", this._onTabWillNavigate);
gTarget.off("navigate", this._onTabNavigated);
gFront.off("start-context", this._onStartContext); gFront.off("start-context", this._onStartContext);
gFront.off("create-node", this._onCreateNode); gFront.off("create-node", this._onCreateNode);
gFront.off("connect-node", this._onConnectNode); gFront.off("connect-node", this._onConnectNode);
@ -142,37 +140,27 @@ var WebAudioEditorController = {
/** /**
* Called for each location change in the debugged tab. * Called for each location change in the debugged tab.
*/ */
async _onTabNavigated(event, {isFrameSwitching}) { _onTabWillNavigate: function({isFrameSwitching}) {
switch (event) { // Clear out current UI.
case "will-navigate": { this.reset();
// Clear out current UI.
this.reset();
// When switching to an iframe, ensure displaying the reload button. // When switching to an iframe, ensure displaying the reload button.
// As the document has already been loaded without being hooked. // As the document has already been loaded without being hooked.
if (isFrameSwitching) { if (isFrameSwitching) {
$("#reload-notice").hidden = false; $("#reload-notice").hidden = false;
$("#waiting-notice").hidden = true; $("#waiting-notice").hidden = true;
} else { } else {
// Otherwise, we are loading a new top level document, // Otherwise, we are loading a new top level document,
// so we don't need to reload anymore and should receive // so we don't need to reload anymore and should receive
// new node events. // new node events.
$("#reload-notice").hidden = true; $("#reload-notice").hidden = true;
$("#waiting-notice").hidden = false; $("#waiting-notice").hidden = false;
}
// Clear out stored audio nodes
gAudioNodes.reset();
window.emit(EVENTS.UI_RESET);
break;
}
case "navigate": {
// TODO Case of bfcache, needs investigating
// bug 994250
break;
}
} }
// Clear out stored audio nodes
gAudioNodes.reset();
window.emit(EVENTS.UI_RESET);
}, },
/** /**