commit | b91e80714f58d76d9ad55cfd9d78b8e37aad5d57 | [log] [tgz] |
---|---|---|
author | Tessa Nijssen <tnijssen@google.com> | Fri Jul 13 18:53:49 2018 |
committer | Commit Bot <commit-bot@chromium.org> | Fri Jul 13 18:53:49 2018 |
tree | 526ffd846113a4aa55b349740ac466b506776b98 | |
parent | 73221c336f865b79a8738f12f623d11568e28b0f [diff] |
Reland [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. Some parameter types were changed to reduce the number of conversions from base::string16 to NSString and vice versa. Previously, WebContentsTextObserver::DidChangeTextSelection() took a base::string16 as a parameter. It would then convert that input to NSString and pass it to webContentsTextSelectionChanged:range: which would then call editingWordRangeFromText:cursorPosition: which would then convert the NSString back to a base::string16. The call to BreakIterator::Init() was moved out of a DCHECK because DCHECKs are stripped for release builds and the call to Init() should not be removed. Bug: 717553 Change-Id: I367093e13129609c7238bdb9125bbd69a3910f0c Reviewed-on: https://chromium-review.googlesource.com/1130232 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@{#575000}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .