fix: ensure popup and closepopup are posted in order (#20114)
This commit is contained in:
parent
8a0a41b9ef
commit
20e3c519dd
2 changed files with 9 additions and 1 deletions
|
@ -35,6 +35,7 @@ class MenuMac : public Menu {
|
|||
int positioning_item,
|
||||
base::Closure callback);
|
||||
void ClosePopupAt(int32_t window_id) override;
|
||||
void ClosePopupOnUI(int32_t window_id);
|
||||
|
||||
private:
|
||||
friend class Menu;
|
||||
|
|
|
@ -48,7 +48,7 @@ void MenuMac::PopupAt(TopLevelWindow* window,
|
|||
base::BindOnce(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
|
||||
native_window->GetWeakPtr(), window->weak_map_id(), x, y,
|
||||
positioning_item, callback);
|
||||
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(popup));
|
||||
base::SequencedTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(popup));
|
||||
}
|
||||
|
||||
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
|
@ -117,6 +117,13 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
|||
}
|
||||
|
||||
void MenuMac::ClosePopupAt(int32_t window_id) {
|
||||
auto close_popup = base::BindOnce(&MenuMac::ClosePopupOnUI,
|
||||
weak_factory_.GetWeakPtr(), window_id);
|
||||
base::SequencedTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
||||
std::move(close_popup));
|
||||
}
|
||||
|
||||
void MenuMac::ClosePopupOnUI(int32_t window_id) {
|
||||
auto controller = popup_controllers_.find(window_id);
|
||||
if (controller != popup_controllers_.end()) {
|
||||
// Close the controller for the window.
|
||||
|
|
Loading…
Reference in a new issue