[Mac] Add Offset to TextSuggestionsTouchBarController Text Selection

This is a reland of http://crrev/c/1169597 with @available checks
added to TextSuggestionsTouchBarControllerTest.Offset in browser tests.

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: I83f7b3f381086118212106dff3b0b34ed8be2237
Reviewed-on: https://chromium-review.googlesource.com/1173052
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@{#582726}
13 files changed