| Index: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| index 04ae3c0f4c4b88d04dc13ea5d87e69732cfcd376..7aaf6d03619563a6e1bc94d49151020323f35d1d 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| @@ -327,7 +327,7 @@ IntSize HTMLVideoElement::bitmapSourceSize() const
|
| return IntSize(videoWidth(), videoHeight());
|
| }
|
|
|
| -ScriptPromise HTMLVideoElement::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
|
| +ScriptPromise HTMLVideoElement::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, Optional<IntRect> cropRect, const ImageBitmapOptions& options, ExceptionState& exceptionState)
|
| {
|
| DCHECK(eventTarget.toLocalDOMWindow());
|
| if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) {
|
| @@ -338,11 +338,12 @@ ScriptPromise HTMLVideoElement::createImageBitmap(ScriptState* scriptState, Even
|
| exceptionState.throwDOMException(InvalidStateError, "The provided element's player has no current data.");
|
| return ScriptPromise();
|
| }
|
| - 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, ImageBitmap::create(this, IntRect(sx, sy, sw, sh), eventTarget.toLocalDOMWindow()->document(), options));
|
| + if (!ImageBitmap::isResizeOptionValid(options, exceptionState))
|
| + return ScriptPromise();
|
| + return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::create(this, cropRect, eventTarget.toLocalDOMWindow()->document(), options));
|
| }
|
|
|
| } // namespace blink
|
|
|