summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@wolfbeast.com>2019-04-27 14:15:05 +0000
committerGitHub <noreply@github.com>2019-04-27 14:15:05 +0000
commit6e8e07e2ce68bfec6abcd6b71edec3809fa6f798 (patch)
treedf451925c8dfbee82d8287020380bb6eaa454fd7
parent3424afccaebc71c4acd4fa9eadf519c408c5965b (diff)
parent1091fcac8ed5e698f59a293d7cf533707b1da137 (diff)
downloadUXP-6e8e07e2ce68bfec6abcd6b71edec3809fa6f798.tar
UXP-6e8e07e2ce68bfec6abcd6b71edec3809fa6f798.tar.gz
UXP-6e8e07e2ce68bfec6abcd6b71edec3809fa6f798.tar.lz
UXP-6e8e07e2ce68bfec6abcd6b71edec3809fa6f798.tar.xz
UXP-6e8e07e2ce68bfec6abcd6b71edec3809fa6f798.zip
Merge pull request #1059 from g4jc/print_preview_fix
Fix #1058 - Failure to print when pages contain zero-sized <canvas> element.
-rw-r--r--dom/html/HTMLCanvasElement.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp
index a01795d9e..4b5deab18 100644
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -552,17 +552,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;