From 2e083ddb042a44e022bdefc97d7504e126a9a750 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 9 Jan 2016 20:52:47 -0800 Subject: [PATCH] Bug 1217129: Part 1 - Add onDestroyed callback to CustomizableUI widgets. r=gijs --HG-- extra : commitid : TYTQcrdFSA extra : rebase_source : 5ac4b035020ade4fcff810d64d8faab70017af8f --- browser/components/customizableui/CustomizableUI.jsm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index afd6122c213d..fa72f40efaa2 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -2336,6 +2336,7 @@ var CustomizableUIInternal = { this.wrapWidgetEventHandler("onBeforeCreated", widget); this.wrapWidgetEventHandler("onClick", widget); this.wrapWidgetEventHandler("onCreated", widget); + this.wrapWidgetEventHandler("onDestroyed", widget); if (widget.type == "button") { widget.onCommand = typeof aData.onCommand == "function" ? @@ -2439,6 +2440,9 @@ var CustomizableUIInternal = { } } } + if (widgetNode && widget.onDestroyed) { + widget.onDestroyed(window.document); + } } gPalette.delete(aWidgetId); @@ -3172,6 +3176,11 @@ this.CustomizableUI = { * - onCreated(aNode): Attached to all widgets; a function that will be invoked * whenever the widget has a DOM node constructed, passing the * constructed node as an argument. + * - onDestroyed(aDoc): Attached to all non-custom widgets; a function that + * will be invoked after the widget has a DOM node destroyed, + * passing the document from which it was removed. This is + * useful especially for 'view' type widgets that need to + * cleanup after views that were constructed on the fly. * - onCommand(aEvt): Only useful for button widgets; a function that will be * invoked when the user activates the button. * - onClick(aEvt): Attached to all widgets; a function that will be invoked