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

Unified Diff: Source/core/page/ImageBitmapFactories.h

Issue 20748002: Blob creation methods for ImageBitmap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make ImageBitmapFactories a class. Created 7 years, 4 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: Source/core/page/ImageBitmapFactories.h
diff --git a/Source/core/page/ImageBitmapFactories.h b/Source/core/page/ImageBitmapFactories.h
index 05feca4ffc17d90f247e869bd42b51f43ae72575..23c34d98c66c55a1611f9a2587e4ffadf5aab7d3 100644
--- a/Source/core/page/ImageBitmapFactories.h
+++ b/Source/core/page/ImageBitmapFactories.h
@@ -32,9 +32,16 @@
#define ImageBitmapFactories_h
#include "bindings/v8/ScriptPromiseResolver.h"
+#include "bindings/v8/ScriptState.h"
+#include "core/fileapi/FileReaderLoader.h"
+#include "core/fileapi/FileReaderLoaderClient.h"
+#include "core/platform/graphics/IntRect.h"
+#include "wtf/Forward.h"
+#include "wtf/HashSet.h"
namespace WebCore {
+class Blob;
class CanvasRenderingContext2D;
class EventTarget;
class ExceptionState;
@@ -43,23 +50,64 @@ class HTMLImageElement;
class HTMLVideoElement;
class ImageBitmap;
class ImageData;
+class ScriptExecutionContext;
+
+class ImageBitmapFactories {
+
+class ImageBitmapLoader;
+public:
+ static ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, int sx, int sy, int sw, int sh, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, int sx, int sy, int sw, int sh, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D*, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D*, int sx, int sy, int sw, int sh, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, int sx, int sy, int sw, int sh, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, Blob*, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, Blob*, int sx, int sy, int sw, int sh, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, ImageData*, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, ImageData*, int sx, int sy, int sw, int sh, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, ExceptionState&);
+ static ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, int sx, int sy, int sw, int sh, ExceptionState&);
+
+ void didStartLoading(PassRefPtr<ImageBitmapLoader>);
+ void didFinishLoading(PassRefPtr<ImageBitmapLoader>);
+
+private:
+ class ImageBitmapLoader : public RefCounted<ImageBitmapLoader>, public FileReaderLoaderClient {
+ public:
+ static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories* factory, PassRefPtr<ScriptPromiseResolver> resolver, IntRect* cropRect)
do-not-use 2013/08/12 15:36:15 It is confusing to take an IntRect raw pointer in
+ {
+ RefPtr<ImageBitmapLoader> imageBitmapLoader = adoptRef(new ImageBitmapLoader(factory, resolver, cropRect));
do-not-use 2013/08/12 15:36:15 nit: We don't really need this local variable.
arbesfeld 2013/08/12 15:49:40 Done.
+ return imageBitmapLoader.release();
+ }
+
+ void loadBlobAsync(ScriptExecutionContext*, Blob*);
+
+ ~ImageBitmapLoader() { }
+
+ private:
+ ImageBitmapLoader(ImageBitmapFactories*, PassRefPtr<ScriptPromiseResolver>, IntRect*);
+
+ void rejectPromise();
+
+ // FileReaderLoaderClient
+ virtual void didStartLoading() { }
do-not-use 2013/08/12 15:36:15 Missing OVERRIDE (below as well)
arbesfeld 2013/08/12 15:49:40 Done.
+ virtual void didReceiveData() { }
+ virtual void didFinishLoading();
+ virtual void didFail(FileError::ErrorCode);
+
+ ScriptState* m_scriptState;
+ FileReaderLoader m_loader;
+ ImageBitmapFactories* m_factory;
+ RefPtr<ScriptPromiseResolver> m_resolver;
+ IntRect* m_cropRect;
do-not-use 2013/08/12 15:36:15 Why does m_cropRect need to be a pointer? Do we ne
arbesfeld 2013/08/12 15:49:40 ImageBitmaps created with no x/y/w/h arguments are
+ };
+
+ HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders;
+};
-namespace ImageBitmapFactories {
-
-ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, int sx, int sy, int sw, int sh, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, int sx, int sy, int sw, int sh, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D*, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D*, int sx, int sy, int sw, int sh, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, int sx, int sy, int sw, int sh, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, ImageData*, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, ImageData*, int sx, int sy, int sw, int sh, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, ExceptionState&);
-ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, int sx, int sy, int sw, int sh, ExceptionState&);
-
-} // namesapce ImageBitmapFactories
} // namespace WebCore
#endif // ImageBitmapFactories_h

Powered by Google App Engine
This is Rietveld 408576698