Event listeners and dispatch

A lot of the changes here are adding bindings support for callback objects. Apologies; the majority of it is either copied wholesale from Gecko or ported in a straightforward manner.