Index: third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp |
diff --git a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp |
index 71c3c6faeebe085a32bfe670837ca9c95499bea8..5269bd7845f885353e192d0f434da7503d7e3d7b 100644 |
--- a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp |
+++ b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp |
@@ -45,6 +45,7 @@ |
#include "core/html/ImageData.h" |
#include "core/imagebitmap/ImageBitmapOptions.h" |
#include "core/offscreencanvas/OffscreenCanvas.h" |
+#include "core/svg/SVGImageElement.h" |
#include "core/svg/graphics/SVGImage.h" |
#include "core/workers/WorkerGlobalScope.h" |
#include "platform/CrossThreadFunctional.h" |
@@ -85,6 +86,28 @@ static inline ImageBitmapSource* toImageBitmapSourceInternal( |
} |
return imageElement; |
} |
+ if (value.isSVGImageElement()) { |
+ SVGImageElement* imageElement = value.getAsSVGImageElement(); |
+ if (!imageElement || !imageElement->cachedImage()) { |
fs
2017/04/06 16:48:12
This sequence of code also looks very similar to t
fserb
2017/04/06 20:06:16
done
|
+ exceptionState.throwDOMException( |
+ InvalidStateError, |
+ "No image can be retrieved from the provided element."); |
+ return nullptr; |
+ } |
+ if (imageElement->cachedImage()->getImage()->isSVGImage()) { |
+ SVGImage* image = toSVGImage(imageElement->cachedImage()->getImage()); |
+ if (!image->hasIntrinsicDimensions() && |
+ (!hasCropRect && |
+ (!options.hasResizeWidth() || !options.hasResizeHeight()))) { |
+ exceptionState.throwDOMException( |
+ InvalidStateError, |
+ "The image element contains an SVG image without intrinsic " |
+ "dimensions, and no resize options or crop region are specified."); |
+ return nullptr; |
+ } |
+ } |
+ return imageElement; |
+ } |
if (value.isHTMLVideoElement()) |
return value.getAsHTMLVideoElement(); |
if (value.isHTMLCanvasElement()) |