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

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

Issue 2035113002: Implement ImageBitmapOptions resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 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 6949fe788a5b329324ccbe20f50f11f22ff783ec..bfe7474ccddd3695260fd5ac9d21fa407ad1d4c0 100644
--- a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
+++ b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
@@ -86,8 +86,10 @@ 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 (!ImageBitmap::isResizeOptionValid(options, exceptionState))
+ return ScriptPromise();
Blob* blob = static_cast<Blob*>(bitmapSource);
ImageBitmapLoader* loader = ImageBitmapFactories::ImageBitmapLoader::create(from(eventTarget), cropRect, options, scriptState);
ScriptPromise promise = loader->promise();
@@ -104,7 +106,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);
}
@@ -122,11 +124,9 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, ImageBitmapSource* bitmapSource, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
{
if (bitmapSource->isBlob()) {
- if (!sw || !sh) {
- exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width"));
+ if (!ImageBitmap::isSWSHValid(sw, sh, exceptionState))
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);

Powered by Google App Engine
This is Rietveld 408576698