[LayoutNG] Adjust BoxInfo::item_index when items are removed

When NGInlineItemsBuilder removed an item, it needs to adjust
BoxInfo::item_index. This patch fixes it.

This was revealed in crrev.com/c/1333588, tests will fail
with the CL without this fix.

Bug: 636993
Change-Id: I7a996e358c0daa8e6c7aa1b5227e4027fe0295bd
Reviewed-on: https://chromium-review.googlesource.com/c/1337210
Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608266}
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_items_builder.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_items_builder.cc
index 931780b0..ca511fb 100644
--- a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_items_builder.cc
+++ b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_items_builder.cc
@@ -774,6 +774,10 @@
     wtf_size_t index =
         static_cast<wtf_size_t>(std::distance(items_->begin(), item));
     items_->EraseAt(index);
+    for (BoxInfo& box : boxes_) {
+      if (box.item_index >= index)
+        --box.item_index;
+    }
     if (index == items_->size())
       return;
     // Re-compute |item| because |EraseAt| may have reallocated the buffer.