mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 15:26:07 +00:00
Bug 1019551 - Fix failure to print when pages contain zero sized <canvas>. r=lsalzman
This commit is contained in:
parent
a1dd98ef44
commit
f1a8db233f
@ -584,17 +584,23 @@ HTMLCanvasElement::CopyInnerTo(Element* aDest,
|
||||
HTMLCanvasElement* dest = static_cast<HTMLCanvasElement*>(aDest);
|
||||
dest->mOriginalCanvas = this;
|
||||
|
||||
nsCOMPtr<nsISupports> cxt;
|
||||
dest->GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(cxt));
|
||||
RefPtr<CanvasRenderingContext2D> context2d =
|
||||
static_cast<CanvasRenderingContext2D*>(cxt.get());
|
||||
if (context2d && !mPrintCallback) {
|
||||
CanvasImageSource source;
|
||||
source.SetAsHTMLCanvasElement() = this;
|
||||
ErrorResult err;
|
||||
context2d->DrawImage(source,
|
||||
0.0, 0.0, err);
|
||||
rv = err.StealNSResult();
|
||||
// We make sure that the canvas is not zero sized since that would cause
|
||||
// the DrawImage call below to return an error, which would cause printing
|
||||
// to fail.
|
||||
nsIntSize size = GetWidthHeight();
|
||||
if (size.height > 0 && size.width > 0) {
|
||||
nsCOMPtr<nsISupports> cxt;
|
||||
dest->GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(cxt));
|
||||
RefPtr<CanvasRenderingContext2D> context2d =
|
||||
static_cast<CanvasRenderingContext2D*>(cxt.get());
|
||||
if (context2d && !mPrintCallback) {
|
||||
CanvasImageSource source;
|
||||
source.SetAsHTMLCanvasElement() = this;
|
||||
ErrorResult err;
|
||||
context2d->DrawImage(source,
|
||||
0.0, 0.0, err);
|
||||
rv = err.StealNSResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
Loading…
x
Reference in New Issue
Block a user