2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-16 21:03:32 +00:00
|
|
|
|
|
|
|
#include "nsBaseDragService.h"
|
|
|
|
#include "nsITransferable.h"
|
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsITransferable.h"
|
1999-05-07 19:51:50 +00:00
|
|
|
#include "nsISupportsArray.h"
|
1999-04-16 21:03:32 +00:00
|
|
|
#include "nsSize.h"
|
2002-09-03 23:36:13 +00:00
|
|
|
#include "nsXPCOM.h"
|
1999-08-25 08:35:06 +00:00
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2007-03-20 12:14:52 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-08-16 01:46:34 +00:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIPresShell.h"
|
2013-01-05 03:12:24 +00:00
|
|
|
#include "nsViewManager.h"
|
2000-08-16 01:46:34 +00:00
|
|
|
#include "nsIDOMNode.h"
|
2008-08-27 12:07:27 +00:00
|
|
|
#include "nsIDOMDragEvent.h"
|
2007-03-20 12:14:52 +00:00
|
|
|
#include "nsISelection.h"
|
|
|
|
#include "nsISelectionPrivate.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2008-08-27 12:07:27 +00:00
|
|
|
#include "nsIDOMDataTransfer.h"
|
2007-03-20 12:14:52 +00:00
|
|
|
#include "nsIImageLoadingContent.h"
|
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "imgIRequest.h"
|
2014-08-22 20:12:38 +00:00
|
|
|
#include "ImageRegion.h"
|
2007-03-20 12:14:52 +00:00
|
|
|
#include "nsRegion.h"
|
2011-04-26 01:37:20 +00:00
|
|
|
#include "nsXULPopupManager.h"
|
|
|
|
#include "nsMenuPopupFrame.h"
|
2014-08-22 20:12:38 +00:00
|
|
|
#include "SVGImageContext.h"
|
2013-09-25 11:21:18 +00:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2011-05-23 14:54:03 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-01-29 00:10:33 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-04-08 18:48:11 +00:00
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "nsFrameLoader.h"
|
|
|
|
#include "TabParent.h"
|
2007-03-20 12:14:52 +00:00
|
|
|
|
|
|
|
#include "gfxContext.h"
|
2009-04-22 12:55:51 +00:00
|
|
|
#include "gfxPlatform.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2007-03-20 12:14:52 +00:00
|
|
|
|
2011-05-23 14:54:03 +00:00
|
|
|
using namespace mozilla;
|
2014-04-17 05:30:45 +00:00
|
|
|
using namespace mozilla::dom;
|
2014-08-22 20:12:38 +00:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
using namespace mozilla::image;
|
2011-05-23 14:54:03 +00:00
|
|
|
|
2007-05-16 18:05:23 +00:00
|
|
|
#define DRAGIMAGES_PREF "nglayout.enable_drag_images"
|
|
|
|
|
2005-03-14 22:49:00 +00:00
|
|
|
nsBaseDragService::nsBaseDragService()
|
2011-10-17 14:59:28 +00:00
|
|
|
: mCanDrop(false), mOnlyChromeDrop(false), mDoingDrag(false),
|
|
|
|
mHasImage(false), mUserCancelled(false),
|
2015-04-08 18:48:11 +00:00
|
|
|
mDragEventDispatchedToChildProcess(false),
|
2007-03-20 12:14:52 +00:00
|
|
|
mDragAction(DRAGDROP_ACTION_NONE), mTargetSize(0,0),
|
2010-04-06 12:59:24 +00:00
|
|
|
mImageX(0), mImageY(0), mScreenX(-1), mScreenY(-1), mSuppressLevel(0),
|
2011-08-26 07:43:56 +00:00
|
|
|
mInputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
|
1999-04-16 21:03:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseDragService::~nsBaseDragService()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsBaseDragService, nsIDragService, nsIDragSession)
|
1999-04-16 21:03:32 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBaseDragService::SetCanDrop(bool aCanDrop)
|
1999-04-16 21:03:32 +00:00
|
|
|
{
|
2005-03-14 22:49:00 +00:00
|
|
|
mCanDrop = aCanDrop;
|
|
|
|
return NS_OK;
|
1999-04-16 21:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBaseDragService::GetCanDrop(bool * aCanDrop)
|
1999-04-16 21:03:32 +00:00
|
|
|
{
|
|
|
|
*aCanDrop = mCanDrop;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-10-29 11:11:02 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBaseDragService::SetOnlyChromeDrop(bool aOnlyChrome)
|
2009-10-29 11:11:02 +00:00
|
|
|
{
|
|
|
|
mOnlyChromeDrop = aOnlyChrome;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBaseDragService::GetOnlyChromeDrop(bool* aOnlyChrome)
|
2009-10-29 11:11:02 +00:00
|
|
|
{
|
|
|
|
*aOnlyChrome = mOnlyChromeDrop;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-04-16 21:03:32 +00:00
|
|
|
|
1999-04-23 14:13:06 +00:00
|
|
|
//---------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBaseDragService::SetDragAction(uint32_t anAction)
|
1999-04-23 14:13:06 +00:00
|
|
|
{
|
2005-03-16 00:40:21 +00:00
|
|
|
mDragAction = anAction;
|
|
|
|
return NS_OK;
|
1999-04-23 14:13:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBaseDragService::GetDragAction(uint32_t * anAction)
|
1999-04-23 14:13:06 +00:00
|
|
|
{
|
|
|
|
*anAction = mDragAction;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-16 21:03:32 +00:00
|
|
|
//---------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::SetTargetSize(nsSize aDragTargetSize)
|
1999-04-16 21:03:32 +00:00
|
|
|
{
|
2005-03-14 22:49:00 +00:00
|
|
|
mTargetSize = aDragTargetSize;
|
|
|
|
return NS_OK;
|
1999-04-16 21:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::GetTargetSize(nsSize * aDragTargetSize)
|
1999-04-16 21:03:32 +00:00
|
|
|
{
|
|
|
|
*aDragTargetSize = mTargetSize;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-26 21:08:14 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBaseDragService::GetNumDropItems(uint32_t * aNumItems)
|
1999-05-26 21:08:14 +00:00
|
|
|
{
|
|
|
|
*aNumItems = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-31 20:51:42 +00:00
|
|
|
//
|
|
|
|
// GetSourceDocument
|
|
|
|
//
|
|
|
|
// Returns the DOM document where the drag was initiated. This will be
|
2012-07-30 14:20:58 +00:00
|
|
|
// nullptr if the drag began outside of our application.
|
2000-07-31 20:51:42 +00:00
|
|
|
//
|
|
|
|
NS_IMETHODIMP
|
2005-03-14 22:49:00 +00:00
|
|
|
nsBaseDragService::GetSourceDocument(nsIDOMDocument** aSourceDocument)
|
2000-07-31 20:51:42 +00:00
|
|
|
{
|
|
|
|
*aSourceDocument = mSourceDocument.get();
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IF_ADDREF(*aSourceDocument);
|
|
|
|
|
2000-07-31 20:51:42 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-20 05:58:25 +00:00
|
|
|
//
|
|
|
|
// GetSourceNode
|
|
|
|
//
|
|
|
|
// Returns the DOM node where the drag was initiated. This will be
|
2012-07-30 14:20:58 +00:00
|
|
|
// nullptr if the drag began outside of our application.
|
2001-05-20 05:58:25 +00:00
|
|
|
//
|
|
|
|
NS_IMETHODIMP
|
2005-03-14 22:49:00 +00:00
|
|
|
nsBaseDragService::GetSourceNode(nsIDOMNode** aSourceNode)
|
2001-05-20 05:58:25 +00:00
|
|
|
{
|
|
|
|
*aSourceNode = mSourceNode.get();
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IF_ADDREF(*aSourceNode);
|
|
|
|
|
2001-05-20 05:58:25 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-16 21:03:32 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
1999-05-26 21:08:14 +00:00
|
|
|
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::GetData(nsITransferable * aTransferable,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aItemIndex)
|
1999-05-07 19:51:50 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::IsDataFlavorSupported(const char *aDataFlavor,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval)
|
1999-05-07 19:51:50 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-04-16 21:03:32 +00:00
|
|
|
|
2008-08-27 12:07:27 +00: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 19:51:50 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
2007-03-20 12:14:52 +00:00
|
|
|
nsISupportsArray* aTransferableArray,
|
|
|
|
nsIScriptableRegion* aDragRgn,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aActionType)
|
1999-04-16 21:03:32 +00:00
|
|
|
{
|
2005-03-16 00:40:21 +00:00
|
|
|
NS_ENSURE_TRUE(aDOMNode, NS_ERROR_INVALID_ARG);
|
2008-03-19 00:06:22 +00:00
|
|
|
NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
|
2005-03-16 00:40:21 +00:00
|
|
|
|
|
|
|
// stash the document of the dom node
|
|
|
|
aDOMNode->GetOwnerDocument(getter_AddRefs(mSourceDocument));
|
|
|
|
mSourceNode = aDOMNode;
|
2009-04-16 15:58:23 +00:00
|
|
|
mEndDragPoint = nsIntPoint(0, 0);
|
2005-03-16 00:40:21 +00: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 13:13:16 +00:00
|
|
|
// are in the wrong coord system, so turn off mouse capture.
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIPresShell::ClearMouseCapture(nullptr);
|
2005-03-16 00:40:21 +00:00
|
|
|
|
2000-07-31 20:51:42 +00:00
|
|
|
return NS_OK;
|
1999-04-16 21:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 12:14:52 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::InvokeDragSessionWithImage(nsIDOMNode* aDOMNode,
|
|
|
|
nsISupportsArray* aTransferableArray,
|
|
|
|
nsIScriptableRegion* aRegion,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aActionType,
|
2007-03-20 12:14:52 +00:00
|
|
|
nsIDOMNode* aImage,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aImageX, int32_t aImageY,
|
2008-08-27 12:07:27 +00:00
|
|
|
nsIDOMDragEvent* aDragEvent,
|
|
|
|
nsIDOMDataTransfer* aDataTransfer)
|
2007-03-20 12:14:52 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(aDragEvent, NS_ERROR_NULL_POINTER);
|
2008-08-27 12:07:27 +00:00
|
|
|
NS_ENSURE_TRUE(aDataTransfer, NS_ERROR_NULL_POINTER);
|
2008-03-19 00:06:22 +00:00
|
|
|
NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
|
2007-03-20 12:14:52 +00:00
|
|
|
|
2008-08-27 12:07:27 +00:00
|
|
|
mDataTransfer = aDataTransfer;
|
2012-07-30 14:20:58 +00:00
|
|
|
mSelection = nullptr;
|
2011-10-17 14:59:28 +00:00
|
|
|
mHasImage = true;
|
2012-07-30 14:20:58 +00:00
|
|
|
mDragPopup = nullptr;
|
2007-03-20 12:14:52 +00:00
|
|
|
mImage = aImage;
|
|
|
|
mImageX = aImageX;
|
|
|
|
mImageY = aImageY;
|
|
|
|
|
|
|
|
aDragEvent->GetScreenX(&mScreenX);
|
|
|
|
aDragEvent->GetScreenY(&mScreenY);
|
2011-08-26 07:43:56 +00:00
|
|
|
aDragEvent->GetMozInputSource(&mInputSource);
|
2010-04-06 12:59:24 +00:00
|
|
|
|
2007-03-20 12:14:52 +00:00
|
|
|
return InvokeDragSession(aDOMNode, aTransferableArray, aRegion, aActionType);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::InvokeDragSessionWithSelection(nsISelection* aSelection,
|
|
|
|
nsISupportsArray* aTransferableArray,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aActionType,
|
2008-08-27 12:07:27 +00:00
|
|
|
nsIDOMDragEvent* aDragEvent,
|
|
|
|
nsIDOMDataTransfer* aDataTransfer)
|
2007-03-20 12:14:52 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
|
|
|
|
NS_ENSURE_TRUE(aDragEvent, NS_ERROR_NULL_POINTER);
|
2008-03-19 00:06:22 +00:00
|
|
|
NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
|
2007-03-20 12:14:52 +00:00
|
|
|
|
2008-08-27 12:07:27 +00:00
|
|
|
mDataTransfer = aDataTransfer;
|
2007-03-20 12:14:52 +00:00
|
|
|
mSelection = aSelection;
|
2011-10-17 14:59:28 +00:00
|
|
|
mHasImage = true;
|
2012-07-30 14:20:58 +00:00
|
|
|
mDragPopup = nullptr;
|
|
|
|
mImage = nullptr;
|
2007-03-20 12:14:52 +00:00
|
|
|
mImageX = 0;
|
|
|
|
mImageY = 0;
|
|
|
|
|
|
|
|
aDragEvent->GetScreenX(&mScreenX);
|
|
|
|
aDragEvent->GetScreenY(&mScreenY);
|
2011-08-26 07:43:56 +00:00
|
|
|
aDragEvent->GetMozInputSource(&mInputSource);
|
2010-04-06 12:59:24 +00:00
|
|
|
|
2007-03-20 12:14:52 +00:00
|
|
|
// just get the focused node from the selection
|
2008-08-27 12:07:27 +00:00
|
|
|
// XXXndeakin this should actually be the deepest node that contains both
|
|
|
|
// endpoints of the selection
|
2007-03-20 12:14:52 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node;
|
|
|
|
aSelection->GetFocusNode(getter_AddRefs(node));
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return InvokeDragSession(node, aTransferableArray, nullptr, aActionType);
|
2007-03-20 12:14:52 +00:00
|
|
|
}
|
1999-05-07 19:51:50 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::GetCurrentSession(nsIDragSession ** aSession)
|
1999-05-07 19:51:50 +00:00
|
|
|
{
|
2005-03-14 22:49:00 +00:00
|
|
|
if (!aSession)
|
1999-05-07 19:51:50 +00:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
2005-03-14 22:49:00 +00: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 00:06:22 +00:00
|
|
|
if (!mSuppressLevel && mDoingDrag) {
|
1999-05-07 19:51:50 +00:00
|
|
|
*aSession = this;
|
1999-08-25 08:35:06 +00:00
|
|
|
NS_ADDREF(*aSession); // addRef because we're a "getter"
|
1999-05-07 19:51:50 +00:00
|
|
|
}
|
|
|
|
else
|
2012-07-30 14:20:58 +00:00
|
|
|
*aSession = nullptr;
|
2005-03-14 22:49:00 +00:00
|
|
|
|
1999-05-07 19:51:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::StartDragSession()
|
1999-05-07 19:51:50 +00:00
|
|
|
{
|
|
|
|
if (mDoingDrag) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
mDoingDrag = true;
|
2009-10-29 11:11:02 +00:00
|
|
|
// By default dispatch drop also to content.
|
2011-10-17 14:59:28 +00:00
|
|
|
mOnlyChromeDrop = false;
|
2011-04-26 01:37:20 +00:00
|
|
|
|
1999-05-07 19:51:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-26 01:37:20 +00:00
|
|
|
void
|
|
|
|
nsBaseDragService::OpenDragPopup()
|
|
|
|
{
|
|
|
|
if (mDragPopup) {
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
|
|
if (pm) {
|
2012-07-30 14:20:58 +00:00
|
|
|
pm->ShowPopupAtScreen(mDragPopup, mScreenX - mImageX, mScreenY - mImageY, false, nullptr);
|
2011-04-26 01:37:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-07 19:51:50 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2005-03-14 22:49:00 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBaseDragService::EndDragSession(bool aDoneDrag)
|
1999-05-07 19:51:50 +00:00
|
|
|
{
|
|
|
|
if (!mDoingDrag) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2005-03-16 00:40:21 +00:00
|
|
|
|
2008-03-19 00:06:22 +00:00
|
|
|
if (aDoneDrag && !mSuppressLevel)
|
2007-04-12 04:37:39 +00:00
|
|
|
FireDragEventAtSource(NS_DRAGDROP_END);
|
|
|
|
|
2011-04-26 01:37:20 +00:00
|
|
|
if (mDragPopup) {
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
|
|
if (pm) {
|
2014-04-08 12:45:52 +00:00
|
|
|
pm->HidePopup(mDragPopup, false, true, false, false);
|
2011-04-26 01:37:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-08 18:48:11 +00:00
|
|
|
for (uint32_t i = 0; i < mChildProcesses.Length(); ++i) {
|
|
|
|
mozilla::unused << mChildProcesses[i]->SendEndDragSession(aDoneDrag,
|
|
|
|
mUserCancelled);
|
|
|
|
}
|
|
|
|
mChildProcesses.Clear();
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
mDoingDrag = false;
|
2015-04-08 18:48:11 +00:00
|
|
|
mCanDrop = false;
|
2005-03-16 00:40:21 +00:00
|
|
|
|
|
|
|
// release the source we've been holding on to.
|
2012-07-30 14:20:58 +00:00
|
|
|
mSourceDocument = nullptr;
|
|
|
|
mSourceNode = nullptr;
|
|
|
|
mSelection = nullptr;
|
|
|
|
mDataTransfer = nullptr;
|
2011-10-17 14:59:28 +00:00
|
|
|
mHasImage = false;
|
|
|
|
mUserCancelled = false;
|
2012-07-30 14:20:58 +00:00
|
|
|
mDragPopup = nullptr;
|
|
|
|
mImage = nullptr;
|
2007-03-20 12:14:52 +00:00
|
|
|
mImageX = 0;
|
|
|
|
mImageY = 0;
|
|
|
|
mScreenX = -1;
|
|
|
|
mScreenY = -1;
|
2015-04-08 18:48:11 +00:00
|
|
|
mEndDragPoint = nsIntPoint(0, 0);
|
2011-08-26 07:43:56 +00:00
|
|
|
mInputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE;
|
2007-03-20 12:14:52 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-04-12 04:37:39 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBaseDragService::FireDragEventAtSource(uint32_t aMsg)
|
2007-04-12 04:37:39 +00:00
|
|
|
{
|
2008-03-19 00:06:22 +00:00
|
|
|
if (mSourceNode && !mSuppressLevel) {
|
2007-04-12 04:37:39 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
|
|
|
|
if (doc) {
|
2010-06-25 13:59:57 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
|
2007-04-12 04:37:39 +00:00
|
|
|
if (presShell) {
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2013-10-01 07:23:02 +00:00
|
|
|
WidgetDragEvent event(true, aMsg, nullptr);
|
2010-04-06 12:59:24 +00:00
|
|
|
event.inputSource = mInputSource;
|
2009-04-13 13:00:29 +00:00
|
|
|
if (aMsg == NS_DRAGDROP_END) {
|
|
|
|
event.refPoint.x = mEndDragPoint.x;
|
|
|
|
event.refPoint.y = mEndDragPoint.y;
|
|
|
|
event.userCancelled = mUserCancelled;
|
|
|
|
}
|
2007-04-12 04:37:39 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mSourceNode);
|
|
|
|
return presShell->HandleDOMEventWithTarget(content, &event, &status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-26 01:37:20 +00: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 15:56:38 +00:00
|
|
|
nsBaseDragService::DragMoved(int32_t aX, int32_t aY)
|
2011-04-26 01:37:20 +00:00
|
|
|
{
|
|
|
|
if (mDragPopup) {
|
|
|
|
nsIFrame* frame = mDragPopup->GetPrimaryFrame();
|
|
|
|
if (frame && frame->GetType() == nsGkAtoms::menuPopupFrame) {
|
2011-10-17 14:59:28 +00:00
|
|
|
(static_cast<nsMenuPopupFrame *>(frame))->MoveTo(aX - mImageX, aY - mImageY, true);
|
2011-04-26 01:37:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-20 12:14:52 +00:00
|
|
|
static nsIPresShell*
|
|
|
|
GetPresShellForContent(nsIDOMNode* aDOMNode)
|
|
|
|
{
|
2007-03-28 21:18:11 +00:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aDOMNode);
|
2010-02-28 11:18:19 +00:00
|
|
|
if (!content)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-02-28 11:18:19 +00:00
|
|
|
|
2007-03-28 21:18:11 +00:00
|
|
|
nsCOMPtr<nsIDocument> document = content->GetCurrentDoc();
|
2007-03-20 12:14:52 +00:00
|
|
|
if (document) {
|
|
|
|
document->FlushPendingNotifications(Flush_Display);
|
|
|
|
|
2010-06-25 13:59:57 +00:00
|
|
|
return document->GetShell();
|
2007-03-20 12:14:52 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2007-03-20 12:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
|
|
|
|
nsIScriptableRegion* aRegion,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aScreenX, int32_t aScreenY,
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntRect* aScreenDragRect,
|
2014-01-29 00:10:33 +00:00
|
|
|
RefPtr<SourceSurface>* aSurface,
|
2008-01-08 22:03:53 +00:00
|
|
|
nsPresContext** aPresContext)
|
2007-03-20 12:14:52 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aSurface = nullptr;
|
|
|
|
*aPresContext = nullptr;
|
2007-03-20 12:14:52 +00:00
|
|
|
|
|
|
|
// use a default size, in case of an error.
|
|
|
|
aScreenDragRect->x = aScreenX - mImageX;
|
|
|
|
aScreenDragRect->y = aScreenY - mImageY;
|
2011-04-26 01:37:20 +00:00
|
|
|
aScreenDragRect->width = 1;
|
|
|
|
aScreenDragRect->height = 1;
|
2007-03-20 12:14:52 +00: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-08 22:03:53 +00:00
|
|
|
*aPresContext = presShell->GetPresContext();
|
|
|
|
|
2015-04-08 18:48:11 +00: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-14 20:25:51 +00:00
|
|
|
// convert mouse position to dev pixels of the prescontext
|
|
|
|
int32_t sx = aScreenX, sy = aScreenY;
|
|
|
|
ConvertToUnscaledDevPixels(*aPresContext, &sx, &sy);
|
|
|
|
|
|
|
|
aScreenDragRect->x = sx - mImageX;
|
|
|
|
aScreenDragRect->y = sy - mImageY;
|
|
|
|
|
2007-05-16 18:05:23 +00:00
|
|
|
// check if drag images are disabled
|
2011-09-29 06:19:26 +00:00
|
|
|
bool enableDragImages = Preferences::GetBool(DRAGIMAGES_PREF, true);
|
2007-05-16 18:05:23 +00:00
|
|
|
|
2007-03-20 12:14:52 +00:00
|
|
|
// didn't want an image, so just set the screen rectangle to the frame size
|
2007-05-16 18:05:23 +00:00
|
|
|
if (!enableDragImages || !mHasImage) {
|
2007-03-20 12:14:52 +00: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-08 22:03:53 +00:00
|
|
|
if (rootFrame && *aPresContext) {
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntRect dragRect;
|
2007-03-20 12:14:52 +00:00
|
|
|
aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height);
|
2015-04-21 15:04:57 +00:00
|
|
|
dragRect = ToAppUnits(dragRect, nsPresContext::AppUnitsPerCSSPixel()).
|
2009-05-08 02:31:04 +00:00
|
|
|
ToOutsidePixels((*aPresContext)->AppUnitsPerDevPixel());
|
2007-03-20 12:14:52 +00: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-24 21:20:06 +00:00
|
|
|
nsIFrame* frame = content->GetPrimaryFrame();
|
2007-03-20 12:14:52 +00: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 03:27:09 +00:00
|
|
|
nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
|
2014-01-29 00:10:33 +00:00
|
|
|
*aSurface = presShell->RenderSelection(mSelection, pnt, aScreenDragRect);
|
2007-03-20 12:14:52 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-26 01:37:20 +00:00
|
|
|
// if a custom image was specified, check if it is an image node and draw
|
2007-03-20 12:14:52 +00:00
|
|
|
// using the source rather than the displayed image. But if mImage isn't
|
2011-04-26 01:37:20 +00:00
|
|
|
// an image or canvas, fall through to RenderNode below.
|
2007-03-20 12:14:52 +00:00
|
|
|
if (mImage) {
|
2014-04-17 05:30:45 +00:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
|
|
|
|
HTMLCanvasElement *canvas = HTMLCanvasElement::FromContentOrNull(content);
|
2008-09-10 16:57:58 +00:00
|
|
|
if (canvas) {
|
2012-12-14 20:25:51 +00:00
|
|
|
return DrawDragForImage(*aPresContext, nullptr, canvas, sx, sy,
|
|
|
|
aScreenDragRect, aSurface);
|
2008-09-10 16:57:58 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 12:14:52 +00:00
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(dragNode);
|
|
|
|
// for image nodes, create the drag image from the actual image data
|
|
|
|
if (imageLoader) {
|
2012-12-14 20:25:51 +00:00
|
|
|
return DrawDragForImage(*aPresContext, imageLoader, nullptr, sx, sy,
|
|
|
|
aScreenDragRect, aSurface);
|
2007-03-20 12:14:52 +00:00
|
|
|
}
|
|
|
|
|
2011-04-26 01:37:20 +00: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-05 20:29:49 +00:00
|
|
|
}
|
2007-03-20 12:14:52 +00:00
|
|
|
|
2011-04-26 01:37:20 +00:00
|
|
|
if (!mDragPopup) {
|
|
|
|
// otherwise, just draw the node
|
|
|
|
nsIntRegion clipRegion;
|
|
|
|
if (aRegion) {
|
|
|
|
aRegion->GetRegion(&clipRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
|
2014-01-29 00:10:33 +00:00
|
|
|
*aSurface = presShell->RenderNode(dragNode, aRegion ? &clipRegion : nullptr,
|
|
|
|
pnt, aScreenDragRect);
|
2011-04-26 01:37:20 +00:00
|
|
|
}
|
2007-03-20 12:14:52 +00:00
|
|
|
|
|
|
|
// if an image was specified, reposition the drag rectangle to
|
|
|
|
// the supplied offset in mImageX and mImageY.
|
|
|
|
if (mImage) {
|
2012-12-14 20:25:51 +00:00
|
|
|
aScreenDragRect->x = sx - mImageX;
|
|
|
|
aScreenDragRect->y = sy - mImageY;
|
2007-03-20 12:14:52 +00:00
|
|
|
}
|
|
|
|
|
1999-05-07 19:51:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-20 12:14:52 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
|
|
|
|
nsIImageLoadingContent* aImageLoader,
|
2014-04-17 05:30:45 +00:00
|
|
|
HTMLCanvasElement* aCanvas,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aScreenX, int32_t aScreenY,
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntRect* aScreenDragRect,
|
2014-01-29 00:10:33 +00:00
|
|
|
RefPtr<SourceSurface>* aSurface)
|
2007-03-20 12:14:52 +00: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 01:50:15 +00:00
|
|
|
nsCOMPtr<imgIContainer> imgContainer;
|
2008-09-10 16:57:58 +00: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 05:30:45 +00:00
|
|
|
nsIntSize sz = aCanvas->GetSize();
|
2010-05-18 04:04:22 +00:00
|
|
|
aScreenDragRect->width = sz.width;
|
|
|
|
aScreenDragRect->height = sz.height;
|
2008-09-10 16:57:58 +00:00
|
|
|
}
|
2007-03-20 12:14:52 +00:00
|
|
|
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntSize srcSize = aScreenDragRect->Size();
|
|
|
|
nsIntSize destSize = srcSize;
|
2007-03-20 12:14:52 +00:00
|
|
|
|
2008-11-04 22:01:21 +00:00
|
|
|
if (destSize.width == 0 || destSize.height == 0)
|
2007-03-20 12:14:52 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// if the image is larger than half the screen size, scale it down. This
|
|
|
|
// scaling algorithm is the same as is used in nsPresShell::PaintRangePaintInfo
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext* deviceContext = aPresContext->DeviceContext();
|
2007-03-20 12:14:52 +00:00
|
|
|
nsRect maxSize;
|
|
|
|
deviceContext->GetClientRect(maxSize);
|
|
|
|
nscoord maxWidth = aPresContext->AppUnitsToDevPixels(maxSize.width >> 1);
|
|
|
|
nscoord maxHeight = aPresContext->AppUnitsToDevPixels(maxSize.height >> 1);
|
2008-11-04 22:01:21 +00:00
|
|
|
if (destSize.width > maxWidth || destSize.height > maxHeight) {
|
2007-03-20 12:14:52 +00:00
|
|
|
float scale = 1.0;
|
2008-11-04 22:01:21 +00:00
|
|
|
if (destSize.width > maxWidth)
|
2013-01-15 12:22:03 +00:00
|
|
|
scale = std::min(scale, float(maxWidth) / destSize.width);
|
2008-11-04 22:01:21 +00:00
|
|
|
if (destSize.height > maxHeight)
|
2013-01-15 12:22:03 +00:00
|
|
|
scale = std::min(scale, float(maxHeight) / destSize.height);
|
2007-03-20 12:14:52 +00:00
|
|
|
|
2008-11-04 22:01:21 +00:00
|
|
|
destSize.width = NSToIntFloor(float(destSize.width) * scale);
|
|
|
|
destSize.height = NSToIntFloor(float(destSize.height) * scale);
|
2015-04-03 00:45:50 +00:00
|
|
|
if (destSize.width == 0 || destSize.height == 0)
|
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-20 12:14:52 +00:00
|
|
|
|
|
|
|
aScreenDragRect->x = NSToIntFloor(aScreenX - float(mImageX) * scale);
|
|
|
|
aScreenDragRect->y = NSToIntFloor(aScreenY - float(mImageY) * scale);
|
2008-11-04 22:01:21 +00:00
|
|
|
aScreenDragRect->width = destSize.width;
|
|
|
|
aScreenDragRect->height = destSize.height;
|
2007-03-20 12:14:52 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 06:43:41 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
if (aImageLoader) {
|
2014-04-17 05:30:45 +00:00
|
|
|
RefPtr<DrawTarget> dt =
|
|
|
|
gfxPlatform::GetPlatform()->
|
2015-03-29 14:59:08 +00:00
|
|
|
CreateOffscreenContentDrawTarget(destSize,
|
2014-04-17 05:30:45 +00:00
|
|
|
SurfaceFormat::B8G8R8A8);
|
|
|
|
if (!dt)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsRefPtr<gfxContext> ctx = new gfxContext(dt);
|
|
|
|
if (!ctx)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-08-22 20:12:38 +00:00
|
|
|
imgContainer->Draw(ctx, destSize, ImageRegion::Create(destSize),
|
|
|
|
imgIContainer::FRAME_CURRENT,
|
|
|
|
GraphicsFilter::FILTER_GOOD, Nothing(),
|
2013-03-11 01:43:37 +00:00
|
|
|
imgIContainer::FLAG_SYNC_DECODE);
|
2014-04-17 05:30:45 +00:00
|
|
|
*aSurface = dt->Snapshot();
|
2008-11-04 22:01:21 +00:00
|
|
|
} else {
|
2014-04-17 05:30:45 +00:00
|
|
|
*aSurface = aCanvas->GetSurfaceSnapshot();
|
2008-09-10 16:57:58 +00:00
|
|
|
}
|
2014-01-29 00:10:33 +00:00
|
|
|
|
|
|
|
return result;
|
2007-03-20 12:14:52 +00:00
|
|
|
}
|
2008-01-08 22:03:53 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseDragService::ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t* aScreenX, int32_t* aScreenY)
|
2008-01-08 22:03:53 +00:00
|
|
|
{
|
2014-11-13 11:53:02 +00:00
|
|
|
int32_t adj = aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
|
2008-01-08 22:03:53 +00:00
|
|
|
*aScreenX = nsPresContext::CSSPixelsToAppUnits(*aScreenX) / adj;
|
|
|
|
*aScreenY = nsPresContext::CSSPixelsToAppUnits(*aScreenY) / adj;
|
|
|
|
}
|
|
|
|
|
2008-03-19 00:06:22 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::Suppress()
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
EndDragSession(false);
|
2008-03-19 00:06:22 +00:00
|
|
|
++mSuppressLevel;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::Unsuppress()
|
|
|
|
{
|
|
|
|
--mSuppressLevel;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-04-08 18:48:11 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::UserCancelled()
|
|
|
|
{
|
|
|
|
mUserCancelled = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseDragService::UpdateDragEffect()
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|