@pcwalton
Refactor a bit and compute vertical margins as well.
0b91af3