Misc SDL fixes

In addition to the changes in the commit message, I also converted the various document event handlers over to using addEventListener as opposed to assigning directly to the on<event> property.

While I'm not relying on this anymore, I believe at the time I was experimenting with some event binding in my shell that I didn't want to be inadvertently hulk-smashed by the SDL layer's event binding.