2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1999-04-17 01:03:32 +04:00
|
|
|
|
|
|
|
#include "nsBaseDragService.h"
|
|
|
|
#include "nsITransferable.h"
|
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsITransferable.h"
|
1999-05-07 23:51:50 +04:00
|
|
|
#include "nsISupportsArray.h"
|
1999-04-17 01:03:32 +04:00
|
|
|
#include "nsSize.h"
|
2002-09-04 03:36:13 +04:00
|
|
|
#include "nsXPCOM.h"
|
1999-08-25 12:35:06 +04:00
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2007-03-20 15:14:52 +03:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-08-16 05:46:34 +04:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIPresShell.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsViewManager.h"
|
2000-08-16 05:46:34 +04:00
|
|
|
#include "nsIDOMNode.h"
|
2008-08-27 16:07:27 +04:00
|
|
|
#include "nsIDOMDragEvent.h"
|
2007-03-20 15:14:52 +03:00
|
|
|
#include "nsISelection.h"
|
|
|
|
#include "nsISelectionPrivate.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2008-08-27 16:07:27 +04:00
|
|
|
#include "nsIDOMDataTransfer.h"
|
2007-03-20 15:14:52 +03:00
|
|
|
#include "nsIImageLoadingContent.h"
|
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "imgIRequest.h"
|
2014-08-23 00:12:38 +04:00
|
|
|
#include "ImageRegion.h"
|
2007-03-20 15:14:52 +03:00
|
|
|
#include "nsRegion.h"
|
2011-04-26 05:37:20 +04:00
|
|
|
#include "nsXULPopupManager.h"
|
|
|
|
#include "nsMenuPopupFrame.h"
|
2014-08-23 00:12:38 +04:00
|
|
|
#include "SVGImageContext.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2011-05-23 18:54:03 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-01-29 04:10:33 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "nsFrameLoader.h"
|
|
|
|
#include "TabParent.h"
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
#include "gfxContext.h"
|
2009-04-22 16:55:51 +04:00
|
|
|
#include "gfxPlatform.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2007-03-20 15:14:52 +03:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
using namespace mozilla;
|
2014-04-17 09:30:45 +04:00
|
|
|
using namespace mozilla::dom;
|
2014-08-23 00:12:38 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
using namespace mozilla::image;
|
2011-05-23 18:54:03 +04:00
|
|
|
|
2007-05-16 22:05:23 +04:00
|
|
|
#define DRAGIMAGES_PREF "nglayout.enable_drag_images"
|
|
|
|
|
2005-03-15 01:49:00 +03:00
|
|
|
nsBaseDragService::nsBaseDragService()
|
2011-10-17 18:59:28 +04:00
|
|
|
: mCanDrop(false), mOnlyChromeDrop(false), mDoingDrag(false),
|
|
|
|
mHasImage(false), mUserCancelled(false),
|
2015-04-08 21:48:11 +03:00
|
|
|
mDragEventDispatchedToChildProcess(false),
|
2015-06-05 15:33:29 +03:00
|
|
|
mDragAction(DRAGDROP_ACTION_NONE),
|
|
|
|
mDragActionFromChildProcess(DRAGDROP_ACTION_UNINITIALIZED), mTargetSize(0,0),
|
2015-09-29 03:44:50 +03:00
|
|
|
mScreenX(-1), mScreenY(-1), mSuppressLevel(0),
|
2011-08-26 11:43:56 +04:00
|
|
|
mInputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
|
1999-04-17 01:03:32 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseDragService::~nsBaseDragService()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsBaseDragService, nsIDragService, nsIDragSession)
|
1999-04-17 01:03:32 +04:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBaseDragService::SetCanDrop(bool aCanDrop)
|
1999-04-17 01:03:32 +04:00
|
|
|
{
|
2005-03-15 01:49:00 +03:00
|
|
|
mCanDrop = aCanDrop;
|
|
|
|
return NS_OK;
|
1999-04-17 01:03:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBaseDragService::GetCanDrop(bool * aCanDrop)
|
1999-04-17 01:03:32 +04:00
|
|
|
{
|
|
|
|
*aCanDrop = mCanDrop;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-10-29 14:11:02 +03:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBaseDragService::SetOnlyChromeDrop(bool aOnlyChrome)
|
2009-10-29 14:11:02 +03:00
|
|
|
{
|
|
|
|
mOnlyChromeDrop = aOnlyChrome;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBaseDragService::GetOnlyChromeDrop(bool* aOnlyChrome)
|
2009-10-29 14:11:02 +03:00
|
|
|
{
|
|
|
|
*aOnlyChrome = mOnlyChromeDrop;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-04-17 01:03:32 +04:00
|
|
|
|
1999-04-23 18:13:06 +04:00
|
|
|
//---------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBaseDragService::SetDragAction(uint32_t anAction)
|
1999-04-23 18:13:06 +04:00
|
|
|
{
|
2005-03-16 03:40:21 +03:00
|
|
|
mDragAction = anAction;
|
|
|
|
return NS_OK;
|
1999-04-23 18:13:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBaseDragService::GetDragAction(uint32_t * anAction)
|
1999-04-23 18:13:06 +04:00
|
|
|
{
|
|
|
|
*anAction = mDragAction;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-17 01:03:32 +04:00
|
|
|
//---------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::SetTargetSize(nsSize aDragTargetSize)
|
1999-04-17 01:03:32 +04:00
|
|
|
{
|
2005-03-15 01:49:00 +03:00
|
|
|
mTargetSize = aDragTargetSize;
|
|
|
|
return NS_OK;
|
1999-04-17 01:03:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::GetTargetSize(nsSize * aDragTargetSize)
|
1999-04-17 01:03:32 +04:00
|
|
|
{
|
|
|
|
*aDragTargetSize = mTargetSize;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-27 01:08:14 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBaseDragService::GetNumDropItems(uint32_t * aNumItems)
|
1999-05-27 01:08:14 +04:00
|
|
|
{
|
|
|
|
*aNumItems = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-01 00:51:42 +04:00
|
|
|
//
|
|
|
|
// GetSourceDocument
|
|
|
|
//
|
|
|
|
// Returns the DOM document where the drag was initiated. This will be
|
2012-07-30 18:20:58 +04:00
|
|
|
// nullptr if the drag began outside of our application.
|
2000-08-01 00:51:42 +04:00
|
|
|
//
|
|
|
|
NS_IMETHODIMP
|
2005-03-15 01:49:00 +03:00
|
|
|
nsBaseDragService::GetSourceDocument(nsIDOMDocument** aSourceDocument)
|
2000-08-01 00:51:42 +04:00
|
|
|
{
|
|
|
|
*aSourceDocument = mSourceDocument.get();
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IF_ADDREF(*aSourceDocument);
|
|
|
|
|
2000-08-01 00:51:42 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-20 09:58:25 +04:00
|
|
|
//
|
|
|
|
// GetSourceNode
|
|
|
|
//
|
|
|
|
// Returns the DOM node where the drag was initiated. This will be
|
2012-07-30 18:20:58 +04:00
|
|
|
// nullptr if the drag began outside of our application.
|
2001-05-20 09:58:25 +04:00
|
|
|
//
|
|
|
|
NS_IMETHODIMP
|
2005-03-15 01:49:00 +03:00
|
|
|
nsBaseDragService::GetSourceNode(nsIDOMNode** aSourceNode)
|
2001-05-20 09:58:25 +04:00
|
|
|
{
|
|
|
|
*aSourceNode = mSourceNode.get();
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IF_ADDREF(*aSourceNode);
|
|
|
|
|
2001-05-20 09:58:25 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-17 01:03:32 +04:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
1999-05-27 01:08:14 +04:00
|
|
|
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::GetData(nsITransferable * aTransferable,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aItemIndex)
|
1999-05-07 23:51:50 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::IsDataFlavorSupported(const char *aDataFlavor,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool *_retval)
|
1999-05-07 23:51:50 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-04-17 01:03:32 +04:00
|
|
|
|
2008-08-27 16:07:27 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
|
|
|
|
{
|
|
|
|
*aDataTransfer = mDataTransfer;
|
|
|
|
NS_IF_ADDREF(*aDataTransfer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::SetDataTransfer(nsIDOMDataTransfer* aDataTransfer)
|
|
|
|
{
|
|
|
|
mDataTransfer = aDataTransfer;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-07 23:51:50 +04:00
|
|
|
//-------------------------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
2007-03-20 15:14:52 +03:00
|
|
|
nsISupportsArray* aTransferableArray,
|
|
|
|
nsIScriptableRegion* aDragRgn,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aActionType)
|
1999-04-17 01:03:32 +04:00
|
|
|
{
|
2005-03-16 03:40:21 +03:00
|
|
|
NS_ENSURE_TRUE(aDOMNode, NS_ERROR_INVALID_ARG);
|
2008-03-19 03:06:22 +03:00
|
|
|
NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
|
2005-03-16 03:40:21 +03:00
|
|
|
|
|
|
|
// stash the document of the dom node
|
|
|
|
aDOMNode->GetOwnerDocument(getter_AddRefs(mSourceDocument));
|
|
|
|
mSourceNode = aDOMNode;
|
2009-04-16 19:58:23 +04:00
|
|
|
mEndDragPoint = nsIntPoint(0, 0);
|
2005-03-16 03:40:21 +03:00
|
|
|
|
|
|
|
// When the mouse goes down, the selection code starts a mouse
|
|
|
|
// capture. However, this gets in the way of determining drag
|
|
|
|
// feedback for things like trees because the event coordinates
|
2009-09-13 17:13:16 +04:00
|
|
|
// are in the wrong coord system, so turn off mouse capture.
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIPresShell::ClearMouseCapture(nullptr);
|
2005-03-16 03:40:21 +03:00
|
|
|
|
2000-08-01 00:51:42 +04:00
|
|
|
return NS_OK;
|
1999-04-17 01:03:32 +04:00
|
|
|
}
|
|
|
|
|
2007-03-20 15:14:52 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::InvokeDragSessionWithImage(nsIDOMNode* aDOMNode,
|
|
|
|
nsISupportsArray* aTransferableArray,
|
|
|
|
nsIScriptableRegion* aRegion,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aActionType,
|
2007-03-20 15:14:52 +03:00
|
|
|
nsIDOMNode* aImage,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aImageX, int32_t aImageY,
|
2008-08-27 16:07:27 +04:00
|
|
|
nsIDOMDragEvent* aDragEvent,
|
|
|
|
nsIDOMDataTransfer* aDataTransfer)
|
2007-03-20 15:14:52 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(aDragEvent, NS_ERROR_NULL_POINTER);
|
2008-08-27 16:07:27 +04:00
|
|
|
NS_ENSURE_TRUE(aDataTransfer, NS_ERROR_NULL_POINTER);
|
2008-03-19 03:06:22 +03:00
|
|
|
NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
|
2007-03-20 15:14:52 +03:00
|
|
|
|
2008-08-27 16:07:27 +04:00
|
|
|
mDataTransfer = aDataTransfer;
|
2012-07-30 18:20:58 +04:00
|
|
|
mSelection = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasImage = true;
|
2012-07-30 18:20:58 +04:00
|
|
|
mDragPopup = nullptr;
|
2007-03-20 15:14:52 +03:00
|
|
|
mImage = aImage;
|
2015-09-29 03:44:50 +03:00
|
|
|
mImageOffset = CSSIntPoint(aImageX, aImageY);
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
aDragEvent->GetScreenX(&mScreenX);
|
|
|
|
aDragEvent->GetScreenY(&mScreenY);
|
2011-08-26 11:43:56 +04:00
|
|
|
aDragEvent->GetMozInputSource(&mInputSource);
|
2010-04-06 16:59:24 +04:00
|
|
|
|
2007-03-20 15:14:52 +03:00
|
|
|
return InvokeDragSession(aDOMNode, aTransferableArray, aRegion, aActionType);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::InvokeDragSessionWithSelection(nsISelection* aSelection,
|
|
|
|
nsISupportsArray* aTransferableArray,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aActionType,
|
2008-08-27 16:07:27 +04:00
|
|
|
nsIDOMDragEvent* aDragEvent,
|
|
|
|
nsIDOMDataTransfer* aDataTransfer)
|
2007-03-20 15:14:52 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
|
|
|
|
NS_ENSURE_TRUE(aDragEvent, NS_ERROR_NULL_POINTER);
|
2008-03-19 03:06:22 +03:00
|
|
|
NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
|
2007-03-20 15:14:52 +03:00
|
|
|
|
2008-08-27 16:07:27 +04:00
|
|
|
mDataTransfer = aDataTransfer;
|
2007-03-20 15:14:52 +03:00
|
|
|
mSelection = aSelection;
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasImage = true;
|
2012-07-30 18:20:58 +04:00
|
|
|
mDragPopup = nullptr;
|
|
|
|
mImage = nullptr;
|
2015-09-29 03:44:50 +03:00
|
|
|
mImageOffset = CSSIntPoint();
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
aDragEvent->GetScreenX(&mScreenX);
|
|
|
|
aDragEvent->GetScreenY(&mScreenY);
|
2011-08-26 11:43:56 +04:00
|
|
|
aDragEvent->GetMozInputSource(&mInputSource);
|
2010-04-06 16:59:24 +04:00
|
|
|
|
2007-03-20 15:14:52 +03:00
|
|
|
// just get the focused node from the selection
|
2008-08-27 16:07:27 +04:00
|
|
|
// XXXndeakin this should actually be the deepest node that contains both
|
|
|
|
// endpoints of the selection
|
2007-03-20 15:14:52 +03:00
|
|
|
nsCOMPtr<nsIDOMNode> node;
|
|
|
|
aSelection->GetFocusNode(getter_AddRefs(node));
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return InvokeDragSession(node, aTransferableArray, nullptr, aActionType);
|
2007-03-20 15:14:52 +03:00
|
|
|
}
|
1999-05-07 23:51:50 +04:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::GetCurrentSession(nsIDragSession ** aSession)
|
1999-05-07 23:51:50 +04:00
|
|
|
{
|
2005-03-15 01:49:00 +03:00
|
|
|
if (!aSession)
|
1999-05-07 23:51:50 +04:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
2005-03-15 01:49:00 +03:00
|
|
|
|
|
|
|
// "this" also implements a drag session, so say we are one but only
|
|
|
|
// if there is currently a drag going on.
|
2008-03-19 03:06:22 +03:00
|
|
|
if (!mSuppressLevel && mDoingDrag) {
|
1999-05-07 23:51:50 +04:00
|
|
|
*aSession = this;
|
1999-08-25 12:35:06 +04:00
|
|
|
NS_ADDREF(*aSession); // addRef because we're a "getter"
|
1999-05-07 23:51:50 +04:00
|
|
|
}
|
|
|
|
else
|
2012-07-30 18:20:58 +04:00
|
|
|
*aSession = nullptr;
|
2005-03-15 01:49:00 +03:00
|
|
|
|
1999-05-07 23:51:50 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::StartDragSession()
|
1999-05-07 23:51:50 +04:00
|
|
|
{
|
|
|
|
if (mDoingDrag) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mDoingDrag = true;
|
2009-10-29 14:11:02 +03:00
|
|
|
// By default dispatch drop also to content.
|
2011-10-17 18:59:28 +04:00
|
|
|
mOnlyChromeDrop = false;
|
2011-04-26 05:37:20 +04:00
|
|
|
|
1999-05-07 23:51:50 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
void
|
|
|
|
nsBaseDragService::OpenDragPopup()
|
|
|
|
{
|
|
|
|
if (mDragPopup) {
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
|
|
if (pm) {
|
2015-09-29 03:44:50 +03:00
|
|
|
pm->ShowPopupAtScreen(mDragPopup, mScreenX - mImageOffset.x,
|
|
|
|
mScreenY - mImageOffset.y, false, nullptr);
|
2011-04-26 05:37:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-05 15:33:29 +03:00
|
|
|
int32_t
|
|
|
|
nsBaseDragService::TakeChildProcessDragAction()
|
|
|
|
{
|
|
|
|
// If the last event was dispatched to the child process, use the drag action
|
|
|
|
// assigned from it instead and return it. DRAGDROP_ACTION_UNINITIALIZED is
|
|
|
|
// returned otherwise.
|
|
|
|
int32_t retval = DRAGDROP_ACTION_UNINITIALIZED;
|
|
|
|
if (TakeDragEventDispatchedToChildProcess() &&
|
|
|
|
mDragActionFromChildProcess != DRAGDROP_ACTION_UNINITIALIZED) {
|
|
|
|
retval = mDragActionFromChildProcess;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
1999-05-07 23:51:50 +04:00
|
|
|
//-------------------------------------------------------------------------
|
2005-03-15 01:49:00 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBaseDragService::EndDragSession(bool aDoneDrag)
|
1999-05-07 23:51:50 +04:00
|
|
|
{
|
|
|
|
if (!mDoingDrag) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2005-03-16 03:40:21 +03:00
|
|
|
|
2015-09-02 09:08:02 +03:00
|
|
|
if (aDoneDrag && !mSuppressLevel) {
|
|
|
|
FireDragEventAtSource(eDragEnd);
|
|
|
|
}
|
2007-04-12 08:37:39 +04:00
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
if (mDragPopup) {
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
|
|
if (pm) {
|
2014-04-08 16:45:52 +04:00
|
|
|
pm->HidePopup(mDragPopup, false, true, false, false);
|
2011-04-26 05:37:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
for (uint32_t i = 0; i < mChildProcesses.Length(); ++i) {
|
|
|
|
mozilla::unused << mChildProcesses[i]->SendEndDragSession(aDoneDrag,
|
|
|
|
mUserCancelled);
|
|
|
|
}
|
|
|
|
mChildProcesses.Clear();
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mDoingDrag = false;
|
2015-04-08 21:48:11 +03:00
|
|
|
mCanDrop = false;
|
2005-03-16 03:40:21 +03:00
|
|
|
|
|
|
|
// release the source we've been holding on to.
|
2012-07-30 18:20:58 +04:00
|
|
|
mSourceDocument = nullptr;
|
|
|
|
mSourceNode = nullptr;
|
|
|
|
mSelection = nullptr;
|
|
|
|
mDataTransfer = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasImage = false;
|
|
|
|
mUserCancelled = false;
|
2012-07-30 18:20:58 +04:00
|
|
|
mDragPopup = nullptr;
|
|
|
|
mImage = nullptr;
|
2015-09-29 03:44:50 +03:00
|
|
|
mImageOffset = CSSIntPoint();
|
2007-03-20 15:14:52 +03:00
|
|
|
mScreenX = -1;
|
|
|
|
mScreenY = -1;
|
2015-04-08 21:48:11 +03:00
|
|
|
mEndDragPoint = nsIntPoint(0, 0);
|
2011-08-26 11:43:56 +04:00
|
|
|
mInputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE;
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-04-12 08:37:39 +04:00
|
|
|
NS_IMETHODIMP
|
2015-09-14 18:18:29 +03:00
|
|
|
nsBaseDragService::FireDragEventAtSource(EventMessage aEventMessage)
|
2007-04-12 08:37:39 +04:00
|
|
|
{
|
2008-03-19 03:06:22 +03:00
|
|
|
if (mSourceNode && !mSuppressLevel) {
|
2007-04-12 08:37:39 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
|
|
|
|
if (doc) {
|
2010-06-25 17:59:57 +04:00
|
|
|
nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
|
2007-04-12 08:37:39 +04:00
|
|
|
if (presShell) {
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2015-09-14 18:18:29 +03:00
|
|
|
WidgetDragEvent event(true, aEventMessage, nullptr);
|
2010-04-06 16:59:24 +04:00
|
|
|
event.inputSource = mInputSource;
|
2015-09-14 18:18:29 +03:00
|
|
|
if (aEventMessage == eDragEnd) {
|
2009-04-13 17:00:29 +04:00
|
|
|
event.refPoint.x = mEndDragPoint.x;
|
|
|
|
event.refPoint.y = mEndDragPoint.y;
|
|
|
|
event.userCancelled = mUserCancelled;
|
|
|
|
}
|
2007-04-12 08:37:39 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mSourceNode);
|
|
|
|
return presShell->HandleDOMEventWithTarget(content, &event, &status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
/* This is used by Windows and Mac to update the position of a popup being
|
|
|
|
* used as a drag image during the drag. This isn't used on GTK as it manages
|
|
|
|
* the drag popup itself.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBaseDragService::DragMoved(int32_t aX, int32_t aY)
|
2011-04-26 05:37:20 +04:00
|
|
|
{
|
|
|
|
if (mDragPopup) {
|
|
|
|
nsIFrame* frame = mDragPopup->GetPrimaryFrame();
|
|
|
|
if (frame && frame->GetType() == nsGkAtoms::menuPopupFrame) {
|
2015-09-29 03:17:34 +03:00
|
|
|
CSSIntPoint cssPos = RoundedToInt(LayoutDeviceIntPoint(aX, aY) /
|
|
|
|
frame->PresContext()->CSSToDevPixelScale()) - mImageOffset;
|
|
|
|
(static_cast<nsMenuPopupFrame *>(frame))->MoveTo(cssPos, true);
|
2011-04-26 05:37:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-20 15:14:52 +03:00
|
|
|
static nsIPresShell*
|
|
|
|
GetPresShellForContent(nsIDOMNode* aDOMNode)
|
|
|
|
{
|
2007-03-29 01:18:11 +04:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aDOMNode);
|
2010-02-28 14:18:19 +03:00
|
|
|
if (!content)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-02-28 14:18:19 +03:00
|
|
|
|
2007-03-29 01:18:11 +04:00
|
|
|
nsCOMPtr<nsIDocument> document = content->GetCurrentDoc();
|
2007-03-20 15:14:52 +03:00
|
|
|
if (document) {
|
|
|
|
document->FlushPendingNotifications(Flush_Display);
|
|
|
|
|
2010-06-25 17:59:57 +04:00
|
|
|
return document->GetShell();
|
2007-03-20 15:14:52 +03:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2007-03-20 15:14:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
|
|
|
|
nsIScriptableRegion* aRegion,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aScreenX, int32_t aScreenY,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntRect* aScreenDragRect,
|
2014-01-29 04:10:33 +04:00
|
|
|
RefPtr<SourceSurface>* aSurface,
|
2008-01-09 01:03:53 +03:00
|
|
|
nsPresContext** aPresContext)
|
2007-03-20 15:14:52 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aSurface = nullptr;
|
|
|
|
*aPresContext = nullptr;
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
// use a default size, in case of an error.
|
2015-09-29 03:44:50 +03:00
|
|
|
aScreenDragRect->x = aScreenX - mImageOffset.x;
|
|
|
|
aScreenDragRect->y = aScreenY - mImageOffset.y;
|
2011-04-26 05:37:20 +04:00
|
|
|
aScreenDragRect->width = 1;
|
|
|
|
aScreenDragRect->height = 1;
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
// if a drag image was specified, use that, otherwise, use the source node
|
|
|
|
nsCOMPtr<nsIDOMNode> dragNode = mImage ? mImage.get() : aDOMNode;
|
|
|
|
|
|
|
|
// get the presshell for the node being dragged. If the drag image is not in
|
|
|
|
// a document or has no frame, get the presshell from the source drag node
|
|
|
|
nsIPresShell* presShell = GetPresShellForContent(dragNode);
|
|
|
|
if (!presShell && mImage)
|
|
|
|
presShell = GetPresShellForContent(aDOMNode);
|
|
|
|
if (!presShell)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2008-01-09 01:03:53 +03:00
|
|
|
*aPresContext = presShell->GetPresContext();
|
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
nsCOMPtr<nsIFrameLoaderOwner> flo = do_QueryInterface(dragNode);
|
|
|
|
if (flo) {
|
|
|
|
nsRefPtr<nsFrameLoader> fl = flo->GetFrameLoader();
|
|
|
|
if (fl) {
|
|
|
|
mozilla::dom::TabParent* tp =
|
|
|
|
static_cast<mozilla::dom::TabParent*>(fl->GetRemoteBrowser());
|
|
|
|
if (tp) {
|
|
|
|
int32_t x, y;
|
|
|
|
tp->TakeDragVisualization(*aSurface, x, y);
|
|
|
|
if (*aSurface) {
|
|
|
|
if (mImage) {
|
|
|
|
// Just clear the surface if chrome has overridden it with an image.
|
|
|
|
*aSurface = nullptr;
|
|
|
|
} else {
|
|
|
|
nsIFrame* f = fl->GetOwnerContent()->GetPrimaryFrame();
|
|
|
|
if (f) {
|
|
|
|
aScreenDragRect->x = x;
|
|
|
|
aScreenDragRect->y = y;
|
|
|
|
aScreenDragRect->width = (*aSurface)->GetSize().width;
|
|
|
|
aScreenDragRect->height = (*aSurface)->GetSize().height;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-15 00:25:51 +04:00
|
|
|
// convert mouse position to dev pixels of the prescontext
|
|
|
|
int32_t sx = aScreenX, sy = aScreenY;
|
|
|
|
ConvertToUnscaledDevPixels(*aPresContext, &sx, &sy);
|
|
|
|
|
2015-09-29 03:44:50 +03:00
|
|
|
aScreenDragRect->x = sx - mImageOffset.x;
|
|
|
|
aScreenDragRect->y = sy - mImageOffset.y;
|
2012-12-15 00:25:51 +04:00
|
|
|
|
2007-05-16 22:05:23 +04:00
|
|
|
// check if drag images are disabled
|
2011-09-29 10:19:26 +04:00
|
|
|
bool enableDragImages = Preferences::GetBool(DRAGIMAGES_PREF, true);
|
2007-05-16 22:05:23 +04:00
|
|
|
|
2007-03-20 15:14:52 +03:00
|
|
|
// didn't want an image, so just set the screen rectangle to the frame size
|
2007-05-16 22:05:23 +04:00
|
|
|
if (!enableDragImages || !mHasImage) {
|
2007-03-20 15:14:52 +03:00
|
|
|
// if a region was specified, set the screen rectangle to the area that
|
|
|
|
// the region occupies
|
|
|
|
if (aRegion) {
|
|
|
|
// the region's coordinates are relative to the root frame
|
|
|
|
nsIFrame* rootFrame = presShell->GetRootFrame();
|
2008-01-09 01:03:53 +03:00
|
|
|
if (rootFrame && *aPresContext) {
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntRect dragRect;
|
2007-03-20 15:14:52 +03:00
|
|
|
aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height);
|
2015-04-21 18:04:57 +03:00
|
|
|
dragRect = ToAppUnits(dragRect, nsPresContext::AppUnitsPerCSSPixel()).
|
2009-05-08 06:31:04 +04:00
|
|
|
ToOutsidePixels((*aPresContext)->AppUnitsPerDevPixel());
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
nsIntRect screenRect = rootFrame->GetScreenRectExternal();
|
|
|
|
aScreenDragRect->SetRect(screenRect.x + dragRect.x, screenRect.y + dragRect.y,
|
|
|
|
dragRect.width, dragRect.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// otherwise, there was no region so just set the rectangle to
|
|
|
|
// the size of the primary frame of the content.
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
|
2009-12-25 00:20:06 +03:00
|
|
|
nsIFrame* frame = content->GetPrimaryFrame();
|
2007-03-20 15:14:52 +03:00
|
|
|
if (frame) {
|
|
|
|
nsIntRect screenRect = frame->GetScreenRectExternal();
|
|
|
|
aScreenDragRect->SetRect(screenRect.x, screenRect.y,
|
|
|
|
screenRect.width, screenRect.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw the image for selections
|
|
|
|
if (mSelection) {
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
|
2015-07-11 19:15:19 +03:00
|
|
|
*aSurface = presShell->RenderSelection(mSelection, pnt, aScreenDragRect,
|
|
|
|
mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE);
|
2007-03-20 15:14:52 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
// if a custom image was specified, check if it is an image node and draw
|
2007-03-20 15:14:52 +03:00
|
|
|
// using the source rather than the displayed image. But if mImage isn't
|
2011-04-26 05:37:20 +04:00
|
|
|
// an image or canvas, fall through to RenderNode below.
|
2007-03-20 15:14:52 +03:00
|
|
|
if (mImage) {
|
2014-04-17 09:30:45 +04:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
|
|
|
|
HTMLCanvasElement *canvas = HTMLCanvasElement::FromContentOrNull(content);
|
2008-09-10 20:57:58 +04:00
|
|
|
if (canvas) {
|
2012-12-15 00:25:51 +04:00
|
|
|
return DrawDragForImage(*aPresContext, nullptr, canvas, sx, sy,
|
|
|
|
aScreenDragRect, aSurface);
|
2008-09-10 20:57:58 +04:00
|
|
|
}
|
|
|
|
|
2007-03-20 15:14:52 +03:00
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(dragNode);
|
|
|
|
// for image nodes, create the drag image from the actual image data
|
|
|
|
if (imageLoader) {
|
2012-12-15 00:25:51 +04:00
|
|
|
return DrawDragForImage(*aPresContext, imageLoader, nullptr, sx, sy,
|
|
|
|
aScreenDragRect, aSurface);
|
2007-03-20 15:14:52 +03:00
|
|
|
}
|
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
// If the image is a popup, use that as the image. This allows custom drag
|
|
|
|
// images that can change during the drag, but means that any platform
|
|
|
|
// default image handling won't occur.
|
|
|
|
// XXXndeakin this should be chrome-only
|
|
|
|
|
|
|
|
nsIFrame* frame = content->GetPrimaryFrame();
|
|
|
|
if (frame && frame->GetType() == nsGkAtoms::menuPopupFrame) {
|
|
|
|
mDragPopup = content;
|
|
|
|
}
|
2010-06-06 00:29:49 +04:00
|
|
|
}
|
2007-03-20 15:14:52 +03:00
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
if (!mDragPopup) {
|
|
|
|
// otherwise, just draw the node
|
|
|
|
nsIntRegion clipRegion;
|
|
|
|
if (aRegion) {
|
|
|
|
aRegion->GetRegion(&clipRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
|
2014-01-29 04:10:33 +04:00
|
|
|
*aSurface = presShell->RenderNode(dragNode, aRegion ? &clipRegion : nullptr,
|
2015-07-11 19:15:19 +03:00
|
|
|
pnt, aScreenDragRect,
|
|
|
|
mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE);
|
2011-04-26 05:37:20 +04:00
|
|
|
}
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
// if an image was specified, reposition the drag rectangle to
|
|
|
|
// the supplied offset in mImageX and mImageY.
|
|
|
|
if (mImage) {
|
2015-09-29 03:44:50 +03:00
|
|
|
aScreenDragRect->x = sx - mImageOffset.x;
|
|
|
|
aScreenDragRect->y = sy - mImageOffset.y;
|
2007-03-20 15:14:52 +03:00
|
|
|
}
|
|
|
|
|
1999-05-07 23:51:50 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
|
|
|
|
nsIImageLoadingContent* aImageLoader,
|
2014-04-17 09:30:45 +04:00
|
|
|
HTMLCanvasElement* aCanvas,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aScreenX, int32_t aScreenY,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntRect* aScreenDragRect,
|
2014-01-29 04:10:33 +04:00
|
|
|
RefPtr<SourceSurface>* aSurface)
|
2007-03-20 15:14:52 +03:00
|
|
|
{
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 05:50:15 +04:00
|
|
|
nsCOMPtr<imgIContainer> imgContainer;
|
2008-09-10 20:57:58 +04:00
|
|
|
if (aImageLoader) {
|
|
|
|
nsCOMPtr<imgIRequest> imgRequest;
|
|
|
|
nsresult rv = aImageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(imgRequest));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (!imgRequest)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
rv = imgRequest->GetImage(getter_AddRefs(imgContainer));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (!imgContainer)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
// use the size of the image as the size of the drag image
|
|
|
|
imgContainer->GetWidth(&aScreenDragRect->width);
|
|
|
|
imgContainer->GetHeight(&aScreenDragRect->height);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(aCanvas, "both image and canvas are null");
|
2014-04-17 09:30:45 +04:00
|
|
|
nsIntSize sz = aCanvas->GetSize();
|
2010-05-18 08:04:22 +04:00
|
|
|
aScreenDragRect->width = sz.width;
|
|
|
|
aScreenDragRect->height = sz.height;
|
2008-09-10 20:57:58 +04:00
|
|
|
}
|
2007-03-20 15:14:52 +03:00
|
|
|
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntSize srcSize = aScreenDragRect->Size();
|
|
|
|
nsIntSize destSize = srcSize;
|
2007-03-20 15:14:52 +03:00
|
|
|
|
2008-11-05 01:01:21 +03:00
|
|
|
if (destSize.width == 0 || destSize.height == 0)
|
2007-03-20 15:14:52 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-04-17 10:43:41 +04:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
if (aImageLoader) {
|
2014-04-17 09:30:45 +04:00
|
|
|
RefPtr<DrawTarget> dt =
|
|
|
|
gfxPlatform::GetPlatform()->
|
2015-03-29 17:59:08 +03:00
|
|
|
CreateOffscreenContentDrawTarget(destSize,
|
2014-04-17 09:30:45 +04:00
|
|
|
SurfaceFormat::B8G8R8A8);
|
|
|
|
if (!dt)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsRefPtr<gfxContext> ctx = new gfxContext(dt);
|
|
|
|
if (!ctx)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-08-23 00:12:38 +04:00
|
|
|
imgContainer->Draw(ctx, destSize, ImageRegion::Create(destSize),
|
|
|
|
imgIContainer::FRAME_CURRENT,
|
|
|
|
GraphicsFilter::FILTER_GOOD, Nothing(),
|
2013-03-11 05:43:37 +04:00
|
|
|
imgIContainer::FLAG_SYNC_DECODE);
|
2014-04-17 09:30:45 +04:00
|
|
|
*aSurface = dt->Snapshot();
|
2008-11-05 01:01:21 +03:00
|
|
|
} else {
|
2014-04-17 09:30:45 +04:00
|
|
|
*aSurface = aCanvas->GetSurfaceSnapshot();
|
2008-09-10 20:57:58 +04:00
|
|
|
}
|
2014-01-29 04:10:33 +04:00
|
|
|
|
|
|
|
return result;
|
2007-03-20 15:14:52 +03:00
|
|
|
}
|
2008-01-09 01:03:53 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseDragService::ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aScreenX, int32_t* aScreenY)
|
2008-01-09 01:03:53 +03:00
|
|
|
{
|
2014-11-13 14:53:02 +03:00
|
|
|
int32_t adj = aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
|
2008-01-09 01:03:53 +03:00
|
|
|
*aScreenX = nsPresContext::CSSPixelsToAppUnits(*aScreenX) / adj;
|
|
|
|
*aScreenY = nsPresContext::CSSPixelsToAppUnits(*aScreenY) / adj;
|
|
|
|
}
|
|
|
|
|
2008-03-19 03:06:22 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::Suppress()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
EndDragSession(false);
|
2008-03-19 03:06:22 +03:00
|
|
|
++mSuppressLevel;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::Unsuppress()
|
|
|
|
{
|
|
|
|
--mSuppressLevel;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-04-08 21:48:11 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::UserCancelled()
|
|
|
|
{
|
|
|
|
mUserCancelled = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::UpdateDragEffect()
|
|
|
|
{
|
2015-06-05 15:33:29 +03:00
|
|
|
mDragActionFromChildProcess = mDragAction;
|
2015-04-08 21:48:11 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::DragEventDispatchedToChildProcess()
|
|
|
|
{
|
|
|
|
mDragEventDispatchedToChildProcess = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsBaseDragService::MaybeAddChildProcess(mozilla::dom::ContentParent* aChild)
|
|
|
|
{
|
|
|
|
if (!mChildProcesses.Contains(aChild)) {
|
|
|
|
mChildProcesses.AppendElement(aChild);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|