Followup de40432: fix JS errors in Firefox

Apparently getClientRects() can return an empty array
in Firefox if the element being measured is display: none;
and has never been visible. This seems to happen to the
surface in the media dialog when opened in insertion mode
(i.e. opening the panel the surface isn't in).

Catch this case in getClientSelectionRect() and return null.

Also make sure that the context's position isn't updated when
it isn't visible. The code was trying to do that, but the
visibility check was missing in one place (onSurfacePosition),
causing updateDimensions() to be called on an invisible context
which would then try to position itself against a surface whose
client rects couldn't be measured.

Change-Id: I761b8670091543fc3a6077e936d7872581f628bd
Merge "Followup de40432: fix JS errors in Firefox"