Chromium Code Reviews| 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 6949fe788a5b329324ccbe20f50f11f22ff783ec..53c231e3b0cb28f5bcabe1fab133681a04e58cd4 100644 |
| --- a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp |
| +++ b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp |
| @@ -86,8 +86,12 @@ static inline ImageBitmapSource* toImageBitmapSourceInternal(const ImageBitmapSo |
| return nullptr; |
| } |
| -ScriptPromise ImageBitmapFactories::createImageBitmapFromBlob(ScriptState* scriptState, EventTarget& eventTarget, ImageBitmapSource* bitmapSource, const IntRect& cropRect, const ImageBitmapOptions& options) |
| +ScriptPromise ImageBitmapFactories::createImageBitmapFromBlob(ScriptState* scriptState, EventTarget& eventTarget, ImageBitmapSource* bitmapSource, const IntRect& cropRect, const ImageBitmapOptions& options, ExceptionState& exceptionState) |
| { |
| + if ((options.hasResizeWidth() && options.resizeWidth() <= 0) || (options.hasResizeHeight() && options.resizeHeight() <= 0)) { |
|
jbroman
2016/07/07 19:18:00
Is checking for negative values necessary? I think
xidachen
2016/07/07 20:43:29
Done. Now it is a static method in ImageBitmap cal
|
| + exceptionState.throwDOMException(InvalidStateError, "The resizeWidth or/and resizeHeight is less than or equals to 0."); |
| + return ScriptPromise(); |
| + } |
| Blob* blob = static_cast<Blob*>(bitmapSource); |
| ImageBitmapLoader* loader = ImageBitmapFactories::ImageBitmapLoader::create(from(eventTarget), cropRect, options, scriptState); |
| ScriptPromise promise = loader->promise(); |
| @@ -104,7 +108,7 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, |
| if (!bitmapSourceInternal) |
| return ScriptPromise(); |
| if (bitmapSourceInternal->isBlob()) |
| - return createImageBitmapFromBlob(scriptState, eventTarget, bitmapSourceInternal, IntRect(), options); |
| + return createImageBitmapFromBlob(scriptState, eventTarget, bitmapSourceInternal, IntRect(), options, exceptionState); |
| IntSize srcSize = bitmapSourceInternal->bitmapSourceSize(); |
| return createImageBitmap(scriptState, eventTarget, bitmapSourceInternal, 0, 0, srcSize.width(), srcSize.height(), options, exceptionState); |
| } |
| @@ -126,7 +130,7 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, |
| exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width")); |
| return ScriptPromise(); |
| } |
| - return createImageBitmapFromBlob(scriptState, eventTarget, bitmapSource, IntRect(sx, sy, sw, sh), options); |
| + return createImageBitmapFromBlob(scriptState, eventTarget, bitmapSource, IntRect(sx, sy, sw, sh), options, exceptionState); |
| } |
| return bitmapSource->createImageBitmap(scriptState, eventTarget, sx, sy, sw, sh, options, exceptionState); |