tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 8a43b19ddf11288b8bc4ded880d1833c50bfb949
parent e39acbf04c65cfdba9ef0996ab13b88285e10001
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Wed, 19 Nov 2025 01:27:02 +0000

Bug 2000999 - Remove nsIWidget::mUseAttachedEvents. r=tnikkel,layout-reviewers

It hasn't done anything useful for a while. The widget listener's shell
and the view's shell will always match for the cases where both exist.

For popups things go through nsMenuPopupFrame::HandleEvent now.

Differential Revision: https://phabricator.services.mozilla.com/D272975

Diffstat:
Mlayout/xul/nsMenuPopupFrame.cpp | 3+--
Mlayout/xul/nsMenuPopupFrame.h | 3+--
Mview/nsView.cpp | 20++------------------
Mview/nsView.h | 3+--
Mwidget/nsIWidget.cpp | 15++-------------
Mwidget/nsIWidget.h | 20+-------------------
Mwidget/nsIWidgetListener.h | 3+--
7 files changed, 9 insertions(+), 58 deletions(-)

diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp @@ -2565,8 +2565,7 @@ bool nsMenuPopupFrame::RequestWindowClose(nsIWidget* aWidget) { return false; } -nsEventStatus nsMenuPopupFrame::HandleEvent(mozilla::WidgetGUIEvent* aEvent, - bool aUseAttachedEvents) { +nsEventStatus nsMenuPopupFrame::HandleEvent(mozilla::WidgetGUIEvent* aEvent) { MOZ_ASSERT(aEvent->mWidget); MOZ_ASSERT(aEvent->mWidget == mWidget); nsEventStatus status = nsEventStatus_eIgnore; diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h @@ -204,8 +204,7 @@ class nsMenuPopupFrame final : public nsBlockFrame, public nsIWidgetListener { bool WindowResized(nsIWidget*, int32_t aWidth, int32_t aHeight) override; bool RequestWindowClose(nsIWidget*) override; MOZ_CAN_RUN_SCRIPT_BOUNDARY - nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent, - bool aUseAttachedEvents) override; + nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent) override; MOZ_CAN_RUN_SCRIPT_BOUNDARY bool PaintWindow(nsIWidget* aWidget, mozilla::LayoutDeviceIntRegion) override; void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId, diff --git a/view/nsView.cpp b/view/nsView.cpp @@ -173,10 +173,6 @@ void nsView::AttachToTopLevelWidget(nsIWidget* aWidget) { } } - // Note, the previous device context will be released. Detaching - // will not restore the old one. - aWidget->AttachViewToTopLevel(!nsIWidget::UsePuppetWidgets()); - mWindow = aWidget; mWindow->SetAttachedWidgetListener(this); @@ -367,24 +363,12 @@ void nsView::DidCompositeWindow(mozilla::layers::TransactionId aTransactionId, aCompositeEnd); } -nsEventStatus nsView::HandleEvent(WidgetGUIEvent* aEvent, - bool aUseAttachedEvents) { +nsEventStatus nsView::HandleEvent(WidgetGUIEvent* aEvent) { MOZ_ASSERT(aEvent->mWidget, "null widget ptr"); nsEventStatus result = nsEventStatus_eIgnore; - auto* listener = [&]() -> nsIWidgetListener* { - if (!aUseAttachedEvents) { - if (auto* l = aEvent->mWidget->GetWidgetListener()) { - return l; - } - } - return aEvent->mWidget->GetAttachedWidgetListener(); - }(); - if (NS_WARN_IF(!listener)) { - return result; - } nsViewManager::MaybeUpdateLastUserEventTime(aEvent); - if (RefPtr<PresShell> ps = listener->GetPresShell()) { + if (RefPtr<PresShell> ps = GetPresShell()) { if (nsIFrame* root = ps->GetRootFrame()) { ps->HandleEvent(root, aEvent, false, &result); } diff --git a/view/nsView.h b/view/nsView.h @@ -229,8 +229,7 @@ class nsView final : public nsIWidgetListener { const mozilla::TimeStamp& aCompositeStart, const mozilla::TimeStamp& aCompositeEnd) override; MOZ_CAN_RUN_SCRIPT_BOUNDARY - nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent, - bool aUseAttachedEvents) override; + nsEventStatus HandleEvent(mozilla::WidgetGUIEvent*) override; void SafeAreaInsetsChanged(const mozilla::LayoutDeviceIntMargin&) override; virtual ~nsView(); diff --git a/widget/nsIWidget.cpp b/widget/nsIWidget.cpp @@ -310,7 +310,6 @@ nsIWidget::nsIWidget(BorderStyle aBorderStyle) mPopupType(PopupType::Any), mHasRemoteContent(false), mUpdateCursor(true), - mUseAttachedEvents(false), mIMEHasFocus(false), mIMEHasQuit(false), mIsFullyOccluded(false), @@ -570,16 +569,6 @@ already_AddRefed<nsIWidget> nsIWidget::CreateChild( return widget.forget(); } -// Attach a view to our widget which we'll send events to. -void nsIWidget::AttachViewToTopLevel(bool aUseAttachedEvents) { - NS_ASSERTION(mWindowType == WindowType::TopLevel || - mWindowType == WindowType::Dialog || - mWindowType == WindowType::Invisible, - "Can't attach to window of that type"); - - mUseAttachedEvents = aUseAttachedEvents; -} - //------------------------------------------------------------------------- // // Close this nsIWidget @@ -653,10 +642,10 @@ LayoutDeviceIntSize nsIWidget::NormalSizeModeClientToWindowSizeDifference() { nsEventStatus nsIWidget::DispatchEvent(WidgetGUIEvent* aEvent) { if (mAttachedWidgetListener) { - return mAttachedWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); + return mAttachedWidgetListener->HandleEvent(aEvent); } if (mWidgetListener) { - return mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); + return mWidgetListener->HandleEvent(aEvent); } return nsEventStatus_eIgnore; } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h @@ -543,24 +543,7 @@ class nsIWidget : public nsSupportsWeakReference { const InitData&); /** - * Attach to a top level widget. - * - * In cases where a top level chrome widget is being used as a content - * container, attach a secondary listener and update the device - * context. The primary widget listener will continue to be called for - * notifications relating to the top-level window, whereas other - * notifications such as painting and events will instead be called via - * the attached listener. SetAttachedWidgetListener should be used to - * assign the attached listener. - * - * aUseAttachedEvents if true, events are sent to the attached listener - * instead of the normal listener. - */ - void AttachViewToTopLevel(bool aUseAttachedEvents); - - /** - * Accessor functions to get and set the attached listener. Used by - * nsView in connection with AttachViewToTopLevel above. + * Accessor functions to get and set the attached listener. */ void SetAttachedWidgetListener(nsIWidgetListener* aListener) { mAttachedWidgetListener = aListener; @@ -2445,7 +2428,6 @@ class nsIWidget : public nsSupportsWeakReference { mozilla::Maybe<FullscreenSavedState> mSavedBounds; bool mUpdateCursor; - bool mUseAttachedEvents; bool mIMEHasFocus; bool mIMEHasQuit; // if the window is fully occluded (rendering may be paused in response) diff --git a/widget/nsIWidgetListener.h b/widget/nsIWidgetListener.h @@ -153,8 +153,7 @@ class nsIWidgetListener { virtual bool IsPaintSuppressed() const { return false; } /** Handle an event. */ - virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent, - bool aUseAttachedEvents) { + virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent) { return nsEventStatus_eIgnore; }