Event listeners and dispatch

Now with a split between commits that just pull in unmodified Gecko code and those that modify it.