commit | dbef474840afdf0e12809cc47e0166e17fc33978 | [log] [tgz] |
---|---|---|
author | Tessa Nijssen <tnijssen@google.com> | Fri Jun 29 21:02:08 2018 |
committer | Commit Bot <commit-bot@chromium.org> | Fri Jun 29 21:02:08 2018 |
tree | 6722c5c8afb675705f47d661ab8f33d1f7684d35 | |
parent | 18e17a020a415767fab02726de4e83ca9aa262eb [diff] |
Reland [Mac] Get Suggestions from Whole Text and Current Selection Currently, the SuggestedTextTouchBarController generates text suggestions based only text being selected and doesn't take any surrounding text into account. The goal is to generate text suggestions from all the text present in the textfield and the current cursor position, which results in behavior more similar to Safari's text suggestions. First, WebContents::DidChangeTextSelection() and WebContentsObserver::DidChangeTextSelection() were modified to pass in the whole text in the textfield and the current selection range instead of the selected text. The method requestSuggestionsForText: was modified to requestSuggestionsForText:inRange: so that it may receive the full text in the textfield along with the range of the current selection. The WebContentsTextObserver was edited to also observe when a webpage finishes loading. This way, the controller can check whether the cursor is in a textfield before the text selection changes. This is necessary for websites in which a textfield is autofocused. This currently does not account for text that may be in the autofocused textfield, which will be addressed in a later CL. The browser tests for SuggestedTextTouchBarController were updated to reflect the new behavior. TouchBarTest now only checks if a touch bar is created based on whether or not a textfield is focused, as that is the only condition required for the creation of a touch bar. Text selection test now passes a range to -webContentsTextSelectionChanged: and tests that the range is stored properly afterwards. Unnecessary asserts were removed from both tests. The way that tests access the SuggestedTextTouchBarController was also modified to reduce the amount of memory used and make the code cleaner. Now, tests access one global controller rather than creating a new one for every test. Bug: 717553 Change-Id: Ia9a62a1b802976cbc76e2243d60d0a41cd1844cd Reviewed-on: https://chromium-review.googlesource.com/1119363 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@{#571624}
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 .