Overhaul flow construction with several performance improvements

This is a grab bag of performance improvements that significantly improve style recalculation, layout, and painting on a few static pages.

r? @glennw