Improve performance calculating width

Measures each element on the first pass to stop repeated calls to
calculate_width interacting with the page. Element widths are stored in an array of hashes along with their visibility.