diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-27 16:25:30 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-27 16:25:30 +0200 |
commit | 722cc9091631e6b9a87964fd98559b7356d559f2 (patch) | |
tree | 27d5a083dcaff9ec9de359593b20524f64f02787 /dom | |
parent | b630986462f1a7c260f344f8561d3cff0efa9dec (diff) | |
parent | 6e8e07e2ce68bfec6abcd6b71edec3809fa6f798 (diff) | |
download | UXP-722cc9091631e6b9a87964fd98559b7356d559f2.tar UXP-722cc9091631e6b9a87964fd98559b7356d559f2.tar.gz UXP-722cc9091631e6b9a87964fd98559b7356d559f2.tar.lz UXP-722cc9091631e6b9a87964fd98559b7356d559f2.tar.xz UXP-722cc9091631e6b9a87964fd98559b7356d559f2.zip |
Merge branch 'master' of https://github.com/MoonchildProductions/UXP
Diffstat (limited to 'dom')
-rw-r--r-- | dom/html/HTMLCanvasElement.cpp | 28 |
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; |