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

Issue 2371113003: Do not give instant focus if a view's toplevelwidget is not active (Closed)

Created:
4 years, 2 months ago by Qiang(Joe) Xu
Modified:
3 years, 10 months ago
Reviewers:
oshima, sky
CC:
chromium-reviews, extensions-reviews_chromium.org, awdf+watch_chromium.org, mlamouri+watch-geolocation_chromium.org, aboxhall+watch_chromium.org, tfarina, mlamouri+watch-notifications_chromium.org, nektar+watch_chromium.org, chromium-apps-reviews_chromium.org, yuzo+watch_chromium.org, Peter Beverloo, je_julie, dmazzoni+watch_chromium.org, dtseng+watch_chromium.org, Michael van Ouwerkerk, kalyank
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Do not give instant focus if a view's toplevelwidget is not active If the top level widget isn't active during setting focus view, we store the focused view and then attempt to activate the widget. If activation succeeds view will be focused. If activation fails |view| will be focused the next time the widget is made active. Based on this rule, a set of unittests related are modified. This is a following up CL for 2113163002 as there are already too many patches there. BUG=621791 BUG=650776 BUG=152938 TEST=add an interactive_ui_test, NativeWidgetAuraTest.NonActiveWindowRequestImeFocus Committed: https://crrev.com/5c16e0e849526c1c627e08a05351ab38a9cfbcf1 Cr-Commit-Position: refs/heads/master@{#426905}

Patch Set 1 #

Patch Set 2 : old issue base #

Patch Set 3 : new patch #

Total comments: 2

Patch Set 4 : add ClearNativeFocus() #

Total comments: 2

Patch Set 5 : replace ClearNativeFocus with widget_->Activate() #

Total comments: 2

Patch Set 6 : rebase #

Patch Set 7 : fix test failures #

Total comments: 1

Patch Set 8 : rebase #

Patch Set 9 : based on sky's comments #

Total comments: 2

Patch Set 10 : move toolbar_view_browsertest.cc #

Patch Set 11 : rebase #

Patch Set 12 : using WidgetActivationWaiter #

Patch Set 13 : nit #

Total comments: 10

Patch Set 14 : rebase #

Patch Set 15 : move added test to widget_interactive_uitest #

Total comments: 2

Patch Set 16 : rebase #

Patch Set 17 : move test to native_widget_aura_interactive_uitest.cc #

Total comments: 6

Patch Set 18 : based on comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+281 lines, -138 lines) Patch
M ash/common/system/tray/tray_details_view_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/ui/ash/accessibility/ax_tree_source_aura_unittest.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_ash_unittest.cc View 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/ui/views/toolbar/toolbar_view_browsertest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +0 lines, -127 lines 0 comments Download
M chrome/browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +115 lines, -1 line 0 comments Download
M chrome/test/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 chunks +4 lines, -1 line 0 comments Download
M ui/views/controls/combobox/combobox_unittest.cc View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/focus/focus_manager.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +15 lines, -0 lines 0 comments Download
M ui/views/mus/native_widget_mus.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -3 lines 0 comments Download
M ui/views/view_targeter_unittest.cc View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/widget/desktop_aura/desktop_native_widget_aura.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +6 lines, -4 lines 0 comments Download
A ui/views/widget/native_widget_aura_interactive_uitest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +130 lines, -0 lines 0 comments Download
M ui/views/widget/root_view_unittest.cc View 1 2 3 4 5 6 2 chunks +2 lines, -0 lines 0 comments Download

Messages

Total messages: 114 (69 generated)
Qiang(Joe) Xu
Hi oshima, sky, this is a following up CL because the original one is a ...
4 years, 2 months ago (2016-09-27 23:33:17 UTC) #8
oshima
On 2016/09/27 23:33:17, Qiang (Joe) Xu wrote: > Hi oshima, sky, this is a following ...
4 years, 2 months ago (2016-09-28 19:49:57 UTC) #11
Qiang(Joe) Xu
On 2016/09/28 19:49:57, oshima wrote: > On 2016/09/27 23:33:17, Qiang (Joe) Xu wrote: > > ...
4 years, 2 months ago (2016-09-28 20:14:14 UTC) #12
oshima
lgtm, thanks. nit: add 650776 to the bug list
4 years, 2 months ago (2016-09-28 20:55:03 UTC) #13
sky
I'm very worried about this change. Prior to your change calling View::RequestFocus would implicitly focus ...
4 years, 2 months ago (2016-09-28 21:56:53 UTC) #15
Qiang(Joe) Xu
The basic logic in FocusManager::SetFocusedView is changed to only when |widget_| is active, the |view| ...
4 years, 2 months ago (2016-09-29 00:07:25 UTC) #16
sky
On Wed, Sep 28, 2016 at 5:07 PM, <warx@chromium.org> wrote: > The basic logic in ...
4 years, 2 months ago (2016-09-29 03:34:39 UTC) #17
oshima
On 2016/09/29 03:34:39, sky wrote: > On Wed, Sep 28, 2016 at 5:07 PM, <mailto:warx@chromium.org> ...
4 years, 2 months ago (2016-09-29 18:48:32 UTC) #18
sky
On Thu, Sep 29, 2016 at 11:48 AM, <oshima@chromium.org> wrote: > On 2016/09/29 03:34:39, sky ...
4 years, 2 months ago (2016-09-29 19:17:41 UTC) #19
Qiang(Joe) Xu
Hi all, updates include: (1) basically a ClearNativeFocus call is added. (2) description of this ...
4 years, 2 months ago (2016-09-30 03:59:20 UTC) #24
sky
Can you outline why you still need the changes to the other tests?
4 years, 2 months ago (2016-09-30 15:26:39 UTC) #27
Qiang(Joe) Xu
On 2016/09/30 15:26:39, sky wrote: > Can you outline why you still need the changes ...
4 years, 2 months ago (2016-09-30 18:30:45 UTC) #28
sky
Sorry for the run around this. Focus is always tricky. https://codereview.chromium.org/2371113003/diff/80001/ui/views/focus/focus_manager.cc File ui/views/focus/focus_manager.cc (right): https://codereview.chromium.org/2371113003/diff/80001/ui/views/focus/focus_manager.cc#newcode325 ...
4 years, 2 months ago (2016-10-03 15:56:18 UTC) #29
Qiang(Joe) Xu
https://codereview.chromium.org/2371113003/diff/80001/ui/views/focus/focus_manager.cc File ui/views/focus/focus_manager.cc (right): https://codereview.chromium.org/2371113003/diff/80001/ui/views/focus/focus_manager.cc#newcode325 ui/views/focus/focus_manager.cc:325: ClearNativeFocus(); On 2016/10/03 15:56:18, sky wrote: > I'm wrong. ...
4 years, 2 months ago (2016-10-03 20:24:51 UTC) #30
Qiang(Joe) Xu
This is a tentative CL for review. As I am not sure why some tests ...
4 years, 2 months ago (2016-10-04 00:00:33 UTC) #34
sky
Please make sure you understand why 3 and 4 are necessary. https://codereview.chromium.org/2371113003/diff/100001/ui/views/focus/focus_manager.cc File ui/views/focus/focus_manager.cc (right): ...
4 years, 2 months ago (2016-10-04 15:47:03 UTC) #38
Qiang(Joe) Xu
Hi Scott, This patch has the following updates: (1) For app_info_dialog_ash_unittest.cc, widget_->Show() is needed because ...
4 years, 2 months ago (2016-10-10 16:40:01 UTC) #44
sky
On 2016/10/10 16:40:01, Qiang (Joe) Xu wrote: > Hi Scott, > > This patch has ...
4 years, 2 months ago (2016-10-10 19:47:08 UTC) #45
Qiang(Joe) Xu
On 2016/10/10 19:47:08, sky wrote: > On 2016/10/10 16:40:01, Qiang (Joe) Xu wrote: > > ...
4 years, 2 months ago (2016-10-10 20:58:40 UTC) #47
sky
Thanks for the clarification. Only one issue. Also, is the ifdef still needed for mac ...
4 years, 2 months ago (2016-10-10 22:47:22 UTC) #48
Qiang(Joe) Xu
On 2016/10/10 22:47:22, sky wrote: > Thanks for the clarification. Only one issue. > > ...
4 years, 2 months ago (2016-10-11 16:51:38 UTC) #49
sky
https://codereview.chromium.org/2371113003/diff/180001/chrome/test/BUILD.gn File chrome/test/BUILD.gn (right): https://codereview.chromium.org/2371113003/diff/180001/chrome/test/BUILD.gn#newcode558 chrome/test/BUILD.gn:558: "../browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc", It is confusing to have both a toolbar_view_browsertest ...
4 years, 2 months ago (2016-10-11 19:24:09 UTC) #54
sky
One followup question on Rununtilidle. Rununtilidle runs until there are no events in the runloop. ...
4 years, 2 months ago (2016-10-11 19:24:50 UTC) #55
Qiang(Joe) Xu
On 2016/10/11 19:24:50, sky wrote: > One followup question on Rununtilidle. Rununtilidle runs until there ...
4 years, 2 months ago (2016-10-11 22:49:11 UTC) #57
Qiang(Joe) Xu
https://codereview.chromium.org/2371113003/diff/180001/chrome/test/BUILD.gn File chrome/test/BUILD.gn (right): https://codereview.chromium.org/2371113003/diff/180001/chrome/test/BUILD.gn#newcode558 chrome/test/BUILD.gn:558: "../browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc", On 2016/10/11 19:24:09, sky wrote: > It is ...
4 years, 2 months ago (2016-10-11 22:49:29 UTC) #58
sky
On 2016/10/11 22:49:11, Qiang (Joe) Xu wrote: > On 2016/10/11 19:24:50, sky wrote: > > ...
4 years, 2 months ago (2016-10-11 23:14:58 UTC) #59
sadrul
On 2016/10/11 23:14:58, sky wrote: > On 2016/10/11 22:49:11, Qiang (Joe) Xu wrote: > > ...
4 years, 2 months ago (2016-10-11 23:19:26 UTC) #60
sky
+1 On Tue, Oct 11, 2016 at 4:19 PM, <sadrul@chromium.org> wrote: > On 2016/10/11 23:14:58, ...
4 years, 2 months ago (2016-10-11 23:27:32 UTC) #61
Qiang(Joe) Xu
On 2016/10/11 23:27:32, sky wrote: > +1 > > On Tue, Oct 11, 2016 at ...
4 years, 2 months ago (2016-10-11 23:31:01 UTC) #62
sky
You shouldn't enable this test until you use something like WidgetActivationWaiter. Two options: . leave ...
4 years, 2 months ago (2016-10-11 23:35:32 UTC) #63
Qiang(Joe) Xu
Hi Scott, updates include: (1) using WidgetActivationWaiter in toolbar_view_interactive_uitest.cc (2) restoring WidgetInputMethodInteractiveTest.OneWindow test. I think ...
4 years, 2 months ago (2016-10-13 03:38:16 UTC) #66
sky
https://codereview.chromium.org/2371113003/diff/300001/chrome/browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc File chrome/browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc (right): https://codereview.chromium.org/2371113003/diff/300001/chrome/browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc#newcode26 chrome/browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc:26: #include "chrome/browser/ui/views/toolbar/toolbar_view.h" This include should the first include, then ...
4 years, 2 months ago (2016-10-13 16:21:22 UTC) #74
Qiang(Joe) Xu
Hi Scott, I have a question regarding tests on other non-chromeos platforms. https://codereview.chromium.org/2371113003/diff/300001/chrome/browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc File chrome/browser/ui/views/toolbar/toolbar_view_interactive_uitest.cc ...
4 years, 2 months ago (2016-10-14 01:42:39 UTC) #75
sky
https://codereview.chromium.org/2371113003/diff/300001/ui/views/widget/native_widget_aura_unittest.cc File ui/views/widget/native_widget_aura_unittest.cc (right): https://codereview.chromium.org/2371113003/diff/300001/ui/views/widget/native_widget_aura_unittest.cc#newcode174 ui/views/widget/native_widget_aura_unittest.cc:174: textfield2->RequestFocus(); On 2016/10/14 01:42:39, Qiang (Joe) Xu wrote: > ...
4 years, 2 months ago (2016-10-14 15:41:36 UTC) #76
Qiang(Joe) Xu
Hi Scott, new patch is uploaded. Change is moving the added test to interactive_ui_test. However, ...
4 years, 2 months ago (2016-10-19 05:13:52 UTC) #93
sky
Your test is creating a DesktopNativeWidgetAura on windows, not a NativeWidgetAura. That's why it fails ...
4 years, 2 months ago (2016-10-19 16:23:33 UTC) #96
Qiang(Joe) Xu
Hi Scott, I put the test in native_widget_aura_interactive_uitest.cc now. Thanks for clarifying. https://codereview.chromium.org/2371113003/diff/440001/ui/views/widget/widget_interactive_uitest.cc File ui/views/widget/widget_interactive_uitest.cc ...
4 years, 2 months ago (2016-10-20 23:51:51 UTC) #99
sky
https://codereview.chromium.org/2371113003/diff/480001/chrome/test/BUILD.gn File chrome/test/BUILD.gn (right): https://codereview.chromium.org/2371113003/diff/480001/chrome/test/BUILD.gn#newcode592 chrome/test/BUILD.gn:592: if (!is_mac) { I would rather you add an ...
4 years, 2 months ago (2016-10-21 03:14:18 UTC) #103
Qiang(Joe) Xu
Hi Scott, new patch is uploaded. Thanks! https://codereview.chromium.org/2371113003/diff/480001/chrome/test/BUILD.gn File chrome/test/BUILD.gn (right): https://codereview.chromium.org/2371113003/diff/480001/chrome/test/BUILD.gn#newcode592 chrome/test/BUILD.gn:592: if (!is_mac) ...
4 years, 2 months ago (2016-10-21 16:23:07 UTC) #104
sky
LGTM - yay! Thanks for your patience and diligence in seeing this patch through.
4 years, 2 months ago (2016-10-21 20:01:50 UTC) #105
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2371113003/500001
4 years, 2 months ago (2016-10-21 20:05:12 UTC) #108
commit-bot: I haz the power
Committed patchset #18 (id:500001)
4 years, 2 months ago (2016-10-21 21:56:22 UTC) #110
commit-bot: I haz the power
Patchset 18 (id:??) landed as https://crrev.com/5c16e0e849526c1c627e08a05351ab38a9cfbcf1 Cr-Commit-Position: refs/heads/master@{#426905}
4 years, 2 months ago (2016-10-21 22:00:19 UTC) #112
Knuckster
On 2016/10/21 20:01:50, sky wrote: > LGTM - yay! Thanks for your patience and diligence ...
3 years, 11 months ago (2017-01-20 14:25:37 UTC) #113
sky
3 years, 10 months ago (2017-02-09 18:01:41 UTC) #114
Message was sent while issue was closed.
On 2017/01/20 14:25:37, Knuckster wrote:
> On 2016/10/21 20:01:50, sky wrote:
> > LGTM - yay! Thanks for your patience and diligence in seeing this patch
> through.
> 
> Hi guys!
> I work at company "Cliqz GmbH", where we do some experiments with Chromium
> sources.
> After merging with v56 we encountered an issue, stemming from this patch.
> The scenario in short is: when clicking into WebView placed inside
> OmniboxPopupContentsView, FocusManager activates the Widget under the popup,
> which causes main window to loose focus and close the popup, preventing the
> content from properly handling the click event.
> We fixed it by adding another check, whether Widget even can be activated,
> making it look like this:
> 
>   if (view && !widget_->IsActive() && widget_->CanActivate()) {
>     SetStoredFocusView(view);
>     widget_->Activate();
>     return;
>   }
> 
> It looks valid to me, that a Widget should not be activated, if it says it
> can't.
> This patch also doesn't seem to break any tests or easily observed behaviour.
> 
> Question is: is it possible for you to accept this fix to your repo. It seems
> valid, and we also want to keep our changes compared to upstream to a minimum
of
> course.
> 
> If it looks wrong, and there should be a better way to do it, I'll be glad to
> hear about it :)
> 
> Best,
> Max Breev

I think a better fix is so make Activate() do nothing if CanActivate() returns
false.

Powered by Google App Engine
This is Rietveld 408576698