|
|
Chromium Code Reviews
DescriptionViews: Expose an on_closed callback via the MenuRunner constructor.
Clients often store a MenuRunner instance as a member to ensure menus
are dismissed when the client is destroyed. If a client doesn't also
observe the menu closing, it effectively leaks the MenuRunner. So, it's
a common pattern to need an on_closed callback.
Previously, this callback was only provided via MenuModelAdapter APIs.
MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients
wanting on_closed were not able to show native menus.
To fix, allow the MenuRunner constructor to pass an on_closed callback
through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa
which gains support for invoking the callback.
Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both
native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to
ensure the behaviour is consistent and any sync/async divergence is
intentional.
4 clients no longer need a MenuModelAdapter - remove it from them.
BUG=653334
Committed: https://crrev.com/7a7c6831b11536332403881c6619986b55f62e05
Cr-Commit-Position: refs/heads/master@{#425186}
Patch Set 1 : Test both adapters #Patch Set 2 : Self review #Patch Set 3 : Just overload constructor. #Patch Set 4 : Remove more unnecessary adapters #Patch Set 5 : Simpler #Patch Set 6 : NON_EXPORTED_BASE #
Total comments: 5
Patch Set 7 : DO NOT COMMIT - Annotate callers to see if they can use MenuModel/SimpleMenuModel::Delegate #Patch Set 8 : Delete [Simple]MenuModel[::Delegate]::Menu[Will]Close[d]? (eep!) +TODO(investigate RVCMM) #Patch Set 9 : Back to Patch set 6 #
Total comments: 2
Patch Set 10 : default arg #Messages
Total messages: 79 (70 generated)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-...) chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...) linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-...) chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...) linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #3 (id:40001) has been deleted
Patchset #2 (id:20001) has been deleted
Patchset #1 (id:1) has been deleted
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #5 (id:140001) has been deleted
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Views: wrap the OnMenuClosed() callback in MenuRunner WIP BUG=653334 ========== to ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. BUG=653334 ==========
tapted@chromium.org changed reviewers: + sky@chromium.org
Patchset #5 (id:160001) has been deleted
Description was changed from ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. BUG=653334 ========== to ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter, so remove it. BUG=653334 ==========
Description was changed from ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter, so remove it. BUG=653334 ========== to ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ==========
Description was changed from ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ========== to ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ==========
Description was changed from ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistence and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ========== to ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistent and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_compile_dbg_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_comp...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Hi sky, please take a look https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:115: MenuRunner(ui::MenuModel* menu_model, int32_t run_types); Patchset 2 didn't keep this overload - there's a bit of fallout (and more if I fixed those compile errors). But in a follow-up it might be neater to remove this - to encourage providing a callback in _all_ cases, since clients who do not reset() their |menu_runner_| instance effectively leak the menu until the client itself is destroyed. https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:118: MenuRunner(MenuItemView* menu, int32_t run_types); I looked around for other things that might miss out on native menus. But there aren't many callers of this overload left. Only 2 in the current Mac build: - scroll_bar (for a context menu that will probably get nerfed on Mac once someone notices it exists at all). - RenderViewContextMenuBase's RenderViewContextMenuBase (since it does "live" menu item updates) (but I think this is dead code on Mac right now) Then, a few more in a mac_views_browser_build - toolbar_button.cc (since they allow middle-clicks on menu items) - The "App" menu (wrench/hotdog - since it has crazy customizations) - bookmarks (we would not use native menus on mac either, since we need drag & drop) - toolbar_action_view.cc (it exposes a MenuItemView* for testing) (but then a few more that are only used in ash) But none of these scare me off wanting to use native menus more widely :). I.e. I think there's a neat solution for things we want using native menus on Mac.
jonross@chromium.org changed reviewers: + jonross@chromium.org
https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:115: MenuRunner(ui::MenuModel* menu_model, int32_t run_types); On 2016/10/12 10:05:21, tapted wrote: > Patchset 2 didn't keep this overload - there's a bit of fallout (and more if I > fixed those compile errors). But in a follow-up it might be neater to remove > this - to encourage providing a callback in _all_ cases, since clients who do > not reset() their |menu_runner_| instance effectively leak the menu until the > client itself is destroyed. There are some clients which are transient. The views triggering the menus don't last long. (Such as the Notifications bubble on Chromium OS.) So the closed MenuRunner is not always around long. However I wouldn't be against a forced closing step https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner_impl_cocoa.mm (right): https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_runner_impl_cocoa.mm:164: on_menu_closed_callback_.Run(); I just want to confirm, the beginning of this method perform the blocking calls. Removing the calls into ui/views/controls/menu/menu_controller? If so, that doesn't block the cleanup that we want to do there (remove the synchronous code path) One far off concern with having a set of menus blocking is related to the mus window server, and how we ack events. As nested message loops remove guarantees on receiving acks for a given event. However if we know the an isolated set of cases, like this, we could post the acks for those.
We already have MenuWillClose in MenuModel. Did you consider adding MenuClosed in MenuModel?
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-...) linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #7 (id:220001) has been deleted
Patchset #8 (id:260001) has been deleted
Patchset #8 (id:280001) has been deleted
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...) linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Patchset #8 (id:300001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #8 (id:320001) has been deleted
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2016/10/12 16:22:32, sky wrote: > We already have MenuWillClose in MenuModel. Did you consider adding MenuClosed > in MenuModel? That turns out to be hard. However, deleting both MenuDelegate::MenuWillClose and SimpleMenuModel::Delegate::MenuClosed was surprisingly easy.... Only RenderViewContextMenu is using this properly. Details: I poked around trying to remove on_menu_closed_callback from the MenuModelAdapter in PatchSet 7. The problem is that the model and the model delegate are often in cross-platform code. However MenuModelAdapter and MenuRunner are in views-specific code - it gets a bit curly trying to convince the cross-platform code to call back into the views code, e.g., to delete the MenuRunner - see comments for some specific cases in PatchSet 7. We'd need a delegate-delegate or something. Some simple cases like the download shelf are neat, and I figured out something for views::Combobox, but doing it for some others makes a mess. So, I think there's still a case for a closed callback via MenuRunner -- it's a good fit for doing the platform-specific cleanup around running a menu, whereas the model delegates can concern themselves only with cross-platform code. Instead, I explored whether we could just delete MenuWillClose from the cross-platform delegate interfaces (i.e. just use the callback passed into MenuRunner). This is in PatchSet 8 - I'm pretty sure it works (trybots are green :), and it's a bit of a code cleanup. But it doesn't feel right.. and it's also orthogonal to this CL (i.e. there's no added churn if we still want to explore that in a follow-up still). So, I went back to PatchSet 6 in the end. https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner_impl_cocoa.mm (right): https://codereview.chromium.org/2394123002/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_runner_impl_cocoa.mm:164: on_menu_closed_callback_.Run(); On 2016/10/12 14:35:18, jonross wrote: > I just want to confirm, the beginning of this method perform the blocking calls. > Removing the calls into ui/views/controls/menu/menu_controller? > > If so, that doesn't block the cleanup that we want to do there (remove the > synchronous code path) Yup - exactly. > > One far off concern with having a set of menus blocking is related to the mus > window server, and how we ack events. As nested message loops remove guarantees > on receiving acks for a given event. However if we know the an isolated set of > cases, like this, we could post the acks for those. It's also possible we can get the mac-themed views menus to a point where they're almost indistinguishable, so we can use that on Mus. For now they don't integrate well with Mac screenreaders, and there are other subtle UI and UX differences that that were making toolkit-views on mac less palatable :/
LGTM with default arg https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:114: const base::Closure& on_menu_closed_callback); Combine this with the next constructor and use a default value? (style guide now allows default values in cases like this).
The CQ bit was checked by tapted@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2394123002/diff/360001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:114: const base::Closure& on_menu_closed_callback); On 2016/10/13 17:44:07, sky wrote: > Combine this with the next constructor and use a default value? (style guide now > allows default values in cases like this). Done.
The CQ bit was unchecked by tapted@chromium.org
The CQ bit was checked by tapted@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/2394123002/#ps370001 (title: "default arg")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistent and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ========== to ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistent and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ==========
Message was sent while issue was closed.
Committed patchset #10 (id:370001)
Message was sent while issue was closed.
Description was changed from ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistent and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 ========== to ========== Views: Expose an on_closed callback via the MenuRunner constructor. Clients often store a MenuRunner instance as a member to ensure menus are dismissed when the client is destroyed. If a client doesn't also observe the menu closing, it effectively leaks the MenuRunner. So, it's a common pattern to need an on_closed callback. Previously, this callback was only provided via MenuModelAdapter APIs. MenuModelAdapter isn't used for Native NSMenus on MacViews, so clients wanting on_closed were not able to show native menus. To fix, allow the MenuRunner constructor to pass an on_closed callback through; either to the MenuModelAdapter, or the MenuRunnerImplCocoa which gains support for invoking the callback. Tests in menu_runner_cocoa_unittest.mm are paramaterized to test both native (NSMenu, synchronous) and views (MenuItemView, asyncrhonous) to ensure the behaviour is consistent and any sync/async divergence is intentional. 4 clients no longer need a MenuModelAdapter - remove it from them. BUG=653334 Committed: https://crrev.com/7a7c6831b11536332403881c6619986b55f62e05 Cr-Commit-Position: refs/heads/master@{#425186} ==========
Message was sent while issue was closed.
Patchset 10 (id:??) landed as https://crrev.com/7a7c6831b11536332403881c6619986b55f62e05 Cr-Commit-Position: refs/heads/master@{#425186} |
