[LayoutNG] Add shrink-to-fit caching optimization.

We can detect if an element was sized to its min-content by seeing if
the available inline-size given in the first layout pass is smaller
than the inline-size of the fragment.

We can therefore skip layout if the new available inline-size is also
smaller than the fragment.

Likewise we can detect if an element was sized to its max-content by
seeing if the available inline-size given in the first layout pass is
larger than the inline-size of the fragment.

We also can therefore skip layout if the new available inline-size is
also larger than the fragment.

This has a suprising effect of the desktop loading benchmarks of ~3-4%.
(I ran them multiple times b/c i didn't believe it).

This also speeds up a microbenchmark testing for this kind of
optimization by a lot.

Bug: 635619
Change-Id: Ie209a18bd0027fde0e34f45eaff58339aea9227f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1481600
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#640775}
4 files changed