forked from mirrors/gecko-dev
Bug 1893119: Part 2 - Make C++ callers of nsIDragService::GetCurrentSession pass a widget a=diannaS
Content process callers must call nsIDragService::GetCurrentSession with the correct widget under the drag. For all callers, it is a sanity check. Original Revision: https://phabricator.services.mozilla.com/D211065 Differential Revision: https://phabricator.services.mozilla.com/D221155
This commit is contained in:
parent
a02ea29565
commit
bfefb51a43
8 changed files with 38 additions and 33 deletions
|
|
@ -2414,8 +2414,8 @@ void EventStateManager::StopTrackingDragGesture(bool aClearInChildProcesses) {
|
||||||
nsCOMPtr<nsIDragService> dragService =
|
nsCOMPtr<nsIDragService> dragService =
|
||||||
do_GetService("@mozilla.org/widget/dragservice;1");
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
||||||
if (dragService) {
|
if (dragService) {
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
RefPtr<nsIDragSession> dragSession =
|
||||||
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
dragService->GetCurrentSession(mPresContext->GetRootWidget());
|
||||||
if (!dragSession) {
|
if (!dragSession) {
|
||||||
// Only notify if there isn't a drag session active.
|
// Only notify if there isn't a drag session active.
|
||||||
dragService->RemoveAllChildProcesses();
|
dragService->RemoveAllChildProcesses();
|
||||||
|
|
@ -2807,8 +2807,11 @@ bool EventStateManager::DoDefaultDragStart(
|
||||||
// began. However, if we're handling drag session for synthesized events,
|
// began. However, if we're handling drag session for synthesized events,
|
||||||
// we need to initialize some information of the session. Therefore, we
|
// we need to initialize some information of the session. Therefore, we
|
||||||
// need to keep going for synthesized case.
|
// need to keep going for synthesized case.
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
if (MOZ_UNLIKELY(!mPresContext)) {
|
||||||
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
return true;
|
||||||
|
}
|
||||||
|
nsCOMPtr<nsIDragSession> dragSession =
|
||||||
|
dragService->GetCurrentSession(mPresContext->GetRootWidget());
|
||||||
if (dragSession && !dragSession->IsSynthesizedForTests()) {
|
if (dragSession && !dragSession->IsSynthesizedForTests()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -248,8 +248,12 @@ nsXULTooltipListener::HandleEvent(Event* aEvent) {
|
||||||
nsCOMPtr<nsIDragService> dragService =
|
nsCOMPtr<nsIDragService> dragService =
|
||||||
do_GetService("@mozilla.org/widget/dragservice;1");
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
||||||
NS_ENSURE_TRUE(dragService, NS_OK);
|
NS_ENSURE_TRUE(dragService, NS_OK);
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
auto* widgetGuiEvent = aEvent->WidgetEventPtr()->AsGUIEvent();
|
||||||
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
if (!widgetGuiEvent) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
nsCOMPtr<nsIDragSession> dragSession =
|
||||||
|
dragService->GetCurrentSession(widgetGuiEvent->mWidget);
|
||||||
if (dragSession) {
|
if (dragSession) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,10 +142,9 @@ MockDragServiceController::SendEvent(
|
||||||
ds->StartDragSession();
|
ds->StartDragSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
nsCOMPtr<nsIDragSession> currentDragSession = ds->GetCurrentSession(widget);
|
||||||
nsresult rv = ds->GetCurrentSession(getter_AddRefs(currentDragSession));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
switch (aEventType) {
|
switch (aEventType) {
|
||||||
case EventType::eMouseDown:
|
case EventType::eMouseDown:
|
||||||
case EventType::eMouseMove:
|
case EventType::eMouseMove:
|
||||||
|
|
|
||||||
|
|
@ -2692,8 +2692,7 @@ void nsWindow::OnDragEvent(int32_t aAction, int64_t aTime, float aX, float aY,
|
||||||
nsDragService::SetDropData(dropData);
|
nsDragService::SetDropData(dropData);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
nsCOMPtr<nsIDragSession> dragSession = dragService->GetCurrentSession(this);
|
||||||
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
|
||||||
if (dragSession) {
|
if (dragSession) {
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case eDragOver:
|
case eDragOver:
|
||||||
|
|
|
||||||
|
|
@ -3975,8 +3975,8 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
|
||||||
- (BOOL)isDragInProgress {
|
- (BOOL)isDragInProgress {
|
||||||
if (!mDragService) return NO;
|
if (!mDragService) return NO;
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
nsCOMPtr<nsIDragSession> dragSession =
|
||||||
mDragService->GetCurrentSession(getter_AddRefs(dragSession));
|
mDragService->GetCurrentSession(mGeckoChild);
|
||||||
return dragSession != nullptr;
|
return dragSession != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4112,8 +4112,8 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
|
||||||
mDragService->StartDragSession();
|
mDragService->StartDragSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
nsCOMPtr<nsIDragSession> dragSession =
|
||||||
mDragService->GetCurrentSession(getter_AddRefs(dragSession));
|
mDragService->GetCurrentSession(mGeckoChild);
|
||||||
if (dragSession) {
|
if (dragSession) {
|
||||||
if (aMessage == eDragOver) {
|
if (aMessage == eDragOver) {
|
||||||
// fire the drag event at the source. Just ignore whether it was
|
// fire the drag event at the source. Just ignore whether it was
|
||||||
|
|
|
||||||
|
|
@ -4940,8 +4940,8 @@ void nsWindow::OnContainerFocusOutEvent(GdkEventFocus* aEvent) {
|
||||||
const bool shouldRollupMenus = [&] {
|
const bool shouldRollupMenus = [&] {
|
||||||
nsCOMPtr<nsIDragService> dragService =
|
nsCOMPtr<nsIDragService> dragService =
|
||||||
do_GetService("@mozilla.org/widget/dragservice;1");
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
nsCOMPtr<nsIDragSession> dragSession =
|
||||||
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
dragService->GetCurrentSession(this);
|
||||||
if (!dragSession) {
|
if (!dragSession) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -7668,7 +7668,6 @@ bool nsWindow::CheckForRollup(gdouble aMouseX, gdouble aMouseY, bool aIsWheel,
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
|
||||||
bool nsWindow::DragInProgress() {
|
bool nsWindow::DragInProgress() {
|
||||||
nsCOMPtr<nsIDragService> dragService =
|
nsCOMPtr<nsIDragService> dragService =
|
||||||
do_GetService("@mozilla.org/widget/dragservice;1");
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
||||||
|
|
@ -7676,8 +7675,8 @@ bool nsWindow::DragInProgress() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
nsCOMPtr<nsIDragSession> currentDragSession =
|
||||||
dragService->GetCurrentSession(getter_AddRefs(currentDragSession));
|
dragService->GetCurrentSession(this);
|
||||||
return !!currentDragSession;
|
return !!currentDragSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7685,7 +7684,8 @@ bool nsWindow::DragInProgress() {
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1622107
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1622107
|
||||||
// We try to detect when Wayland compositor / gtk fails to deliver
|
// We try to detect when Wayland compositor / gtk fails to deliver
|
||||||
// info about finished D&D operations and cancel it on our own.
|
// info about finished D&D operations and cancel it on our own.
|
||||||
MOZ_CAN_RUN_SCRIPT static void WaylandDragWorkaround(GdkEventButton* aEvent) {
|
MOZ_CAN_RUN_SCRIPT static void WaylandDragWorkaround(nsWindow* aWindow,
|
||||||
|
GdkEventButton* aEvent) {
|
||||||
static int buttonPressCountWithDrag = 0;
|
static int buttonPressCountWithDrag = 0;
|
||||||
|
|
||||||
// We track only left button state as Firefox performs D&D on left
|
// We track only left button state as Firefox performs D&D on left
|
||||||
|
|
@ -7699,8 +7699,8 @@ MOZ_CAN_RUN_SCRIPT static void WaylandDragWorkaround(GdkEventButton* aEvent) {
|
||||||
if (!dragService) {
|
if (!dragService) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
nsCOMPtr<nsIDragSession> currentDragSession =
|
||||||
dragService->GetCurrentSession(getter_AddRefs(currentDragSession));
|
dragService->GetCurrentSession(aWindow);
|
||||||
|
|
||||||
if (!currentDragSession) {
|
if (!currentDragSession) {
|
||||||
buttonPressCountWithDrag = 0;
|
buttonPressCountWithDrag = 0;
|
||||||
|
|
@ -8360,7 +8360,7 @@ static gboolean button_press_event_cb(GtkWidget* widget,
|
||||||
window->OnButtonPressEvent(event);
|
window->OnButtonPressEvent(event);
|
||||||
|
|
||||||
if (GdkIsWaylandDisplay()) {
|
if (GdkIsWaylandDisplay()) {
|
||||||
WaylandDragWorkaround(event);
|
WaylandDragWorkaround(window, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
||||||
|
|
@ -802,7 +802,7 @@ class nsWindow final : public nsBaseWidget {
|
||||||
|
|
||||||
InputRegion mInputRegion;
|
InputRegion mInputRegion;
|
||||||
|
|
||||||
static bool DragInProgress(void);
|
bool DragInProgress(void);
|
||||||
|
|
||||||
void DispatchMissedButtonReleases(GdkEventCrossing* aGdkEvent);
|
void DispatchMissedButtonReleases(GdkEventCrossing* aGdkEvent);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,8 +166,8 @@ void nsNativeDragTarget::ProcessDrag(EventMessage aEventMessage,
|
||||||
GetGeckoDragAction(grfKeyState, pdwEffect, &geckoAction);
|
GetGeckoDragAction(grfKeyState, pdwEffect, &geckoAction);
|
||||||
|
|
||||||
// Set the current action into the Gecko specific type
|
// Set the current action into the Gecko specific type
|
||||||
nsCOMPtr<nsIDragSession> currSession;
|
RefPtr<nsDragSession> currSession =
|
||||||
mDragService->GetCurrentSession(getter_AddRefs(currSession));
|
static_cast<nsDragSession*>(mDragService->GetCurrentSession(mWidget));
|
||||||
if (!currSession) {
|
if (!currSession) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -298,8 +298,8 @@ nsNativeDragTarget::DragOver(DWORD grfKeyState, POINTL ptl, LPDWORD pdwEffect) {
|
||||||
// then we should include it as an allowed effect.
|
// then we should include it as an allowed effect.
|
||||||
mEffectsAllowed = (*pdwEffect) | (mEffectsAllowed & DROPEFFECT_LINK);
|
mEffectsAllowed = (*pdwEffect) | (mEffectsAllowed & DROPEFFECT_LINK);
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
nsCOMPtr<nsIDragSession> currentDragSession =
|
||||||
mDragService->GetCurrentSession(getter_AddRefs(currentDragSession));
|
mDragService->GetCurrentSession(mWidget);
|
||||||
if (!currentDragSession) {
|
if (!currentDragSession) {
|
||||||
return S_OK; // Drag was canceled.
|
return S_OK; // Drag was canceled.
|
||||||
}
|
}
|
||||||
|
|
@ -349,8 +349,8 @@ nsNativeDragTarget::DragLeave() {
|
||||||
// dispatch the event into Gecko
|
// dispatch the event into Gecko
|
||||||
DispatchDragDropEvent(eDragExit, gDragLastPoint);
|
DispatchDragDropEvent(eDragExit, gDragLastPoint);
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
nsCOMPtr<nsIDragSession> currentDragSession =
|
||||||
mDragService->GetCurrentSession(getter_AddRefs(currentDragSession));
|
mDragService->GetCurrentSession(mWidget);
|
||||||
|
|
||||||
if (currentDragSession) {
|
if (currentDragSession) {
|
||||||
nsCOMPtr<nsINode> sourceNode;
|
nsCOMPtr<nsINode> sourceNode;
|
||||||
|
|
@ -426,8 +426,8 @@ nsNativeDragTarget::Drop(LPDATAOBJECT pData, DWORD grfKeyState, POINTL aPT,
|
||||||
// Now process the native drag state and then dispatch the event
|
// Now process the native drag state and then dispatch the event
|
||||||
ProcessDrag(eDrop, grfKeyState, aPT, pdwEffect);
|
ProcessDrag(eDrop, grfKeyState, aPT, pdwEffect);
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
nsCOMPtr<nsIDragSession> currentDragSession =
|
||||||
serv->GetCurrentSession(getter_AddRefs(currentDragSession));
|
serv->GetCurrentSession(mWidget);
|
||||||
if (!currentDragSession) {
|
if (!currentDragSession) {
|
||||||
return S_OK; // DragCancel() was called.
|
return S_OK; // DragCancel() was called.
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue