From 3993777bc5c03b904bb670828e7d8675f3f15dde Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 23 Dec 2021 16:27:25 +0000 Subject: [PATCH] Bug 1539884 - Part 34: Mark StatusBarEntry::OnMessage as CAN_RUN_SCRIPT r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D134417 --- widget/windows/SystemStatusBar.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/widget/windows/SystemStatusBar.cpp b/widget/windows/SystemStatusBar.cpp index 994e98a19e03..7326c8c3f472 100644 --- a/widget/windows/SystemStatusBar.cpp +++ b/widget/windows/SystemStatusBar.cpp @@ -39,7 +39,8 @@ class StatusBarEntry final : public LinkedListElement>, nsresult Init(); void Destroy(); - LRESULT OnMessage(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); + MOZ_CAN_RUN_SCRIPT LRESULT OnMessage(HWND hWnd, UINT msg, WPARAM wp, + LPARAM lp); const Element* GetMenu() { return mMenu; }; nsresult OnComplete(imgIContainer* aImage) override; @@ -47,7 +48,8 @@ class StatusBarEntry final : public LinkedListElement>, private: ~StatusBarEntry(); RefPtr mIconLoader; - RefPtr mMenu; + // Effectively const but is cycle collected + MOZ_KNOWN_LIVE RefPtr mMenu; NOTIFYICONDATAW mIconData; boolean mInitted; }; @@ -237,8 +239,8 @@ LRESULT StatusBarEntry::OnMessage(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { nsEventStatus status = nsEventStatus_eIgnore; WidgetMouseEvent event(true, eXULSystemStatusBarClick, nullptr, WidgetMouseEvent::eReal); - EventDispatcher::Dispatch(mMenu, menu->PresContext(), &event, nullptr, - &status); + RefPtr presContext = menu->PresContext(); + EventDispatcher::Dispatch(mMenu, presContext, &event, nullptr, &status); return DefWindowProc(hWnd, msg, wp, lp); } @@ -271,10 +273,10 @@ LRESULT StatusBarEntry::OnMessage(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { NS_IMPL_ISUPPORTS(SystemStatusBar, nsISystemStatusBar) -static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { - StatusBarEntry* entry = - (StatusBarEntry*)GetWindowLongPtr(hWnd, GWLP_USERDATA); - if (entry) { +MOZ_CAN_RUN_SCRIPT static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, + WPARAM wp, LPARAM lp) { + if (RefPtr entry = + (StatusBarEntry*)GetWindowLongPtr(hWnd, GWLP_USERDATA)) { return entry->OnMessage(hWnd, msg, wp, lp); } return TRUE;