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.

Let me know if you'd like me to split this PR up.

r? @glennw
It wasn't needed. There's no need to reconstruct the flow tree when the window resizes (except in some corner cases involving media queries).