diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-04-16 14:48:38 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-04-16 14:48:38 +0200 |
commit | 842e3d91b43810385d2942f0b9423fbc3c4ae4b9 (patch) | |
tree | 9e271304e885b39d8a88ba7fefd59d75f7a03623 /dom/canvas | |
parent | 931950a880b3550490422b1855c509be10586858 (diff) | |
parent | 4028f58ce7e9ed54327afc6e2a44f5092005dcda (diff) | |
download | UXP-842e3d91b43810385d2942f0b9423fbc3c4ae4b9.tar UXP-842e3d91b43810385d2942f0b9423fbc3c4ae4b9.tar.gz UXP-842e3d91b43810385d2942f0b9423fbc3c4ae4b9.tar.lz UXP-842e3d91b43810385d2942f0b9423fbc3c4ae4b9.tar.xz UXP-842e3d91b43810385d2942f0b9423fbc3c4ae4b9.zip |
Merge branch 'master' of https://github.com/MoonchildProductions/UXP
Diffstat (limited to 'dom/canvas')
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.cpp | 24 | ||||
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.h | 4 |
2 files changed, 20 insertions, 8 deletions
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 15df2b337..a38c38293 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -105,6 +105,7 @@ #include "mozilla/dom/CanvasPath.h" #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/HTMLVideoElement.h" +#include "mozilla/dom/SVGImageElement.h" #include "mozilla/dom/SVGMatrix.h" #include "mozilla/dom/TextMetrics.h" #include "mozilla/dom/SVGMatrix.h" @@ -2477,10 +2478,10 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, return nullptr; } - Element* htmlElement; + Element* element; if (aSource.IsHTMLCanvasElement()) { HTMLCanvasElement* canvas = &aSource.GetAsHTMLCanvasElement(); - htmlElement = canvas; + element = canvas; nsIntSize size = canvas->GetSize(); if (size.width == 0 || size.height == 0) { @@ -2505,7 +2506,7 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, } RefPtr<CanvasPattern> pat = - new CanvasPattern(this, srcSurf, repeatMode, htmlElement->NodePrincipal(), canvas->IsWriteOnly(), false); + new CanvasPattern(this, srcSurf, repeatMode, element->NodePrincipal(), canvas->IsWriteOnly(), false); return pat.forget(); } @@ -2516,11 +2517,19 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, return nullptr; } - htmlElement = img; + element = img; + } else if (aSource.IsSVGImageElement()) { + SVGImageElement* img = &aSource.GetAsSVGImageElement(); + if (img->IntrinsicState().HasState(NS_EVENT_STATE_BROKEN)) { + aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return nullptr; + } + + element = img; } else if (aSource.IsHTMLVideoElement()) { auto& video = aSource.GetAsHTMLVideoElement(); video.MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::CREATE_PATTERN); - htmlElement = &video; + element = &video; } else { // Special case for ImageBitmap ImageBitmap& imgBitmap = aSource.GetAsImageBitmap(); @@ -2559,7 +2568,7 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, // The canvas spec says that createPattern should use the first frame // of animated images nsLayoutUtils::SurfaceFromElementResult res = - nsLayoutUtils::SurfaceFromElement(htmlElement, + nsLayoutUtils::SurfaceFromElement(element, nsLayoutUtils::SFE_WANT_FIRST_FRAME, mTarget); if (!res.GetSourceSurface()) { @@ -4949,6 +4958,9 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage, if (aImage.IsHTMLImageElement()) { HTMLImageElement* img = &aImage.GetAsHTMLImageElement(); element = img; + } else if (aImage.IsSVGImageElement()) { + SVGImageElement* img = &aImage.GetAsSVGImageElement(); + element = img; } else { HTMLVideoElement* video = &aImage.GetAsHTMLVideoElement(); video->MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::DRAW_IMAGE); diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index c3ee3bdcb..d5dff8f3b 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -38,8 +38,8 @@ class SourceSurface; } // namespace gl namespace dom { -class HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap; -typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource; +class HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap; +typedef HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource; class ImageData; class StringOrCanvasGradientOrCanvasPattern; class OwningStringOrCanvasGradientOrCanvasPattern; |