Try orienting popup the other way if offset pushes it out of bounds

orientAboutObject() currently determines whether the popup should align
its left side with the icon or the right side. However, after
determining this, there is an offset to ensure the popup lines up with
the icon as expected, which might push it out of bounds. In that case,
we fallback to centering the popup. However, there might be plenty of
room on the other side, so we should just align the other direction
instead. Updated the logic to do that by first trying to align left
(in LTR) or right (in RTL), then trying again with the other alignment
if it doesn't fit after all x calculations are made.

Bug: 150644839
Change-Id: I219dae331bf790e461d91394ffe025d40ec54c9b
1 file changed