Bug 1807482 - Remove gRollupListener. r=stransky

This is just preliminary clean-up.

Differential Revision: https://phabricator.services.mozilla.com/D165734
This commit is contained in:
Emilio Cobos Álvarez 2023-01-03 13:39:43 +00:00
Родитель 2e5132f48e
Коммит f62fac0678
10 изменённых файлов: 13 добавлений и 33 удалений

Просмотреть файл

@ -293,7 +293,7 @@ bool nsXULPopupManager::Rollup(uint32_t aCount, bool aFlush,
if (StaticPrefs::ui_popup_disable_autohide()) { if (StaticPrefs::ui_popup_disable_autohide()) {
// Required on linux to allow events to work on other targets. // Required on linux to allow events to work on other targets.
if (mWidget) { if (mWidget) {
mWidget->CaptureRollupEvents(nullptr, false); mWidget->CaptureRollupEvents(false);
} }
return false; return false;
} }
@ -1955,7 +1955,7 @@ void nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup) {
if (item && aOldPopup == item->Content()) return; if (item && aOldPopup == item->Content()) return;
if (mWidget) { if (mWidget) {
mWidget->CaptureRollupEvents(nullptr, false); mWidget->CaptureRollupEvents(false);
mWidget = nullptr; mWidget = nullptr;
} }
@ -1963,7 +1963,7 @@ void nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup) {
nsMenuPopupFrame* popup = item->Frame(); nsMenuPopupFrame* popup = item->Frame();
mWidget = popup->GetWidget(); mWidget = popup->GetWidget();
if (mWidget) { if (mWidget) {
mWidget->CaptureRollupEvents(nullptr, true); mWidget->CaptureRollupEvents(true);
} }
} }

Просмотреть файл

@ -301,7 +301,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override; virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
virtual WindowRenderer* GetWindowRenderer() override; virtual WindowRenderer* GetWindowRenderer() override;
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override; virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
virtual void CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCapture) override; virtual void CaptureRollupEvents(bool aDoCapture) override;
[[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) override; [[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) override;
virtual bool HasPendingInputEvent() override; virtual bool HasPendingInputEvent() override;
virtual nsTransparencyMode GetTransparencyMode() override; virtual nsTransparencyMode GetTransparencyMode() override;

Просмотреть файл

@ -2253,11 +2253,9 @@ LayoutDeviceIntSize nsCocoaWindow::ClientToWindowSize(const LayoutDeviceIntSize&
nsMenuBarX* nsCocoaWindow::GetMenuBar() { return mMenuBar; } nsMenuBarX* nsCocoaWindow::GetMenuBar() { return mMenuBar; }
void nsCocoaWindow::CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCapture) { void nsCocoaWindow::CaptureRollupEvents(bool aDoCapture) {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK; NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
gRollupListener = nullptr;
if (aDoCapture) { if (aDoCapture) {
if (![NSApp isActive]) { if (![NSApp isActive]) {
// We need to capture mouse event if we aren't // We need to capture mouse event if we aren't
@ -2266,7 +2264,6 @@ void nsCocoaWindow::CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCa
// and gdb sessions. See bug 699538. // and gdb sessions. See bug 699538.
nsToolkit::GetToolkit()->MonitorAllProcessMouseEvents(); nsToolkit::GetToolkit()->MonitorAllProcessMouseEvents();
} }
gRollupListener = aListener;
// Sometimes more than one popup window can be visible at the same time // Sometimes more than one popup window can be visible at the same time
// (e.g. nested non-native context menus, or the test case (attachment // (e.g. nested non-native context menus, or the test case (attachment

Просмотреть файл

@ -3692,8 +3692,7 @@ void nsWindow::CaptureMouse(bool aCapture) {
} }
} }
void nsWindow::CaptureRollupEvents(nsIRollupListener* aListener, void nsWindow::CaptureRollupEvents(bool aDoCapture) {
bool aDoCapture) {
LOG("CaptureRollupEvents() %i\n", int(aDoCapture)); LOG("CaptureRollupEvents() %i\n", int(aDoCapture));
if (mIsDestroyed) { if (mIsDestroyed) {
@ -3701,7 +3700,6 @@ void nsWindow::CaptureRollupEvents(nsIRollupListener* aListener,
} }
if (aDoCapture) { if (aDoCapture) {
gRollupListener = aListener;
// Don't add a grab if a drag is in progress, or if the widget is a drag // Don't add a grab if a drag is in progress, or if the widget is a drag
// feedback popup. (panels with type="drag"). // feedback popup. (panels with type="drag").
if (!GdkIsWaylandDisplay() && !mIsDragPopup && if (!GdkIsWaylandDisplay() && !mIsDragPopup &&
@ -3714,7 +3712,6 @@ void nsWindow::CaptureRollupEvents(nsIRollupListener* aListener,
// was not added to this widget. // was not added to this widget.
LOG(" remove mContainer grab [%p]\n", this); LOG(" remove mContainer grab [%p]\n", this);
gtk_grab_remove(GTK_WIDGET(mContainer)); gtk_grab_remove(GTK_WIDGET(mContainer));
gRollupListener = nullptr;
} }
} }
@ -7432,7 +7429,6 @@ bool nsWindow::CheckForRollup(gdouble aMouseX, gdouble aMouseY, bool aIsWheel,
rollupWidget = rollupListener->GetRollupWidget(); rollupWidget = rollupListener->GetRollupWidget();
} }
if (!rollupWidget) { if (!rollupWidget) {
nsBaseWidget::gRollupListener = nullptr;
return false; return false;
} }

Просмотреть файл

@ -190,8 +190,7 @@ class nsWindow final : public nsBaseWidget {
void SetWindowClass(const nsAString& xulWinType) override; void SetWindowClass(const nsAString& xulWinType) override;
LayoutDeviceIntPoint WidgetToScreenOffset() override; LayoutDeviceIntPoint WidgetToScreenOffset() override;
void CaptureMouse(bool aCapture) override; void CaptureMouse(bool aCapture) override;
void CaptureRollupEvents(nsIRollupListener* aListener, void CaptureRollupEvents(bool aDoCapture) override;
bool aDoCapture) override;
[[nodiscard]] nsresult GetAttention(int32_t aCycleCount) override; [[nodiscard]] nsresult GetAttention(int32_t aCycleCount) override;
bool HasPendingInputEvent() override; bool HasPendingInputEvent() override;

Просмотреть файл

@ -105,8 +105,6 @@ static int32_t gNumWidgets;
# include "nsCocoaFeatures.h" # include "nsCocoaFeatures.h"
#endif #endif
nsIRollupListener* nsBaseWidget::gRollupListener = nullptr;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::layers; using namespace mozilla::layers;
using namespace mozilla::ipc; using namespace mozilla::ipc;
@ -1805,9 +1803,7 @@ const widget::SizeConstraints nsBaseWidget::GetSizeConstraints() {
// static // static
nsIRollupListener* nsBaseWidget::GetActiveRollupListener() { nsIRollupListener* nsBaseWidget::GetActiveRollupListener() {
// If set, then this is likely an <html:select> dropdown. // TODO: Simplify this.
if (gRollupListener) return gRollupListener;
return nsXULPopupManager::GetInstance(); return nsXULPopupManager::GetInstance();
} }

Просмотреть файл

@ -165,8 +165,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
// nsIWidget interface // nsIWidget interface
void CaptureMouse(bool aCapture) override {} void CaptureMouse(bool aCapture) override {}
void CaptureRollupEvents(nsIRollupListener* aListener, void CaptureRollupEvents(bool aDoCapture) override {}
bool aDoCapture) override {}
nsIWidgetListener* GetWidgetListener() const override; nsIWidgetListener* GetWidgetListener() const override;
void SetWidgetListener(nsIWidgetListener* alistener) override; void SetWidgetListener(nsIWidgetListener* alistener) override;
void Destroy() override; void Destroy() override;
@ -730,8 +729,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
// a PANGESTURE_(MAY)START event). // a PANGESTURE_(MAY)START event).
bool mCurrentPanGestureBelongsToSwipe; bool mCurrentPanGestureBelongsToSwipe;
static nsIRollupListener* gRollupListener;
struct InitialZoomConstraints { struct InitialZoomConstraints {
InitialZoomConstraints(const uint32_t& aPresShellID, InitialZoomConstraints(const uint32_t& aPresShellID,
const ScrollableLayerGuid::ViewID& aViewID, const ScrollableLayerGuid::ViewID& aViewID,

Просмотреть файл

@ -1413,8 +1413,7 @@ class nsIWidget : public nsISupports {
* @param aDoCapture true enables capture, false disables capture * @param aDoCapture true enables capture, false disables capture
* *
*/ */
virtual void CaptureRollupEvents(nsIRollupListener* aListener, virtual void CaptureRollupEvents(bool aDoCapture) = 0;
bool aDoCapture) = 0;
/** /**
* Bring this window to the user's attention. This is intended to be a more * Bring this window to the user's attention. This is intended to be a more

Просмотреть файл

@ -3969,16 +3969,13 @@ void nsWindow::CaptureMouse(bool aCapture) {
* *
**************************************************************/ **************************************************************/
void nsWindow::CaptureRollupEvents(nsIRollupListener* aListener, void nsWindow::CaptureRollupEvents(bool aDoCapture) {
bool aDoCapture) {
if (aDoCapture) { if (aDoCapture) {
gRollupListener = aListener;
if (!sMsgFilterHook && !sCallProcHook && !sCallMouseHook) { if (!sMsgFilterHook && !sCallProcHook && !sCallMouseHook) {
RegisterSpecialDropdownHooks(); RegisterSpecialDropdownHooks();
} }
sProcessHook = true; sProcessHook = true;
} else { } else {
gRollupListener = nullptr;
sProcessHook = false; sProcessHook = false;
UnregisterSpecialDropdownHooks(); UnregisterSpecialDropdownHooks();
} }
@ -7483,7 +7480,7 @@ void nsWindow::OnDestroy() {
} }
if (this == rollupWidget) { if (this == rollupWidget) {
if (rollupListener) rollupListener->Rollup(0, false, nullptr, nullptr); if (rollupListener) rollupListener->Rollup(0, false, nullptr, nullptr);
CaptureRollupEvents(nullptr, false); CaptureRollupEvents(false);
} }
IMEHandler::OnDestroyWindow(this); IMEHandler::OnDestroyWindow(this);

Просмотреть файл

@ -229,8 +229,7 @@ class nsWindow final : public nsBaseWidget {
nsEventStatus& aStatus) override; nsEventStatus& aStatus) override;
void EnableDragDrop(bool aEnable) override; void EnableDragDrop(bool aEnable) override;
void CaptureMouse(bool aCapture) override; void CaptureMouse(bool aCapture) override;
void CaptureRollupEvents(nsIRollupListener* aListener, void CaptureRollupEvents(bool aDoCapture) override;
bool aDoCapture) override;
[[nodiscard]] nsresult GetAttention(int32_t aCycleCount) override; [[nodiscard]] nsresult GetAttention(int32_t aCycleCount) override;
bool HasPendingInputEvent() override; bool HasPendingInputEvent() override;
WindowRenderer* GetWindowRenderer() override; WindowRenderer* GetWindowRenderer() override;