4

Firefox addon. I'm porting an existing addon to a restartless one. I have a panel with a lot of UI elements (mostly boxes/description and images) in it, and it is very convenient for me to define the panel elements in an XUL overlay file. I will have lots of bloated js code if I don't.

The panel element (parent) itself is created in code dynamically, and then I use loadOverlay, wait for the 'merged' event and then append the panel element's children from the overlayed document. I also make sure that the elements are cleaned up upon a remove.

However, using overlays will most probably won't pass an AMO review. And some of the reasons I think are :

  • In most cases overlay elements will cause problems while removing (eg: toolbar buttons remembering their positions etc.)
  • There are problems with attaching js/css files in an overlay file.
  • loadOverlay is buggy (496320, 330458)

And here are my inferences :

  • loadOverlay() API itself is not deprecated - in fact it is 'not frozen and may change later' - which means possibly it will be use-able in future.
  • The bug that a second overlay load fails, is not applicable in my case, as I don't initialize without an overlay merge.
  • Using static overlay for preference windows etc. is perfectly acceptable as of now.
  • The panel in my case behaves a lot like a preference window (which is brought up on demand and cleaned up upon addon removal)
  • I don't have any js/css attached to the overlay, nor any event listeners for the elements. The overlay is only used to define boxes and description text - nothing more.

So considering these, is it acceptable to use overlays and loadOverlay() for a restartless addon ? If not, is there an alternative ?

nmaier
  • 32,336
  • 5
  • 63
  • 78
user3337744
  • 119
  • 7

1 Answers1

0

About overlays, by checking source code of restartless addon that extend existing addon (like ehh), I see the overlay.xul is auto merged with the existing addon's. So it shouldn't be a problem to use overlay.

  • 1
    Hi, Thanks. Using overlays are allowed for preferences windows etc. Also I believe they're are okay too as long as they are cleaned up 'properly' in a restartless way. But they're not generally recommended from the response I got from #amo-editors and #extdev channels. Especially `loadOverlay` is not recommended due to bugs. I ended up rewriting the whole UI in js. I really wanted to know if there were any alternatives than writing entire UI in js. – user3337744 Apr 07 '14 at 18:33