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

Unified Diff: Source/modules/imagebitmap/ImageBitmapFactories.cpp

Issue 211313003: Fix crash when creating an ImageBitmap from an invalid canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/imagebitmap/ImageBitmapFactories.cpp
diff --git a/Source/modules/imagebitmap/ImageBitmapFactories.cpp b/Source/modules/imagebitmap/ImageBitmapFactories.cpp
index fd4eaf0625fb6ac3dfd00303b406e94198713931..debe56b6b83c1c647466131198d0e77192f3f227 100644
--- a/Source/modules/imagebitmap/ImageBitmapFactories.cpp
+++ b/Source/modules/imagebitmap/ImageBitmapFactories.cpp
@@ -63,11 +63,16 @@ static IntSize sizeFor(HTMLVideoElement* video)
return IntSize();
}
-static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtrWillBeRawPtr<ImageBitmap> imageBitmap)
+ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtrWillBeRawPtr<ImageBitmap> imageBitmap)
Stephen White 2014/03/25 16:56:31 Is there a reason this needs to be non-static?
{
RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(context);
ScriptPromise promise = resolver->promise();
- resolver->resolve(imageBitmap);
+ if (imageBitmap) {
+ resolver->resolve(imageBitmap);
+ } else {
+ v8::Isolate* isolate = ScriptState::current()->isolate();
+ resolver->reject(ScriptValue(v8::Null(isolate), isolate));
+ }
return promise;
}
@@ -185,8 +190,9 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget,
exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width"));
return ScriptPromise();
}
+
// FIXME: make ImageBitmap creation asynchronous crbug.com/258082
- return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::create(canvas, IntRect(sx, sy, sw, sh)));
+ return fulfillImageBitmap(eventTarget.executionContext(), canvas->buffer() ? ImageBitmap::create(canvas, IntRect(sx, sy, sw, sh)) : nullptr);
}
ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, Blob* blob, ExceptionState& exceptionState)
« no previous file with comments | « LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698