@@ -4146,20 +4146,6 @@ void PresShell::SchedulePaint() {
41464146 }
41474147}
41484148
4149- void PresShell::DispatchSynthMouseOrPointerMove (
4150- WidgetMouseEvent* aMouseOrPointerMoveEvent) {
4151- AUTO_PROFILER_TRACING_MARKER_DOCSHELL (" Paint" ,
4152- " DispatchSynthMouseOrPointerMove" ,
4153- GRAPHICS, mPresContext ->GetDocShell ());
4154- nsEventStatus status = nsEventStatus_eIgnore;
4155- nsView* targetView = nsView::GetViewFor (aMouseOrPointerMoveEvent->mWidget );
4156- if (!targetView) {
4157- return ;
4158- }
4159- RefPtr<nsViewManager> viewManager = targetView->GetViewManager ();
4160- viewManager->DispatchEvent (aMouseOrPointerMoveEvent, targetView, &status);
4161- }
4162-
41634149void PresShell::ClearMouseCaptureOnView (nsView* aView) {
41644150 if (nsIContent* capturingContent = GetCapturingContent ()) {
41654151 if (aView) {
@@ -5910,13 +5896,12 @@ void PresShell::SynthesizeMouseMove(bool aFromScroll) {
59105896 }
59115897}
59125898
5913- static nsView* FindFloatingViewContaining (nsPresContext* aRootPresContext,
5914- nsIWidget* aRootWidget,
5915- const LayoutDeviceIntPoint& aPt) {
5916- nsIFrame* popupFrame = nsLayoutUtils::GetPopupFrameForPoint (
5899+ static nsMenuPopupFrame* FindPopupFrame (nsPresContext* aRootPresContext,
5900+ nsIWidget* aRootWidget,
5901+ const LayoutDeviceIntPoint& aPt) {
5902+ return nsLayoutUtils::GetPopupFrameForPoint (
59175903 aRootPresContext, aRootWidget, aPt,
59185904 nsLayoutUtils::GetPopupFrameForPointFlags::OnlyReturnFramesWithWidgets);
5919- return popupFrame ? popupFrame->GetView () : nullptr ;
59205905}
59215906
59225907/*
@@ -5925,8 +5910,7 @@ static nsView* FindFloatingViewContaining(nsPresContext* aRootPresContext,
59255910 * floating view. It assumes that only floating views extend outside the bounds
59265911 * of their parents.
59275912 *
5928- * This methods should only be called if FindFloatingViewContaining returns
5929- * null.
5913+ * This methods should only be called if FindPopupFrame returns null.
59305914 *
59315915 * aPt is relative aRelativeToView with the viewport type
59325916 * aRelativeToViewportType. aRelativeToView will always have a frame. If aView
@@ -6123,82 +6107,77 @@ void PresShell::ProcessSynthMouseOrPointerMoveEvent(
61236107
61246108 int32_t APD = mPresContext ->AppUnitsPerDevPixel ();
61256109
6126- // We need a widget to put in the event we are going to dispatch so we look
6127- // for a view that has a widget and the mouse location is over. We first look
6128- // for floating views, if there isn't one we use the root view. |view| holds
6129- // that view.
6130- nsView* view = nullptr ;
6131-
6132- // The appunits per devpixel ratio of |view|.
6133- int32_t viewAPD;
6134-
61356110 // mRefPoint will be mMouseLocation relative to the widget of |view|, the
6136- // widget we will put in the event we dispatch, in viewAPD appunits
6111+ // widget we will put in the event we dispatch, in widgetAPD appunits
61376112 nsPoint refpoint (0 , 0 );
61386113
6139- // We always dispatch the event to the pres shell that contains the view that
6140- // the mouse is over. pointVM is the VM of that pres shell.
6141- nsViewManager* pointVM = nullptr ;
6142-
61436114 nsView* const rootView = mViewManager ? mViewManager ->GetRootView () : nullptr ;
61446115 if (!rootView || !rootView->HasWidget ()) {
61456116 return ;
61466117 }
6147- #ifdef DEBUG
6148- nsCOMPtr<nsIDragSession> dragSession =
6149- nsContentUtils::GetDragSession (rootView->GetWidget ());
6150- MOZ_ASSERT (!dragSession);
6151- #endif
6118+ MOZ_ASSERT (!nsCOMPtr{nsContentUtils::GetDragSession (rootView->GetWidget ())});
61526119
6120+ // We need a widget to put in the event we are going to dispatch so we look
6121+ // for a view that has a widget and the mouse location is over. We first look
6122+ // for floating views, if there isn't one we use the root view. |view| holds
6123+ // that view.
6124+ nsCOMPtr<nsIWidget> widget;
6125+ // We always dispatch the event to the pres shell that contains the view that
6126+ // the mouse is over. pointShell is that.
6127+ RefPtr<PresShell> pointShell;
6128+ // The appunits per devpixel ratio of |widget|.
6129+ int32_t widgetAPD;
6130+ // If we're in a child process and the view points to an OOP iframe, this is
6131+ // its BrowserBridgeChild.
6132+ RefPtr<BrowserBridgeChild> bbc;
6133+
6134+ // We either dispatch the event to a popup, or a view.
6135+ nsMenuPopupFrame* popupFrame = nullptr ;
61536136 if (rootView->GetFrame ()) {
6154- view =
6155- FindFloatingViewContaining (mPresContext , rootView->GetWidget (),
6156- LayoutDeviceIntPoint::FromAppUnitsToNearest (
6157- aPointerInfo.mLastRefPointInRootDoc +
6158- rootView->ViewToWidgetOffset (),
6159- APD));
6160- }
6161-
6162- nsView* pointView = view;
6163- if (!view) {
6164- view = rootView;
6137+ popupFrame = FindPopupFrame (mPresContext , rootView->GetWidget (),
6138+ LayoutDeviceIntPoint::FromAppUnitsToNearest (
6139+ aPointerInfo.mLastRefPointInRootDoc +
6140+ rootView->ViewToWidgetOffset (),
6141+ APD));
6142+ if (popupFrame) {
6143+ pointShell = popupFrame->PresShell ();
6144+ widget = popupFrame->GetWidget ();
6145+ widgetAPD = popupFrame->PresContext ()->AppUnitsPerDevPixel ();
6146+ refpoint = aPointerInfo.mLastRefPointInRootDoc ;
6147+ DebugOnly<nsLayoutUtils::TransformResult> result =
6148+ nsLayoutUtils::TransformPoint (
6149+ RelativeTo{rootView->GetFrame (), ViewportType::Visual},
6150+ RelativeTo{popupFrame, ViewportType::Layout}, refpoint);
6151+ MOZ_ASSERT (result == nsLayoutUtils::TRANSFORM_SUCCEEDED);
6152+ }
6153+ }
6154+ if (!widget) {
6155+ widget = rootView->GetWidget ();
6156+ widgetAPD = APD;
6157+ nsView* pointView = rootView;
61656158 if (rootView->GetFrame ()) {
61666159 pointView = FindViewContaining (rootView, ViewportType::Visual, rootView,
61676160 aPointerInfo.mLastRefPointInRootDoc );
6168- } else {
6169- pointView = rootView;
61706161 }
61716162 // pointView can be null in situations related to mouse capture
6172- pointVM = (pointView ? pointView : view)->GetViewManager ();
6163+ pointShell = (pointView ? pointView : rootView)->GetPresShell ();
6164+ bbc = GetChildBrowser (pointView);
61736165 refpoint =
61746166 aPointerInfo.mLastRefPointInRootDoc + rootView->ViewToWidgetOffset ();
6175- viewAPD = APD;
6176- } else {
6177- pointVM = view->GetViewManager ();
6178- nsIFrame* frame = view->GetFrame ();
6179- NS_ASSERTION (frame, " floating views can't be anonymous" );
6180- viewAPD = frame->PresContext ()->AppUnitsPerDevPixel ();
6181- refpoint = aPointerInfo.mLastRefPointInRootDoc ;
6182- DebugOnly<nsLayoutUtils::TransformResult> result =
6183- nsLayoutUtils::TransformPoint (
6184- RelativeTo{rootView->GetFrame (), ViewportType::Visual},
6185- RelativeTo{frame, ViewportType::Layout}, refpoint);
6186- MOZ_ASSERT (result == nsLayoutUtils::TRANSFORM_SUCCEEDED);
6187- refpoint += view->ViewToWidgetOffset ();
6188- }
6189- NS_ASSERTION (view->GetWidget (), "view should have a widget here");
6167+ }
6168+ NS_ASSERTION (widget, " view should have a widget here" );
61906169 Maybe<WidgetMouseEvent> mouseMoveEvent;
61916170 Maybe<WidgetPointerEvent> pointerMoveEvent;
61926171 if (aMoveMessage == eMouseMove) {
6193- mouseMoveEvent.emplace (true , eMouseMove, view-> GetWidget () ,
6172+ mouseMoveEvent.emplace (true , eMouseMove, widget ,
61946173 WidgetMouseEvent::eSynthesized);
61956174 mouseMoveEvent->mButton = MouseButton::ePrimary;
61966175 // We don't want to dispatch preceding pointer event since the caller
61976176 // should've already been dispatched it. However, if the target is an OOP
61986177 // iframe, we'll set this to true again below.
61996178 mouseMoveEvent->convertToPointer = false ;
62006179 } else {
6201- pointerMoveEvent.emplace (true , ePointerMove, view-> GetWidget () );
6180+ pointerMoveEvent.emplace (true , ePointerMove, widget );
62026181 pointerMoveEvent->mButton = MouseButton::eNotPressed;
62036182 pointerMoveEvent->mReason = WidgetMouseEvent::eSynthesized;
62046183 }
@@ -6214,13 +6193,13 @@ void PresShell::ProcessSynthMouseOrPointerMoveEvent(
62146193 event.mFlags .mIsSynthesizedForTests = aPointerInfo.mIsSynthesizedForTests ;
62156194
62166195 event.mRefPoint =
6217- LayoutDeviceIntPoint::FromAppUnitsToNearest (refpoint, viewAPD );
6196+ LayoutDeviceIntPoint::FromAppUnitsToNearest (refpoint, widgetAPD );
62186197 event.mButtons = aPointerInfo.mLastButtons ;
62196198 event.mInputSource = aPointerInfo.mInputSource ;
62206199 event.pointerId = aPointerId;
62216200 event.mModifiers = PresShell::GetCurrentModifiers ();
62226201
6223- if (BrowserBridgeChild* bbc = GetChildBrowser (pointView) ) {
6202+ if (bbc) {
62246203 // If we have a BrowserBridgeChild, we're going to be dispatching this
62256204 // mouse event into an OOP iframe of the current document if and only if
62266205 // we're synthesizing a mouse move.
@@ -6237,7 +6216,7 @@ void PresShell::ProcessSynthMouseOrPointerMoveEvent(
62376216 return ;
62386217 }
62396218
6240- if (RefPtr<PresShell> presShell = pointVM-> GetPresShell () ) {
6219+ if (pointShell ) {
62416220 // Since this gets run in a refresh tick there isn't an InputAPZContext on
62426221 // the stack from the nsBaseWidget. We need to simulate one with at least
62436222 // the correct target guid, so that the correct callback transform gets
@@ -6246,7 +6225,16 @@ void PresShell::ProcessSynthMouseOrPointerMoveEvent(
62466225 // input block. Same for the APZ response field.
62476226 InputAPZContext apzContext (aPointerInfo.mLastTargetGuid , 0 ,
62486227 nsEventStatus_eIgnore);
6249- presShell->DispatchSynthMouseOrPointerMove (&event);
6228+ AUTO_PROFILER_TRACING_MARKER_DOCSHELL (
6229+ " Paint" , " DispatchSynthMouseOrPointerMove" , GRAPHICS,
6230+ pointShell->GetPresContext ()->GetDocShell ());
6231+ nsEventStatus status = nsEventStatus_eIgnore;
6232+ if (popupFrame) {
6233+ pointShell->HandleEvent (popupFrame, &event, false , &status);
6234+ } else {
6235+ RefPtr<nsViewManager> viewManager = rootView->GetViewManager ();
6236+ viewManager->DispatchEvent (&event, rootView, &status);
6237+ }
62506238 }
62516239}
62526240
0 commit comments