Precompute selection regions for all lines

This is easer to reason about and probably more efficient than computing
everything on a per-line basis.