Fix a couple of selection issues

In FireFox if an image has no text around it, click on either side of the
image resulting the same selection get returned. focusNode: image,
focusOffset: 0. To workaround it, move the cursor to the next walkable
position when clicking on the right side of an image.

Another corner case is that when click on the right side of an image that has
no text elements, non-FireFox browsers will retrn focusNode: frame,
focusOffset: 1 as the selection. Since this is not a valid cursor
position, move the cursor to the next walkable position after the frame
node.