[Mac] Replace Editing Word with Selected Suggestion from Touch Bar

WebContents::Replace() replaces the current text selection with a given
string. Currently, SuggestedTextTouchBarController replaces the
current user selection when a suggestion is chosen from the touch bar.

SuggestedTextTouchBarController now calculates a range that
encompasses the word in which the cursor resides. If the cursor is not
in or at the end of a word, the range representing the editing word
starts at the cursor position and has length 0.

When a suggestion is chosen from the touch bar, the selection within
the textfield is modified to encompass the word currently being
edited (which may be only a cursor position) and then
WebContents::Replace() is called to replace the selection.

A unit test was written to test that
editingWordFromText:cursorPosition: properly calculates the range
encompassing the current editing word for various combinations of word
and non-word characters.

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