[LayoutNG] Estimate the capacity of NGInlineItemsBuilder

Currently, 50 to 60% of CollectInlines are spent in
ExpandCapacity to reallocate the vector buffer. This patch
makes rough estimation from the number of direct children
to reduce the number of reallocations.

Currently, slow tests such as storage/indexdb/* creates
more than 1,000 items by appending the test results in
<span></span><br> structure. This patch reduces vector
allocation in such cases to once or twice.

Bug: 636993
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I2b5b1462dc59091cc534a2f143b54567d31b863a
Reviewed-on: https://chromium-review.googlesource.com/1155268
Reviewed-by: Emil A Eklund <eae@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579486}
1 file changed