Avoid scrollbar construction/destruction thrashing during flex layout.

BUG=528940
R=skobes@chromium.org,pdr@chromium.org

***
Re-landing this change after it was reverted; original patch:

https://codereview.chromium.org/1357423007
***

Before this change:

https://codereview.chromium.org/1295933003

... blocks with overflow:auto would delay updating their scrollbars until
after all flex layout was finished.  After the change, scrollbar info is
updated immediately during the course of layout.  Flex items may run
layout multiple times during flex layout; if a flex item has auto scrollbars,
it may create and destroy its scrollbars multiple times.

Aside from being a performance problem, this can cause WebScrollbarThemePainter
to point to a stale Scrollbar object.  If a flex item has scrollbars prior to
layout; then the flex item destroys and creates scrollbars during layout; and
at the end of layout, it still has a scrollbar; then
CompositedDeprecatedPaintLayerMapping::updateOverflowControlsLayers will not
update the WebScrollbarThemePainter with the final Scrollbar object.

We could fix this in updateOverflowControlsLayers, but that wouldn't address
the performance issue of needlessly creating and destroying scrollbars during
flex layout.  This patch avoids destroying scrollbars that are no longer
deemed necessary, until after all flexing is finished.

TBR=skobes,haraken,keishi

Review URL: https://codereview.chromium.org/1373413002

Cr-Commit-Position: refs/heads/master@{#351472}
2 files changed