| Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| index ca1f5ac6b3c46766c330ea23d7032a3c969c193e..11dea96195ae846675480dd67a533b6512030a0c 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
|
| @@ -1106,14 +1106,15 @@ IntSize HTMLCanvasElement::bitmapSourceSize() const
|
| return IntSize(width(), height());
|
| }
|
|
|
| -ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
|
| +ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, Optional<IntRect> cropRect, const ImageBitmapOptions& options, ExceptionState& exceptionState)
|
| {
|
| DCHECK(eventTarget.toLocalDOMWindow());
|
| - if (!sw || !sh) {
|
| - exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width"));
|
| + if ((cropRect && !ImageBitmap::isSourceSizeValid(cropRect->width(), cropRect->height(), exceptionState))
|
| + || !ImageBitmap::isSourceSizeValid(bitmapSourceSize().width(), bitmapSourceSize().height(), exceptionState))
|
| return ScriptPromise();
|
| - }
|
| - return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? ImageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr);
|
| + if (!ImageBitmap::isResizeOptionValid(options, exceptionState))
|
| + return ScriptPromise();
|
| + return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? ImageBitmap::create(this, cropRect, options) : nullptr);
|
| }
|
|
|
| bool HTMLCanvasElement::isOpaque() const
|
|
|