Make popups position themselves correctly when dimensions change

If you had a PopupButtonWidget near the edge of a container, opening
the popup for the first time could cause a vertical scrollbar to
appear, which could push the button to the next line, which would
totally mess up the sizing computations.

Reorder operations in PopupWidget#updateDimensions so the width
and height are set before any measurements are taken. This way
if the width and height changes influence the measurements
(e.g. due to scrollbars), we don't end up using outdated measurements.

Bonus:
* Reorder and comment updateDimensions() to make it more understandable
* Make $container default to nearest scrollable container, not <body>
* Correct lies in getClosestScrollableContainer docs

Change-Id: I1db4f3af1cbccf644d9a7928380d15bf451bcc78
Merge "Make popups position themselves correctly when dimensions change"