mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1473029, convert drag services to internally use CSSIntRegion instead ns nsIScriptableRegion, r=mstange
This commit is contained in:
parent
03caccfe9e
commit
a399d3073b
@ -4976,7 +4976,7 @@ PresShell::CreateRangePaintInfo(nsRange* aRange,
|
||||
already_AddRefed<SourceSurface>
|
||||
PresShell::PaintRangePaintInfo(const nsTArray<UniquePtr<RangePaintInfo>>& aItems,
|
||||
Selection* aSelection,
|
||||
nsIntRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
nsRect aArea,
|
||||
const LayoutDeviceIntPoint aPoint,
|
||||
LayoutDeviceIntRect* aScreenRect,
|
||||
@ -5073,10 +5073,10 @@ PresShell::PaintRangePaintInfo(const nsTArray<UniquePtr<RangePaintInfo>>& aItems
|
||||
|
||||
// Convert aRegion from CSS pixels to dev pixels
|
||||
nsIntRegion region =
|
||||
aRegion->ToAppUnits(nsPresContext::AppUnitsPerCSSPixel())
|
||||
.ToOutsidePixels(pc->AppUnitsPerDevPixel());
|
||||
aRegion->ToAppUnits(nsPresContext::AppUnitsPerCSSPixel())
|
||||
.ToOutsidePixels(pc->AppUnitsPerDevPixel());
|
||||
for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
|
||||
const nsIntRect& rect = iter.Get();
|
||||
const IntRect& rect = iter.Get();
|
||||
|
||||
builder->MoveTo(rect.TopLeft());
|
||||
builder->LineTo(rect.TopRight());
|
||||
@ -5136,7 +5136,7 @@ PresShell::PaintRangePaintInfo(const nsTArray<UniquePtr<RangePaintInfo>>& aItems
|
||||
|
||||
already_AddRefed<SourceSurface>
|
||||
PresShell::RenderNode(nsINode* aNode,
|
||||
nsIntRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
const LayoutDeviceIntPoint aPoint,
|
||||
LayoutDeviceIntRect* aScreenRect,
|
||||
uint32_t aFlags)
|
||||
@ -5163,9 +5163,10 @@ PresShell::RenderNode(nsINode* aNode,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aRegion) {
|
||||
Maybe<CSSIntRegion> region = aRegion;
|
||||
if (region) {
|
||||
// combine the area with the supplied region
|
||||
nsIntRect rrectPixels = aRegion->GetBounds();
|
||||
CSSIntRect rrectPixels = region->GetBounds();
|
||||
|
||||
nsRect rrect = ToAppUnits(rrectPixels, nsPresContext::AppUnitsPerCSSPixel());
|
||||
area.IntersectRect(area, rrect);
|
||||
@ -5175,11 +5176,11 @@ PresShell::RenderNode(nsINode* aNode,
|
||||
return nullptr;
|
||||
|
||||
// move the region so that it is offset from the topleft corner of the surface
|
||||
aRegion->MoveBy(-nsPresContext::AppUnitsToIntCSSPixels(area.x),
|
||||
-nsPresContext::AppUnitsToIntCSSPixels(area.y));
|
||||
region->MoveBy(-nsPresContext::AppUnitsToIntCSSPixels(area.x),
|
||||
-nsPresContext::AppUnitsToIntCSSPixels(area.y));
|
||||
}
|
||||
|
||||
return PaintRangePaintInfo(rangeItems, nullptr, aRegion, area, aPoint,
|
||||
return PaintRangePaintInfo(rangeItems, nullptr, region, area, aPoint,
|
||||
aScreenRect, aFlags);
|
||||
}
|
||||
|
||||
@ -5210,7 +5211,7 @@ PresShell::RenderSelection(Selection* aSelection,
|
||||
}
|
||||
}
|
||||
|
||||
return PaintRangePaintInfo(rangeItems, aSelection, nullptr, area, aPoint,
|
||||
return PaintRangePaintInfo(rangeItems, aSelection, Nothing(), area, aPoint,
|
||||
aScreenRect, aFlags);
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ public:
|
||||
|
||||
already_AddRefed<SourceSurface>
|
||||
RenderNode(nsINode* aNode,
|
||||
nsIntRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
const LayoutDeviceIntPoint aPoint,
|
||||
LayoutDeviceIntRect* aScreenRect,
|
||||
uint32_t aFlags) override;
|
||||
@ -543,7 +543,7 @@ private:
|
||||
already_AddRefed<SourceSurface>
|
||||
PaintRangePaintInfo(const nsTArray<UniquePtr<RangePaintInfo>>& aItems,
|
||||
dom::Selection* aSelection,
|
||||
nsIntRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
nsRect aArea,
|
||||
const LayoutDeviceIntPoint aPoint,
|
||||
LayoutDeviceIntRect* aScreenRect,
|
||||
|
@ -1162,7 +1162,7 @@ public:
|
||||
*/
|
||||
virtual already_AddRefed<mozilla::gfx::SourceSurface>
|
||||
RenderNode(nsINode* aNode,
|
||||
nsIntRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
const mozilla::LayoutDeviceIntPoint aPoint,
|
||||
mozilla::LayoutDeviceIntRect* aScreenRect,
|
||||
uint32_t aFlags) = 0;
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
// nsBaseDragService
|
||||
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType) override;
|
||||
// nsIDragService
|
||||
NS_IMETHOD EndDragSession(bool aDoneDrag, uint32_t aKeyModifiers) override;
|
||||
@ -46,14 +46,14 @@ private:
|
||||
// Creates and returns the drag image for a drag. aImagePoint will be set to
|
||||
// the origin of the drag relative to mNativeDragView.
|
||||
NSImage* ConstructDragImage(nsINode* aDOMNode,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
NSPoint* aImagePoint);
|
||||
|
||||
// Creates and returns the drag image for a drag. aPoint should be the origin
|
||||
// of the drag, for example the mouse coordinate of the mousedown event.
|
||||
// aDragRect will be set the area of the drag relative to this.
|
||||
NSImage* ConstructDragImage(nsINode* aDOMNode,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
mozilla::CSSIntPoint aPoint,
|
||||
mozilla::LayoutDeviceIntRect* aDragRect);
|
||||
|
||||
|
@ -66,7 +66,7 @@ nsDragService::~nsDragService()
|
||||
|
||||
NSImage*
|
||||
nsDragService::ConstructDragImage(nsINode* aDOMNode,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
NSPoint* aDragPoint)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
@ -108,7 +108,7 @@ nsDragService::ConstructDragImage(nsINode* aDOMNode,
|
||||
|
||||
NSImage*
|
||||
nsDragService::ConstructDragImage(nsINode* aDOMNode,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
CSSIntPoint aPoint,
|
||||
LayoutDeviceIntRect* aDragRect)
|
||||
{
|
||||
@ -284,7 +284,7 @@ nsDragService::GetFilePath(NSPasteboardItem* item)
|
||||
|
||||
nsresult
|
||||
nsDragService::InvokeDragSessionImpl(nsIArray* aTransferableArray,
|
||||
nsIScriptableRegion* aDragRgn,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
@ -344,7 +344,7 @@ nsDragService::InvokeDragSessionImpl(nsIArray* aTransferableArray,
|
||||
[pbItem setDataProvider:mNativeDragView forTypes:types];
|
||||
|
||||
NSPoint draggingPoint;
|
||||
NSImage* image = ConstructDragImage(mSourceNode, aDragRgn, &draggingPoint);
|
||||
NSImage* image = ConstructDragImage(mSourceNode, aRegion, &draggingPoint);
|
||||
|
||||
NSRect localDragRect = image.alignmentRect;
|
||||
localDragRect.origin.x = draggingPoint.x;
|
||||
@ -712,7 +712,7 @@ nsDragService::DragMovedWithView(NSDraggingSession* aSession, NSPoint aPoint)
|
||||
|
||||
// Create a new image; if one isn't returned don't change the current one.
|
||||
LayoutDeviceIntRect newRect;
|
||||
NSImage* image = ConstructDragImage(mSourceNode, nullptr, screenPoint, &newRect);
|
||||
NSImage* image = ConstructDragImage(mSourceNode, Nothing(), screenPoint, &newRect);
|
||||
if (image) {
|
||||
NSRect draggingRect = nsCocoaUtils::GeckoRectToCocoaRectDevPix(newRect, scaleFactor);
|
||||
[draggingItem setDraggingFrame:draggingRect contents:image];
|
||||
|
@ -334,7 +334,7 @@ nsDragService::InvokeDragSession(nsINode *aDOMNode,
|
||||
// nsBaseDragService
|
||||
nsresult
|
||||
nsDragService::InvokeDragSessionImpl(nsIArray* aArrayTransferables,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType)
|
||||
{
|
||||
// make sure that we have an array of transferables to use
|
||||
@ -1717,8 +1717,8 @@ void nsDragService::SetDragIcon(GdkDragContext* aContext)
|
||||
LayoutDeviceIntRect dragRect;
|
||||
nsPresContext* pc;
|
||||
RefPtr<SourceSurface> surface;
|
||||
DrawDrag(mSourceNode, mRegion, mScreenPosition,
|
||||
&dragRect, &surface, &pc);
|
||||
DrawDrag(mSourceNode, mRegion,
|
||||
mScreenPosition, &dragRect, &surface, &pc);
|
||||
if (!pc)
|
||||
return;
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
|
||||
// nsBaseDragService
|
||||
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType) override;
|
||||
// nsIDragService
|
||||
NS_IMETHOD InvokeDragSession (nsINode *aDOMNode,
|
||||
|
@ -63,8 +63,7 @@ nsBaseDragService::nsBaseDragService()
|
||||
mDragAction(DRAGDROP_ACTION_NONE),
|
||||
mDragActionFromChildProcess(DRAGDROP_ACTION_UNINITIALIZED), mTargetSize(0,0),
|
||||
mContentPolicyType(nsIContentPolicy::TYPE_OTHER),
|
||||
mSuppressLevel(0), mInputSource(MouseEvent_Binding::MOZ_SOURCE_MOUSE),
|
||||
mRegion(nullptr)
|
||||
mSuppressLevel(0), mInputSource(MouseEvent_Binding::MOZ_SOURCE_MOUSE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -302,7 +301,7 @@ nsBaseDragService::InvokeDragSessionWithImage(nsINode* aDOMNode,
|
||||
// to be set to the area encompassing the selected rows of the
|
||||
// tree to ensure that the drag feedback gets clipped to those
|
||||
// rows. For other content, region should be null.
|
||||
mRegion = nullptr;
|
||||
mRegion = Nothing();
|
||||
#ifdef MOZ_XUL
|
||||
if (aDOMNode && aDOMNode->IsContent() && !aImage) {
|
||||
if (aDOMNode->NodeInfo()->Equals(nsGkAtoms::treechildren,
|
||||
@ -310,7 +309,13 @@ nsBaseDragService::InvokeDragSessionWithImage(nsINode* aDOMNode,
|
||||
nsTreeBodyFrame* treeBody =
|
||||
do_QueryFrame(aDOMNode->AsContent()->GetPrimaryFrame());
|
||||
if (treeBody) {
|
||||
treeBody->GetSelectionRegion(getter_AddRefs(mRegion));
|
||||
nsCOMPtr<nsIScriptableRegion> region;
|
||||
treeBody->GetSelectionRegion(getter_AddRefs(region));
|
||||
if (region) {
|
||||
nsIntRegion intRegion;
|
||||
region->GetRegion(&intRegion);
|
||||
mRegion.emplace(CSSIntRegion::FromUnknownRegion(intRegion));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,7 +325,7 @@ nsBaseDragService::InvokeDragSessionWithImage(nsINode* aDOMNode,
|
||||
aTransferableArray,
|
||||
aActionType,
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE);
|
||||
mRegion = nullptr;
|
||||
mRegion = Nothing();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -342,7 +347,7 @@ nsBaseDragService::InvokeDragSessionWithSelection(Selection* aSelection,
|
||||
mDragPopup = nullptr;
|
||||
mImage = nullptr;
|
||||
mImageOffset = CSSIntPoint();
|
||||
mRegion = nullptr;
|
||||
mRegion = Nothing();
|
||||
|
||||
mScreenPosition.x = aDragEvent->ScreenX(CallerType::System);
|
||||
mScreenPosition.y = aDragEvent->ScreenY(CallerType::System);
|
||||
@ -473,7 +478,7 @@ nsBaseDragService::EndDragSession(bool aDoneDrag, uint32_t aKeyModifiers)
|
||||
mScreenPosition = CSSIntPoint();
|
||||
mEndDragPoint = LayoutDeviceIntPoint(0, 0);
|
||||
mInputSource = MouseEvent_Binding::MOZ_SOURCE_MOUSE;
|
||||
mRegion = nullptr;
|
||||
mRegion = Nothing();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -573,7 +578,7 @@ GetPresShellForContent(nsINode* aDOMNode)
|
||||
|
||||
nsresult
|
||||
nsBaseDragService::DrawDrag(nsINode* aDOMNode,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
CSSIntPoint aScreenPosition,
|
||||
LayoutDeviceIntRect* aScreenDragRect,
|
||||
RefPtr<SourceSurface>* aSurface,
|
||||
@ -633,9 +638,7 @@ nsBaseDragService::DrawDrag(nsINode* aDOMNode,
|
||||
CSSIntRect dragRect;
|
||||
if (aRegion) {
|
||||
// the region's coordinates are relative to the root frame
|
||||
int32_t dragRectX, dragRectY, dragRectW, dragRectH;
|
||||
aRegion->GetBoundingBox(&dragRectX, &dragRectY, &dragRectW, &dragRectH);
|
||||
dragRect.SetRect(dragRectX, dragRectY, dragRectW, dragRectH);
|
||||
dragRect = aRegion->GetBounds();
|
||||
|
||||
nsIFrame* rootFrame = presShell->GetRootFrame();
|
||||
CSSIntRect screenRect = rootFrame->GetScreenRect();
|
||||
@ -695,12 +698,7 @@ nsBaseDragService::DrawDrag(nsINode* aDOMNode,
|
||||
|
||||
if (!mDragPopup) {
|
||||
// otherwise, just draw the node
|
||||
nsIntRegion clipRegion;
|
||||
uint32_t renderFlags = mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE;
|
||||
if (aRegion) {
|
||||
aRegion->GetRegion(&clipRegion);
|
||||
}
|
||||
|
||||
if (renderFlags) {
|
||||
nsCOMPtr<nsINode> dragINode = do_QueryInterface(dragNode);
|
||||
// check if the dragged node itself is an img element
|
||||
@ -721,7 +719,7 @@ nsBaseDragService::DrawDrag(nsINode* aDOMNode,
|
||||
}
|
||||
}
|
||||
LayoutDeviceIntPoint pnt(aScreenDragRect->TopLeft());
|
||||
*aSurface = presShell->RenderNode(dragNode, aRegion ? &clipRegion : nullptr,
|
||||
*aSurface = presShell->RenderNode(dragNode, aRegion,
|
||||
pnt, aScreenDragRect,
|
||||
renderFlags);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsRegion.h"
|
||||
#include "Units.h"
|
||||
|
||||
// translucency level for drag images
|
||||
@ -82,7 +83,7 @@ protected:
|
||||
* EndDragSession() get called if the platform drag is successfully invoked.
|
||||
*/
|
||||
virtual nsresult InvokeDragSessionImpl(nsIArray* aTransferableArray,
|
||||
nsIScriptableRegion* aDragRgn,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType) = 0;
|
||||
|
||||
/**
|
||||
@ -108,7 +109,7 @@ protected:
|
||||
* whichever of mImage or aDOMNode is used.
|
||||
*/
|
||||
nsresult DrawDrag(nsINode* aDOMNode,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
mozilla::CSSIntPoint aScreenPosition,
|
||||
mozilla::LayoutDeviceIntRect* aScreenDragRect,
|
||||
RefPtr<SourceSurface>* aSurface,
|
||||
@ -199,7 +200,7 @@ protected:
|
||||
nsTArray<RefPtr<mozilla::dom::ContentParent>> mChildProcesses;
|
||||
|
||||
// Sub-region for tree-selections.
|
||||
nsCOMPtr<nsIScriptableRegion> mRegion;
|
||||
mozilla::Maybe<mozilla::CSSIntRegion> mRegion;
|
||||
};
|
||||
|
||||
#endif // nsBaseDragService_h__
|
||||
|
@ -47,7 +47,7 @@ GetPrincipalURIFromNode(nsCOMPtr<nsINode>& sourceNode,
|
||||
|
||||
nsresult
|
||||
nsDragServiceProxy::InvokeDragSessionImpl(nsIArray* aArrayTransferables,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType)
|
||||
{
|
||||
NS_ENSURE_STATE(mSourceDocument->GetDocShell());
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
// nsBaseDragService
|
||||
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType) override;
|
||||
private:
|
||||
virtual ~nsDragServiceProxy();
|
||||
|
@ -68,7 +68,7 @@ nsDragService::~nsDragService()
|
||||
|
||||
bool
|
||||
nsDragService::CreateDragImage(nsINode *aDOMNode,
|
||||
nsIScriptableRegion *aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
SHDRAGIMAGE *psdi)
|
||||
{
|
||||
if (!psdi)
|
||||
@ -165,7 +165,7 @@ nsDragService::CreateDragImage(nsINode *aDOMNode,
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult
|
||||
nsDragService::InvokeDragSessionImpl(nsIArray* anArrayTransferables,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const Maybe<CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType)
|
||||
{
|
||||
// Try and get source URI of the items that are being dragged
|
||||
@ -654,7 +654,7 @@ nsDragService::UpdateDragImage(nsINode* aImage, int32_t aImageX, int32_t aImageY
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDragSourceHelper, (void**)&pdsh))) {
|
||||
SHDRAGIMAGE sdi;
|
||||
if (CreateDragImage(mSourceNode, nullptr, &sdi)) {
|
||||
if (CreateDragImage(mSourceNode, Nothing(), &sdi)) {
|
||||
nsNativeDragTarget::DragImageChanged();
|
||||
if (FAILED(pdsh->InitializeFromBitmap(&sdi, mDataObject)))
|
||||
DeleteObject(sdi.hbmpDragImage);
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
// nsBaseDragService
|
||||
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
|
||||
nsIScriptableRegion* aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
uint32_t aActionType);
|
||||
|
||||
// nsIDragSession
|
||||
@ -54,7 +54,7 @@ protected:
|
||||
|
||||
// Create a bitmap for drag operations
|
||||
bool CreateDragImage(nsINode *aDOMNode,
|
||||
nsIScriptableRegion *aRegion,
|
||||
const mozilla::Maybe<mozilla::CSSIntRegion>& aRegion,
|
||||
SHDRAGIMAGE *psdi);
|
||||
|
||||
IDataObject * mDataObject;
|
||||
|
Loading…
Reference in New Issue
Block a user