Bug 997014 - Part 6: Remove duplicate code for retreiving a snapshot from a canvas in CanvasRenderingContext2D. r=roc

This commit is contained in:
Matt Woodrow 2014-04-17 17:32:41 +12:00
parent efb62922b5
commit c86a13d275

View File

@ -3216,33 +3216,6 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
if (image.IsHTMLCanvasElement()) {
HTMLCanvasElement* canvas = &image.GetAsHTMLCanvasElement();
element = canvas;
nsIntSize size = canvas->GetSize();
if (size.width == 0 || size.height == 0) {
error.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
// Special case for Canvas, which could be an Azure canvas!
nsICanvasRenderingContextInternal *srcCanvas = canvas->GetContextAtIndex(0);
if (srcCanvas == this) {
// Self-copy.
srcSurf = mTarget->Snapshot();
imgSize = gfxIntSize(mWidth, mHeight);
} else if (srcCanvas) {
// This might not be an Azure canvas!
srcSurf = srcCanvas->GetSurfaceSnapshot();
if (srcSurf) {
if (mCanvasElement) {
// Do security check here.
CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement,
element->NodePrincipal(),
canvas->IsWriteOnly(),
false);
}
imgSize = gfxIntSize(srcSurf->GetSize().width, srcSurf->GetSize().height);
}
}
} else {
if (image.IsHTMLImageElement()) {
HTMLImageElement* img = &image.GetAsHTMLImageElement();