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

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

Issue 2122273002: Merge some repeated code in ImageBitmapFactories into a helper function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2e22bf027d36092ac087c597d8d5949fb13a2b16..6949fe788a5b329324ccbe20f50f11f22ff783ec 100644
--- a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
+++ b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
@@ -86,6 +86,16 @@ static inline ImageBitmapSource* toImageBitmapSourceInternal(const ImageBitmapSo
return nullptr;
}
+ScriptPromise ImageBitmapFactories::createImageBitmapFromBlob(ScriptState* scriptState, EventTarget& eventTarget, ImageBitmapSource* bitmapSource, const IntRect& cropRect, const ImageBitmapOptions& options)
+{
+ Blob* blob = static_cast<Blob*>(bitmapSource);
+ ImageBitmapLoader* loader = ImageBitmapFactories::ImageBitmapLoader::create(from(eventTarget), cropRect, options, scriptState);
+ ScriptPromise promise = loader->promise();
+ from(eventTarget).addLoader(loader);
+ loader->loadBlobAsync(eventTarget.getExecutionContext(), blob);
+ return promise;
+}
+
ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, const ImageBitmapOptions& options, ExceptionState& exceptionState)
{
UseCounter::Feature feature = UseCounter::CreateImageBitmap;
@@ -93,14 +103,8 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
ImageBitmapSource* bitmapSourceInternal = toImageBitmapSourceInternal(bitmapSource, exceptionState, false);
if (!bitmapSourceInternal)
return ScriptPromise();
- if (bitmapSourceInternal->isBlob()) {
- Blob* blob = static_cast<Blob*>(bitmapSourceInternal);
- ImageBitmapLoader* loader = ImageBitmapFactories::ImageBitmapLoader::create(from(eventTarget), IntRect(), options, scriptState);
- ScriptPromise promise = loader->promise();
- from(eventTarget).addLoader(loader);
- loader->loadBlobAsync(eventTarget.getExecutionContext(), blob);
- return promise;
- }
+ if (bitmapSourceInternal->isBlob())
+ return createImageBitmapFromBlob(scriptState, eventTarget, bitmapSourceInternal, IntRect(), options);
IntSize srcSize = bitmapSourceInternal->bitmapSourceSize();
return createImageBitmap(scriptState, eventTarget, bitmapSourceInternal, 0, 0, srcSize.width(), srcSize.height(), options, exceptionState);
}
@@ -122,12 +126,7 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width"));
return ScriptPromise();
}
- Blob* blob = static_cast<Blob*>(bitmapSource);
- ImageBitmapLoader* loader = ImageBitmapFactories::ImageBitmapLoader::create(from(eventTarget), IntRect(sx, sy, sw, sh), options, scriptState);
- ScriptPromise promise = loader->promise();
- from(eventTarget).addLoader(loader);
- loader->loadBlobAsync(eventTarget.getExecutionContext(), blob);
- return promise;
+ return createImageBitmapFromBlob(scriptState, eventTarget, bitmapSource, IntRect(sx, sy, sw, sh), options);
}
return bitmapSource->createImageBitmap(scriptState, eventTarget, sx, sy, sw, sh, options, exceptionState);
« no previous file with comments | « third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698