/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class MockDragSession : public nsBaseDragSession { protected:
MOZ_CAN_RUN_SCRIPT nsresult
InvokeDragSessionImpl(nsIWidget* aWidget, nsIArray* aTransferableArray, const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
uint32_t aActionType) override { // In Windows' nsDragService, InvokeDragSessionImpl would establish a // nested (native) event loop that runs as long as the drag is happening. // See DoDragDrop in MSDN. // We cannot do anything like that here since it would block mochitest // from scripting behavior with MockDragServiceController::SendDragEvent.
// mDragAction is not yet handled properly in the MockDragService. // This should be updated with each drag event. Instead, we always MOVE. // // We still need to end the drag session on the source widget. // In normal (non-mock) Gecko operation, this happens regardless // of whether the drop/cancel happened over one of our widgets. // For instance, Windows does this in StartInvokingDragSession, after // DoDragDrop returns, gtk does this on eDragTaskSourceEnd and cocoa // does this in -[NSDraggingSource draggingSession: endedAt: operation:]. // // Here, we know the source and target are Gecko windows (the test // framework does not support dragging to/from other apps). We could // end the source drag session on drop and cancel, but sometimes we // will want a dragleave to end the session (representing a drag cancel // from Gecko) and other we times don't (like when dragging from one Gecko // widget to another). Therefore, we instead rely on the test to tell // us when to end the source session by calling // MockDragServiceController::EndSourceDragSession(). // Note that, like in non-mocked DND, we do this regardless of whether // the source and target were the same widget -- in that case, // EndDragSession is just called twice.
mDragAction = nsIDragService::DRAGDROP_ACTION_MOVE; return NS_OK;
}
};
auto clientPosInScreenCoords = widget->GetClientBounds().TopLeft();
widgetEvent->mRefPoint =
LayoutDeviceIntPoint(aScreenX, aScreenY) - clientPosInScreenCoords;
RefPtr<MockDragService> ds = mDragService;
if (aEventType == EventType::eDragEnter) { // We expect StartDragSession to return an "error" when a drag session // already exists, which it will since we are testing dragging from // inside Gecko, so we don't check the return value.
ds->StartDragSession(widget);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.