Optimize line width measurements

No full measurement is needed, since most of the time the longest line will
be scrolled out of view, and we're only interested in its length.

Issue #1275