Bug 1893119: Part 3 - Add widget to nsContentUtils::GetDragSession r=gstoll,rkraesig

Updates each client of the nsContentUtils method to get the right drag session -- the one for the widget that is currently the source or target of the drag session.
The change to nsDOMWindowUtils::DispatchDOMEventViaPresShellForTesting() supports the change to WidgetDragEvent::InitDropEffectForTests() and enabled a
large number of test fixes in the next patch.

Differential Revision: https://phabricator.services.mozilla.com/D211067
This commit is contained in:
David P
2024-07-04 07:48:04 +00:00
parent 6755e73ac9
commit 805b8742ba
14 changed files with 73 additions and 21 deletions

View File

@@ -5758,7 +5758,13 @@ static BrowserBridgeChild* GetChildBrowser(nsView* aView) {
void PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) {
// If drag session has started, we shouldn't synthesize mousemove event.
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
nsView* rootView = mViewManager ? mViewManager->GetRootView() : nullptr;
if (!rootView || !rootView->HasWidget()) {
mSynthMouseMoveEvent.Forget();
return;
}
nsCOMPtr<nsIDragSession> dragSession =
nsContentUtils::GetDragSession(rootView->GetWidget());
if (dragSession) {
mSynthMouseMoveEvent.Forget();
return;
@@ -5770,9 +5776,8 @@ void PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) {
mSynthMouseMoveEvent.Forget();
}
nsView* rootView = mViewManager ? mViewManager->GetRootView() : nullptr;
if (mMouseLocation == nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) ||
!rootView || !rootView->HasWidget() || !mPresContext) {
!mPresContext) {
mSynthMouseMoveEvent.Forget();
return;
}
@@ -8521,7 +8526,8 @@ bool PresShell::EventHandler::PrepareToDispatchEvent(
return true;
}
case eDrop: {
nsCOMPtr<nsIDragSession> session = nsContentUtils::GetDragSession();
nsCOMPtr<nsIDragSession> session =
nsContentUtils::GetDragSession(GetPresContext());
if (session) {
bool onlyChromeDrop = false;
session->GetOnlyChromeDrop(&onlyChromeDrop);