Event listeners and dispatch

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