Backed out changeset 39296ccf8936 (bug 997014)

This commit is contained in:
Carsten "Tomcat" Book 2014-04-17 08:43:41 +02:00
parent 9a457afe93
commit 810846820e
2 changed files with 19 additions and 20 deletions

View File

@ -25,6 +25,7 @@
#include "nsISelectionPrivate.h"
#include "nsPresContext.h"
#include "nsIDOMDataTransfer.h"
#include "nsICanvasElementExternal.h"
#include "nsIImageLoadingContent.h"
#include "imgIContainer.h"
#include "imgIRequest.h"
@ -41,7 +42,6 @@
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::dom;
#define DRAGIMAGES_PREF "nglayout.enable_drag_images"
@ -507,8 +507,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
// using the source rather than the displayed image. But if mImage isn't
// an image or canvas, fall through to RenderNode below.
if (mImage) {
nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
HTMLCanvasElement *canvas = HTMLCanvasElement::FromContentOrNull(content);
nsCOMPtr<nsICanvasElementExternal> canvas = do_QueryInterface(dragNode);
if (canvas) {
return DrawDragForImage(*aPresContext, nullptr, canvas, sx, sy,
aScreenDragRect, aSurface);
@ -526,6 +525,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
// default image handling won't occur.
// XXXndeakin this should be chrome-only
nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
nsIFrame* frame = content->GetPrimaryFrame();
if (frame && frame->GetType() == nsGkAtoms::menuPopupFrame) {
mDragPopup = content;
@ -557,7 +557,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
nsresult
nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
nsIImageLoadingContent* aImageLoader,
HTMLCanvasElement* aCanvas,
nsICanvasElementExternal* aCanvas,
int32_t aScreenX, int32_t aScreenY,
nsIntRect* aScreenDragRect,
RefPtr<SourceSurface>* aSurface)
@ -582,7 +582,7 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
}
else {
NS_ASSERTION(aCanvas, "both image and canvas are null");
nsIntSize sz = aCanvas->GetSize();
nsIntSize sz = aCanvas->GetSizeExternal();
aScreenDragRect->width = sz.width;
aScreenDragRect->height = sz.height;
}
@ -616,19 +616,19 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
aScreenDragRect->height = destSize.height;
}
RefPtr<DrawTarget> dt =
gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(destSize.ToIntSize(),
SurfaceFormat::B8G8R8A8);
if (!dt)
return NS_ERROR_FAILURE;
nsRefPtr<gfxContext> ctx = new gfxContext(dt);
if (!ctx)
return NS_ERROR_FAILURE;
nsresult result = NS_OK;
if (aImageLoader) {
RefPtr<DrawTarget> dt =
gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(destSize.ToIntSize(),
SurfaceFormat::B8G8R8A8);
if (!dt)
return NS_ERROR_FAILURE;
nsRefPtr<gfxContext> ctx = new gfxContext(dt);
if (!ctx)
return NS_ERROR_FAILURE;
gfxRect outRect(0, 0, destSize.width, destSize.height);
gfxMatrix scale =
gfxMatrix().Scale(srcSize.width/outRect.Width(), srcSize.height/outRect.Height());
@ -636,11 +636,11 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
imgContainer->Draw(ctx, GraphicsFilter::FILTER_GOOD, scale, outRect, imgSize,
destSize, nullptr, imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE);
*aSurface = dt->Snapshot();
} else {
*aSurface = aCanvas->GetSurfaceSnapshot();
result = aCanvas->RenderContextsExternal(ctx, GraphicsFilter::FILTER_GOOD);
}
*aSurface = dt->Snapshot();
return result;
}

View File

@ -15,7 +15,6 @@
#include "nsRect.h"
#include "nsPoint.h"
#include "mozilla/RefPtr.h"
#include "mozilla/dom/HTMLCanvasElement.h"
// translucency level for drag images
#define DRAG_TRANSLUCENCY 0.65
@ -95,7 +94,7 @@ protected:
*/
nsresult DrawDragForImage(nsPresContext* aPresContext,
nsIImageLoadingContent* aImageLoader,
mozilla::dom::HTMLCanvasElement* aCanvas,
nsICanvasElementExternal* aCanvas,
int32_t aScreenX, int32_t aScreenY,
nsIntRect* aScreenDragRect,
mozilla::RefPtr<SourceSurface>* aSurface);