[Mac] Add Offset to TextSuggestionsTouchBarController Text Selection

When the text surrounding the current selection gets too long, only
part of it is received by TextSuggestionsTouchBarController. The
location of the received text within the total block of text is
denoted by an offset. Previously, TextSuggestionsTouchBarController
did not take this offset into account, causing crashes when the
selection range was past the end of the received text.

The offset is passed along with the text and selection range. The
selection range within the received text is calculated using the
offset and received selection range. The editing word range is stored
both as the range within the received text and the range within the
total text for checking when to ignore text selection updates.

RenderWidgetHostView::GetOffsetForSurroundingText() was added to
retrieve the offset on WebContents update.

Browser tests were modified to account for the new offset parameter. A
new browser test, TextSuggestionsTouchBarController.Offset, was added
to test that the controller properly handles offsets.

Bug: 717553
Change-Id: I6dce1405fd5c115ca6ddfdbe4157faf75ccc3a6c
Reviewed-on: https://chromium-review.googlesource.com/1169597
Commit-Queue: Tessa Nijssen <tnijssen@google.com>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Sarah Chan <spqchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582205}
13 files changed