Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Issue 2345183002: Views: Draw Textfield selected text in gray when top-level Widget loses focus.

Created:
4 years, 3 months ago by Patti Lor
Modified:
4 years ago
Reviewers:
tapted, msw, groshaft867
CC:
chromium-reviews, tfarina, James Su, shuchen+watch_chromium.org, yusukes+watch_chromium.org, nona+watch_chromium.org, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Views: Draw Textfield selected text in gray when top-level Widget loses focus. When a views::Textfield was the last focused View before moving focus off of the top-level views::Widget they belong to, continue to draw the text selection. Currently the selection looks like it disappears when focus is moved away, which can be confusing. In order to do this, a new FocusChangeListener method OnFocusManagerDestroying was added in order to handle inconsistent destruction order on Mac vs Windows/Linux. Note this does not work for the Omnibox. BUG=645338 TEST=(If testing on Mac, turn on #mac-views-webui-dialogs.) Type some text into a Textfield in the HTTP authentication dialog, highlight it, and move focus to a different app or to the desktop. The text selection just made should still be visible (possibly in a different color). The selected text should also be draggable with the mouse even if the Textfield doesn't have focus.

Patch Set 1 #

Patch Set 2 : Fix up diff & add colors to Windows/Mac. #

Total comments: 8

Patch Set 3 : Refactor to use FocusChangeListener, avoid ClearSelection() in OnBlur(). #

Patch Set 4 : Rebase. #

Patch Set 5 : Fix NativeThemeAura, NativeThemeChanged, and OnMouseDragged. #

Patch Set 6 : Avoid DCHECK with number of observers. #

Patch Set 7 : Fix focus changing to other Views. #

Total comments: 12

Patch Set 8 : Review comments, split out bug fix for 331038. #

Patch Set 9 : Fix tests failing on TYPE_CONTROL Widgets & method for Windows colors. #

Patch Set 10 : Fix DCHECK error from Widgets being deleted with Textfields still listening to their FocusManager. #

Patch Set 11 : Re-add missing Windows fix, revert accidental comment change. #

Patch Set 12 : Fix TextfieldTest.DestroyingTextfieldFromOnKeyEvent. #

Patch Set 13 : Get rid of debugging things, use hashdefine for OnFocusManagerDestroying Textfield code. #

Patch Set 14 : Fix up colors for Linux. #

Total comments: 11

Patch Set 15 : Review comments. #

Patch Set 16 : Get rid of OnFocusManagerDestroying() & fix tests by closing the Widget manually. #

Patch Set 17 : Don't use unique_ptr for Textfields inside Widgets - destruction handled by Widget. #

Patch Set 18 : Fix Windows. #

Patch Set 19 : Rebase. #

Total comments: 11

Patch Set 20 : Review comments. #

Patch Set 21 : Rebase. #

Patch Set 22 : Fix rebase. #

Total comments: 5

Patch Set 23 : DCHECK no focus manager at destruction, add NativeViewHierarchyChanged. #

Patch Set 24 : Flip if. #

Patch Set 25 : Fix DCHECKs. #

Total comments: 15

Patch Set 26 : Review comments. #

Total comments: 6

Patch Set 27 : Rebase. #

Patch Set 28 : Fix lifetime issues with BorderView's widget_ and address review comments. #

Total comments: 25

Patch Set 29 : Refactor to use SelectionController(Delegate). Unfinished! #

Unified diffs Side-by-side diffs Delta from patch set Stats (+246 lines, -64 lines) Patch
M chrome/browser/ui/libgtkui/native_theme_gtk.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +1 line, -5 lines 0 comments Download
M ui/gfx/render_text.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +11 lines, -6 lines 0 comments Download
M ui/gfx/render_text.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 3 chunks +6 lines, -3 lines 0 comments Download
M ui/native_theme/common_theme.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +2 lines, -0 lines 0 comments Download
M ui/native_theme/native_theme.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +1 line, -0 lines 0 comments Download
M ui/native_theme/native_theme_dark_aura.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +1 line, -0 lines 0 comments Download
M ui/native_theme/native_theme_mac.mm View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +2 lines, -0 lines 0 comments Download
M ui/native_theme/native_theme_win.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +4 lines, -0 lines 0 comments Download
M ui/native_theme/native_theme_win.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 4 chunks +9 lines, -4 lines 0 comments Download
M ui/views/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/controls/label.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +4 lines, -0 lines 0 comments Download
M ui/views/controls/label.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +20 lines, -2 lines 0 comments Download
M ui/views/controls/textfield/textfield.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 4 chunks +13 lines, -7 lines 0 comments Download
M ui/views/controls/textfield/textfield.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 6 chunks +41 lines, -19 lines 0 comments Download
M ui/views/controls/textfield/textfield_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +5 lines, -0 lines 0 comments Download
M ui/views/focus/focus_traversal_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +11 lines, -14 lines 0 comments Download
M ui/views/selection_controller_delegate.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +45 lines, -2 lines 0 comments Download
A ui/views/selection_controller_delegate.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 chunk +67 lines, -0 lines 0 comments Download
M ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 176 (143 generated)
Patti Lor
Hi Trent, PTAL at this WIP. I'm not sure about the implementation for this - ...
4 years, 3 months ago (2016-09-19 05:27:13 UTC) #3
tapted
https://codereview.chromium.org/2345183002/diff/20001/ui/gfx/render_text.cc File ui/gfx/render_text.cc (right): https://codereview.chromium.org/2345183002/diff/20001/ui/gfx/render_text.cc#newcode58 ui/gfx/render_text.cc:58: const SkColor kDefaultUnfocusedSelectionBackgroundColor = 0xffdcdcdc; Will this be similar ...
4 years, 3 months ago (2016-09-20 06:57:55 UTC) #4
groshaft867
lgtm
4 years, 2 months ago (2016-10-11 04:44:08 UTC) #23
groshaft867
lgtm lgtm
4 years, 2 months ago (2016-10-11 04:44:08 UTC) #25
groshaft867
lgtm lgtm
4 years, 2 months ago (2016-10-11 04:44:10 UTC) #26
groshaft867
4 years, 2 months ago (2016-10-11 05:04:40 UTC) #27
groshaft867
lgtm
4 years, 2 months ago (2016-10-11 05:04:41 UTC) #28
groshaft867
lgtm lgtm
4 years, 2 months ago (2016-10-11 05:04:42 UTC) #29
Patti Lor
Refactored! As discussed offline there is still a bug in this though - see the ...
4 years, 2 months ago (2016-10-12 05:53:00 UTC) #39
tapted
Is it possible to split out the fix for 331038? We should land that separately. ...
4 years, 2 months ago (2016-10-13 06:21:35 UTC) #42
Patti Lor
Hi Trent, PTAL. Thanks! https://codereview.chromium.org/2345183002/diff/130001/ui/native_theme/native_theme_win.cc File ui/native_theme/native_theme_win.cc (right): https://codereview.chromium.org/2345183002/diff/130001/ui/native_theme/native_theme_win.cc#newcode568 ui/native_theme/native_theme_win.cc:568: : COLOR_BTNFACE]; On 2016/10/13 06:21:35, ...
4 years, 2 months ago (2016-10-24 02:43:18 UTC) #78
tapted
Neat - I think this is on the right track. I need to take a ...
4 years, 2 months ago (2016-10-24 03:11:20 UTC) #79
tapted
https://codereview.chromium.org/2345183002/diff/290001/ui/native_theme/native_theme_win.cc File ui/native_theme/native_theme_win.cc (right): https://codereview.chromium.org/2345183002/diff/290001/ui/native_theme/native_theme_win.cc#newcode149 ui/native_theme/native_theme_win.cc:149: SkColor GetUnfocusedSelectionBackgroundColor( Can we make this a (const) member ...
4 years, 2 months ago (2016-10-24 06:04:16 UTC) #80
Patti Lor
Hi Trent, PTAL & thanks for the help! I've updated the CL description to say ...
4 years, 1 month ago (2016-10-27 00:17:27 UTC) #101
tapted
https://codereview.chromium.org/2345183002/diff/430001/ui/views/controls/textfield/textfield.cc File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2345183002/diff/430001/ui/views/controls/textfield/textfield.cc#newcode939 ui/views/controls/textfield/textfield.cc:939: // focus, so don't bother listening if there is ...
4 years, 1 month ago (2016-10-27 00:53:42 UTC) #102
tapted
https://codereview.chromium.org/2345183002/diff/430001/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc File ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc (right): https://codereview.chromium.org/2345183002/diff/430001/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc#newcode274 ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc:274: } On 2016/10/27 00:53:42, tapted wrote: > Something like ...
4 years, 1 month ago (2016-10-27 00:54:34 UTC) #103
Patti Lor
Thanks Trent, PTAL. https://codereview.chromium.org/2345183002/diff/430001/ui/views/controls/textfield/textfield.cc File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2345183002/diff/430001/ui/views/controls/textfield/textfield.cc#newcode939 ui/views/controls/textfield/textfield.cc:939: // focus, so don't bother listening ...
4 years, 1 month ago (2016-10-30 23:26:04 UTC) #117
tapted
https://codereview.chromium.org/2345183002/diff/430001/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc File ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc (right): https://codereview.chromium.org/2345183002/diff/430001/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc#newcode274 ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc:274: } On 2016/10/30 23:26:04, Patti Lor wrote: > On ...
4 years, 1 month ago (2016-10-31 00:30:25 UTC) #118
Patti Lor
Hi Trent, thanks for the review! PTAL. https://codereview.chromium.org/2345183002/diff/430001/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc File ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc (right): https://codereview.chromium.org/2345183002/diff/430001/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc#newcode274 ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc:274: } On ...
4 years, 1 month ago (2016-11-02 03:19:48 UTC) #144
tapted
lgtm with some tweaks - let's ask OWNERS. I think I'd prefer ~Textfield() to call ...
4 years, 1 month ago (2016-11-02 03:45:06 UTC) #145
tapted
ooer we should add some test coverage for this too. But let's consult OWNERS to ...
4 years, 1 month ago (2016-11-02 03:59:15 UTC) #146
Patti Lor
Hey Trent, thanks for the lgtm - I added a #ifdef + comment in focus_traversal_unittest.cc ...
4 years, 1 month ago (2016-11-07 05:34:27 UTC) #156
tapted
The #ifdef doesn't look right - there might be a bug. Do you have an ...
4 years, 1 month ago (2016-11-07 06:14:50 UTC) #157
Patti Lor
Hi Trent, thanks for the help offline. The changes seem to work on Linux fine ...
4 years, 1 month ago (2016-11-08 01:47:31 UTC) #162
tapted
looks good - let's send to msw - he knows textfield and rendertext well. It ...
4 years, 1 month ago (2016-11-08 02:06:11 UTC) #163
Patti Lor
Hi msw, PTAL at the approach taken here. I'll add tests if you think this ...
4 years, 1 month ago (2016-11-08 04:00:27 UTC) #165
tapted
https://codereview.chromium.org/2345183002/diff/710001/ui/views/focus/focus_traversal_unittest.cc File ui/views/focus/focus_traversal_unittest.cc (right): https://codereview.chromium.org/2345183002/diff/710001/ui/views/focus/focus_traversal_unittest.cc#newcode173 ui/views/focus/focus_traversal_unittest.cc:173: std::unique_ptr<Widget> widget_; On 2016/11/08 04:00:27, Patti Lor wrote: > ...
4 years, 1 month ago (2016-11-08 23:35:19 UTC) #166
msw
https://codereview.chromium.org/2345183002/diff/710001/ui/gfx/render_text.cc File ui/gfx/render_text.cc (right): https://codereview.chromium.org/2345183002/diff/710001/ui/gfx/render_text.cc#newcode1203 ui/gfx/render_text.cc:1203: if (!selection().is_empty() && focused()) { Shouldn't this check also ...
4 years, 1 month ago (2016-11-09 02:08:53 UTC) #167
msw
A couple more comments. Also, can you post some screenshots of unfocused selections in a ...
4 years, 1 month ago (2016-11-09 02:14:55 UTC) #168
Patti Lor
Hi msw@, thanks for your review - just posting a reply to two of your ...
4 years, 1 month ago (2016-11-10 07:29:09 UTC) #169
msw
https://codereview.chromium.org/2345183002/diff/710001/ui/views/focus/focus_traversal_unittest.cc File ui/views/focus/focus_traversal_unittest.cc (right): https://codereview.chromium.org/2345183002/diff/710001/ui/views/focus/focus_traversal_unittest.cc#newcode173 ui/views/focus/focus_traversal_unittest.cc:173: std::unique_ptr<Widget> widget_; On 2016/11/10 07:29:09, Patti Lor wrote: > ...
4 years, 1 month ago (2016-11-10 18:45:01 UTC) #170
Patti Lor
Thanks for the clarification! https://codereview.chromium.org/2345183002/diff/710001/ui/views/focus/focus_traversal_unittest.cc File ui/views/focus/focus_traversal_unittest.cc (right): https://codereview.chromium.org/2345183002/diff/710001/ui/views/focus/focus_traversal_unittest.cc#newcode173 ui/views/focus/focus_traversal_unittest.cc:173: std::unique_ptr<Widget> widget_; On 2016/11/10 18:45:01, ...
4 years, 1 month ago (2016-11-10 23:37:48 UTC) #171
tapted
4 years, 1 month ago (2016-11-11 00:10:39 UTC) #172
(just a drive-by comment)

https://codereview.chromium.org/2345183002/diff/710001/ui/views/controls/text...
File ui/views/controls/textfield/textfield.cc (right):

https://codereview.chromium.org/2345183002/diff/710001/ui/views/controls/text...
ui/views/controls/textfield/textfield.cc:1098: void
Textfield::OnWillChangeFocus(View* focus_before, View* focus_after) {
On 2016/11/09 02:08:53, msw wrote:
> It's really unfortunate that we can't do this via OnFocus/OnBlur... Why was it
> determined that we shouldn't paint unfocused selections when the focus is
> transferred to another view in the widget?

I think this would be inconsistent with the WebContents. Also the "Graphite"
option is a popular theme on Mac, which gives an (almost?) identical gray color
to unfocused selections (i.e. instead of Aqua/blue). This would make it almost
impossible to tell what textfield has focus based on the selection highlight.

Powered by Google App Engine
This is Rietveld 408576698