|
|
Description[Views] If a sibling menu is selected, reset the MenuButton's PressedLock
MenuButton::Activate() creates a PressedLock, which is important if it doesn't
call into MenuController code. However, if it is running a menu through the
MenuController and a sibling menu is shown, we need to reset that PressedLock
so that buttons don't remain pressed. Fix the bug and add a couple tests.
BUG=560852
Committed: https://crrev.com/d2db790c2898559a24402c131d22444c6d0ca4a4
Cr-Commit-Position: refs/heads/master@{#363547}
Patch Set 1 : #
Total comments: 4
Patch Set 2 : Remove PressedLock #Patch Set 3 : #Patch Set 4 : Test fix #
Total comments: 2
Messages
Total messages: 22 (10 generated)
Description was changed from ========== Bookmark Bar Fix BUG= ========== to ========== [Views] If a sibling menu is selected, reset the MenuButton's PressedLock MenuButton::Activate() creates a PressedLock, which is important if it doesn't call into MenuController code. However, if it is running a menu through the MenuController and a sibling menu is shown, we need to reset that PressedLock so that buttons don't remain pressed. Fix the bug and add a couple tests. BUG=560852 ==========
Patchset #1 (id:1) has been deleted
Patchset #1 (id:20001) has been deleted
Patchset #1 (id:40001) has been deleted
rdevlin.cronin@chromium.org changed reviewers: + sky@chromium.org
Scott, mind taking a look?
https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... File ui/views/controls/button/menu_button.cc (right): https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... ui/views/controls/button/menu_button.cc:134: listener_->OnMenuButtonClicked(this, menu_position); Under what case does this not show a menu?
On 2015/12/04 00:44:40, sky wrote: > https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... > File ui/views/controls/button/menu_button.cc (right): > > https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... > ui/views/controls/button/menu_button.cc:134: > listener_->OnMenuButtonClicked(this, menu_position); > Under what case does this not show a menu? Let me clarify that, under what conditions does the code mentioned not end up in MenuController?
https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... File ui/views/controls/button/menu_button.cc (right): https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... ui/views/controls/button/menu_button.cc:134: listener_->OnMenuButtonClicked(this, menu_position); On 2015/12/04 00:44:40, sky wrote: > Under what case does this not show a menu? It won't end up in menu controller code if OnMenuButtonClicked doesn't actually show a ("real") menu. Looking through the overrides, I found at least two places this happens: - AvatarMenuButton: Looks like a custom view is being shown. - ToolbarActionView (the one I know about for sure): We can show an extension popup instead of a menu. The alternative to this that I thought about was just taking the PressedLock in Activate() out entirely, and requiring anyone that didn't want to show a menu to instantiate their own pressed lock, but I was a little worried that there was a case I was missing somewhere that would suddenly break, and it seemed a bit odd, since the rest of the button state code responding to clicks is pretty much handled by the button itself. But I'm on the edge, so if that approach (or one I haven't thought of) sounds better to you, I'm all for it.
https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... File ui/views/controls/button/menu_button.cc (right): https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... ui/views/controls/button/menu_button.cc:134: listener_->OnMenuButtonClicked(this, menu_position); On 2015/12/04 16:43:59, Devlin wrote: > On 2015/12/04 00:44:40, sky wrote: > > Under what case does this not show a menu? > > It won't end up in menu controller code if OnMenuButtonClicked doesn't actually > show a ("real") menu. Looking through the overrides, I found at least two > places this happens: > - AvatarMenuButton: Looks like a custom view is being shown. > - ToolbarActionView (the one I know about for sure): We can show an extension > popup instead of a menu. > > The alternative to this that I thought about was just taking the PressedLock in > Activate() out entirely, and requiring anyone that didn't want to show a menu to > instantiate their own pressed lock, but I was a little worried that there was a > case I was missing somewhere that would suddenly break, and it seemed a bit odd, > since the rest of the button state code responding to clicks is pretty much > handled by the button itself. But I'm on the edge, so if that approach (or one > I haven't thought of) sounds better to you, I'm all for it. I prefer letting the callsites handle the PressedLock for two reasons: . We're (hopefully) going to move away from nested message loop menus. The way we have the pressedlock here won't work in that world. . It means we don't need an awkward api to reset the lock (SiblingMenuShow).
https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... File ui/views/controls/button/menu_button.cc (right): https://codereview.chromium.org/1495973002/diff/60001/ui/views/controls/butto... ui/views/controls/button/menu_button.cc:134: listener_->OnMenuButtonClicked(this, menu_position); On 2015/12/04 16:56:53, sky wrote: > On 2015/12/04 16:43:59, Devlin wrote: > > On 2015/12/04 00:44:40, sky wrote: > > > Under what case does this not show a menu? > > > > It won't end up in menu controller code if OnMenuButtonClicked doesn't > actually > > show a ("real") menu. Looking through the overrides, I found at least two > > places this happens: > > - AvatarMenuButton: Looks like a custom view is being shown. > > - ToolbarActionView (the one I know about for sure): We can show an extension > > popup instead of a menu. > > > > The alternative to this that I thought about was just taking the PressedLock > in > > Activate() out entirely, and requiring anyone that didn't want to show a menu > to > > instantiate their own pressed lock, but I was a little worried that there was > a > > case I was missing somewhere that would suddenly break, and it seemed a bit > odd, > > since the rest of the button state code responding to clicks is pretty much > > handled by the button itself. But I'm on the edge, so if that approach (or > one > > I haven't thought of) sounds better to you, I'm all for it. > > I prefer letting the callsites handle the PressedLock for two reasons: > . We're (hopefully) going to move away from nested message loop menus. The way > we have the pressedlock here won't work in that world. > . It means we don't need an awkward api to reset the lock (SiblingMenuShow). Okay, done. Looking at them more, it seems like we shouldn't even need to update those two special cases - ToolbarActionView already instantiates a PressedLock, and since the AvatarMenuButton doesn't enter a nested loop, the pressed lock that exists doesn't really do anything. Sound right to you?
Yes, LGTM I think the avatar menu should really persist the lock until the bubble it shows goes away. But that's separate.
Patchset #4 (id:100001) has been deleted
I very sillily forgot to re-run (all the) menu button tests with the last CL. Please take a look at the changes. Sorry for the noise. https://codereview.chromium.org/1495973002/diff/120001/ui/views/controls/butt... File ui/views/controls/button/menu_button.cc (right): https://codereview.chromium.org/1495973002/diff/120001/ui/views/controls/butt... ui/views/controls/button/menu_button.cc:222: if (state() == Button::STATE_HOVERED) This is kind of awkward, but important since we entered HOVERED state here and, unlike with a mouse, need to exit it once the gesture ends... https://codereview.chromium.org/1495973002/diff/120001/ui/views/controls/butt... File ui/views/controls/button/menu_button_unittest.cc (right): https://codereview.chromium.org/1495973002/diff/120001/ui/views/controls/butt... ui/views/controls/button/menu_button_unittest.cc:301: EXPECT_EQ(Button::STATE_HOVERED, menu_button_listener.last_source_state()); The state will start in HOVERED in Activate() and is set to PRESSED by menu code.
SLGTM
The CQ bit was checked by rdevlin.cronin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from sky@chromium.org Link to the patchset: https://codereview.chromium.org/1495973002/#ps120001 (title: "Test fix")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1495973002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1495973002/120001
Message was sent while issue was closed.
Description was changed from ========== [Views] If a sibling menu is selected, reset the MenuButton's PressedLock MenuButton::Activate() creates a PressedLock, which is important if it doesn't call into MenuController code. However, if it is running a menu through the MenuController and a sibling menu is shown, we need to reset that PressedLock so that buttons don't remain pressed. Fix the bug and add a couple tests. BUG=560852 ========== to ========== [Views] If a sibling menu is selected, reset the MenuButton's PressedLock MenuButton::Activate() creates a PressedLock, which is important if it doesn't call into MenuController code. However, if it is running a menu through the MenuController and a sibling menu is shown, we need to reset that PressedLock so that buttons don't remain pressed. Fix the bug and add a couple tests. BUG=560852 ==========
Message was sent while issue was closed.
Committed patchset #4 (id:120001)
Message was sent while issue was closed.
Description was changed from ========== [Views] If a sibling menu is selected, reset the MenuButton's PressedLock MenuButton::Activate() creates a PressedLock, which is important if it doesn't call into MenuController code. However, if it is running a menu through the MenuController and a sibling menu is shown, we need to reset that PressedLock so that buttons don't remain pressed. Fix the bug and add a couple tests. BUG=560852 ========== to ========== [Views] If a sibling menu is selected, reset the MenuButton's PressedLock MenuButton::Activate() creates a PressedLock, which is important if it doesn't call into MenuController code. However, if it is running a menu through the MenuController and a sibling menu is shown, we need to reset that PressedLock so that buttons don't remain pressed. Fix the bug and add a couple tests. BUG=560852 Committed: https://crrev.com/d2db790c2898559a24402c131d22444c6d0ca4a4 Cr-Commit-Position: refs/heads/master@{#363547} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/d2db790c2898559a24402c131d22444c6d0ca4a4 Cr-Commit-Position: refs/heads/master@{#363547} |