Maintain two-sided selections when transforming

"Real" selections, not just cursor position.
If multiple regions are selected, only the first remains. We could
support more, but it's not worth the effort right now. Chrome doesn't
even let me make such selections, though Firefox does.

Two different markers are inserted ('\x00' and '\x01') to mark the
endpoints, so the endpoints are transformed. For example, someone can
insert new text in the middle of your selection, which transforms
appropriately.
(For basic cursor selections, we now use '\x00' too; an improvement on
'\xff' since folks might want to type ÿ at some point)

I discovered that the (old) version of Safari that I can run has a bug
with Node.contains, so I'm just dropping support.  We could implement a
workaround, but ehh...

Also committed some debug logging which I've been using for a while.