Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Unified Diff: third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp

Issue 2802813002: Adds SVGImageElement as a ImageBitmapSource (Closed)
Patch Set: tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..552c9d98e5240bcfbdb4f9b56bdfe005f685f61c 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"
@@ -60,13 +61,20 @@ namespace blink {
static inline ImageBitmapSource* toImageBitmapSourceInternal(
const ImageBitmapSourceUnion& value,
- ExceptionState& exceptionState,
+ ExceptionState* exceptionState,
fs 2017/04/06 20:27:54 Was this required by anything now?
fserb 2017/04/06 21:03:49 It isn't. Lint was complaining that it should be e
fs 2017/04/06 21:11:27 What Lint was that? (ExceptionState& is pretty muc
fserb 2017/04/07 18:36:28 done.
const ImageBitmapOptions& options,
bool hasCropRect) {
+ HTMLAndSVGImageElementSource* imageElement = nullptr;
if (value.isHTMLImageElement()) {
- HTMLImageElement* imageElement = value.getAsHTMLImageElement();
- if (!imageElement || !imageElement->cachedImage()) {
- exceptionState.throwDOMException(
+ if (!(imageElement = value.getAsHTMLImageElement()))
+ return nullptr;
+ } else if (value.isSVGImageElement()) {
+ if (!(imageElement = value.getAsSVGImageElement()))
+ return nullptr;
+ }
+ if (imageElement) {
+ if (!imageElement->cachedImage()) {
+ exceptionState->throwDOMException(
InvalidStateError,
"No image can be retrieved from the provided element.");
return nullptr;
@@ -76,7 +84,7 @@ static inline ImageBitmapSource* toImageBitmapSourceInternal(
if (!image->hasIntrinsicDimensions() &&
(!hasCropRect &&
(!options.hasResizeWidth() || !options.hasResizeHeight()))) {
- exceptionState.throwDOMException(
+ exceptionState->throwDOMException(
InvalidStateError,
"The image element contains an SVG image without intrinsic "
"dimensions, and no resize options or crop region are specified.");
@@ -131,8 +139,8 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(
ExceptionState& exceptionState) {
UseCounter::Feature feature = UseCounter::CreateImageBitmap;
UseCounter::count(scriptState->getExecutionContext(), feature);
- ImageBitmapSource* bitmapSourceInternal =
- toImageBitmapSourceInternal(bitmapSource, exceptionState, options, false);
+ ImageBitmapSource* bitmapSourceInternal = toImageBitmapSourceInternal(
+ bitmapSource, &exceptionState, options, false);
if (!bitmapSourceInternal)
return ScriptPromise();
return createImageBitmap(scriptState, eventTarget, bitmapSourceInternal,
@@ -152,7 +160,7 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(
UseCounter::Feature feature = UseCounter::CreateImageBitmap;
UseCounter::count(scriptState->getExecutionContext(), feature);
ImageBitmapSource* bitmapSourceInternal =
- toImageBitmapSourceInternal(bitmapSource, exceptionState, options, true);
+ toImageBitmapSourceInternal(bitmapSource, &exceptionState, options, true);
if (!bitmapSourceInternal)
return ScriptPromise();
Optional<IntRect> cropRect = IntRect(sx, sy, sw, sh);

Powered by Google App Engine
This is Rietveld 408576698