[LayoutNG] Remove trailing spaces of blocks in phase 1

This patch changes NGInlineItemsBuilder to remove trailing
spaces at the end of blocks.

It used to do so, but stopped in https://crrev.com/c/1022191
because doing so reduces opportunities to re-use NGInlineItem
and increases shaping when contents are added.

However, for fonts that has kerning before a space character,
this change increased re-shaping every block end. Given line
breaking is more often ran than adding contents dynamically,
this turned out to be not a good trade off. We could re-shape
only end-part in RestoreTrailingCollapsibleSpace to achieve
the originally intended optimizations.

This speeds up blink_perf tests on Windows by ~10%.

This patch also fixes a few cases where space collapsing is
incorrect when items are re-used.

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