tor-browser

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

commit f62d2edc173647e0b604c749ff1e3deff03064cb
parent 3ce095b0d11326e03204fa9335ac0474e379e47f
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Fri, 17 Oct 2025 20:26:55 +0000

Bug 1994964 - Remove GetViewToDispatchEvent. r=tnikkel,layout-reviewers

It's a very round-about way of getting the root frame of the pres
context's shell.

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

Diffstat:
Mdom/base/nsContentUtils.cpp | 29++---------------------------
Mdom/base/nsContentUtils.h | 2--
Mdom/base/nsDOMWindowUtils.cpp | 11++++-------
3 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp @@ -9457,25 +9457,6 @@ LayoutDeviceIntPoint nsContentUtils::ToWidgetPoint( visualRelative, aPresContext->AppUnitsPerDevPixel()); } -nsView* nsContentUtils::GetViewToDispatchEvent(nsPresContext* aPresContext, - PresShell** aPresShell) { - if (!aPresContext || !aPresShell) { - return nullptr; - } - RefPtr<PresShell> presShell = aPresContext->PresShell(); - if (NS_WARN_IF(!presShell)) { - *aPresShell = nullptr; - return nullptr; - } - nsViewManager* viewManager = presShell->GetViewManager(); - if (!viewManager) { - presShell.forget(aPresShell); // XXX Is this intentional? - return nullptr; - } - presShell.forget(aPresShell); - return viewManager->GetRootView(); -} - namespace { class SynthesizedMouseEventCallback final : public nsISynthesizedEventCallback { @@ -9636,14 +9617,8 @@ Result<bool, nsresult> nsContentUtils::SynthesizeMouseEvent( nsEventStatus status = nsEventStatus_eIgnore; if (aOptions.mToWindow) { - RefPtr<PresShell> presShell; - nsView* view = - GetViewToDispatchEvent(presContext, getter_AddRefs(presShell)); - if (!presShell || !view) { - return Err(NS_ERROR_FAILURE); - } - nsresult rv = presShell->HandleEvent(view->GetFrame(), &mouseOrPointerEvent, - false, &status); + nsresult rv = aPresShell->HandleEvent(aPresShell->GetRootFrame(), + &mouseOrPointerEvent, false, &status); if (NS_FAILED(rv)) { return Err(rv); } diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h @@ -3042,8 +3042,6 @@ class nsContentUtils { static mozilla::LayoutDeviceIntPoint ToWidgetPoint( const mozilla::CSSPoint& aPoint, const nsPoint& aOffset, nsPresContext* aPresContext); - static nsView* GetViewToDispatchEvent(nsPresContext* aPresContext, - mozilla::PresShell** aPresShell); /** * Synthesize a mouse event to the given widget diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp @@ -934,14 +934,11 @@ nsresult nsDOMWindowUtils::SendTouchEventCommon( nsEventStatus status = nsEventStatus_eIgnore; if (aToWindow) { - RefPtr<PresShell> presShell; - nsView* view = nsContentUtils::GetViewToDispatchEvent( - presContext, getter_AddRefs(presShell)); - if (!presShell || !view) { - return NS_ERROR_FAILURE; - } + RefPtr<PresShell> presShell = presContext->PresShell(); + // XXX shouldn't this happen _after_ DispatchEvent? *aPreventDefault = (status == nsEventStatus_eConsumeNoDefault); - return presShell->HandleEvent(view->GetFrame(), &event, false, &status); + return presShell->HandleEvent(presShell->GetRootFrame(), &event, false, + &status); } if (aAsyncEnabled == AsyncEnabledOption::ASYNC_ENABLED ||