The great image scaling rewrite of 2014

Separate out logic for aspect ratio locked scaling so it can be
shared between ve.ce.ResizableNode and ve.ui.MediaSizeWidget.

Change-Id: I5b4f0f91b8534725130978875a5b4cabb6b98bd2
Merge "The great image scaling rewrite of 2014"