| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ImageBitmapFactories_h | 31 #ifndef ImageBitmapFactories_h |
| 32 #define ImageBitmapFactories_h | 32 #define ImageBitmapFactories_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptPromise.h" | 34 #include "bindings/v8/ScriptPromise.h" |
| 35 #include "bindings/v8/ScriptPromiseResolver.h" | 35 #include "bindings/v8/ScriptPromiseResolver.h" |
| 36 #include "bindings/v8/ScriptState.h" | 36 #include "bindings/v8/ScriptState.h" |
| 37 #include "core/fileapi/FileReaderLoader.h" | 37 #include "core/fileapi/FileReaderLoader.h" |
| 38 #include "core/fileapi/FileReaderLoaderClient.h" | 38 #include "core/fileapi/FileReaderLoaderClient.h" |
| 39 #include "core/workers/WorkerSupplementable.h" | |
| 40 #include "platform/Supplementable.h" | 39 #include "platform/Supplementable.h" |
| 41 #include "platform/geometry/IntRect.h" | 40 #include "platform/geometry/IntRect.h" |
| 42 #include "wtf/Forward.h" | 41 #include "wtf/Forward.h" |
| 43 #include "wtf/HashSet.h" | 42 #include "wtf/HashSet.h" |
| 44 | 43 |
| 45 namespace WebCore { | 44 namespace WebCore { |
| 46 | 45 |
| 47 class Blob; | 46 class Blob; |
| 48 class CanvasRenderingContext2D; | 47 class CanvasRenderingContext2D; |
| 49 class EventTarget; | 48 class EventTarget; |
| 50 class ExceptionState; | 49 class ExceptionState; |
| 51 class HTMLCanvasElement; | 50 class HTMLCanvasElement; |
| 52 class HTMLImageElement; | 51 class HTMLImageElement; |
| 53 class HTMLVideoElement; | 52 class HTMLVideoElement; |
| 54 class ImageBitmap; | 53 class ImageBitmap; |
| 55 class ImageData; | 54 class ImageData; |
| 56 class ExecutionContext; | 55 class ExecutionContext; |
| 57 | 56 |
| 58 class ImageBitmapFactories FINAL : public Supplement<DOMWindow>, public WorkerSu
pplement { | 57 class ImageBitmapFactories : public Supplement<DOMWindow> { |
| 59 | 58 |
| 60 class ImageBitmapLoader; | 59 class ImageBitmapLoader; |
| 61 | 60 |
| 62 public: | 61 public: |
| 63 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, Exce
ptionState&); | 62 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, Exce
ptionState&); |
| 64 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, int
sx, int sy, int sw, int sh, ExceptionState&); | 63 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 65 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, Exce
ptionState&); | 64 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, Exce
ptionState&); |
| 66 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, int
sx, int sy, int sw, int sh, ExceptionState&); | 65 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 67 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2
D*, ExceptionState&); | 66 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2
D*, ExceptionState&); |
| 68 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2
D*, int sx, int sy, int sw, int sh, ExceptionState&); | 67 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2
D*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 69 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, Exc
eptionState&); | 68 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, Exc
eptionState&); |
| 70 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, int
sx, int sy, int sw, int sh, ExceptionState&); | 69 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 71 static ScriptPromise createImageBitmap(EventTarget&, Blob*, ExceptionState&)
; | 70 static ScriptPromise createImageBitmap(EventTarget&, Blob*, ExceptionState&)
; |
| 72 static ScriptPromise createImageBitmap(EventTarget&, Blob*, int sx, int sy,
int sw, int sh, ExceptionState&); | 71 static ScriptPromise createImageBitmap(EventTarget&, Blob*, int sx, int sy,
int sw, int sh, ExceptionState&); |
| 73 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, ExceptionSt
ate&); | 72 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, ExceptionSt
ate&); |
| 74 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, int sx, int
sy, int sw, int sh, ExceptionState&); | 73 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, int sx, int
sy, int sw, int sh, ExceptionState&); |
| 75 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, Exception
State&); | 74 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, Exception
State&); |
| 76 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, int sx, i
nt sy, int sw, int sh, ExceptionState&); | 75 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, int sx, i
nt sy, int sw, int sh, ExceptionState&); |
| 77 | 76 |
| 78 void didFinishLoading(ImageBitmapLoader*); | 77 void didFinishLoading(ImageBitmapLoader*); |
| 79 | 78 |
| 80 virtual ~ImageBitmapFactories() { } | 79 virtual ~ImageBitmapFactories() { } |
| 81 | 80 |
| 81 protected: |
| 82 static const char* supplementName(); |
| 83 |
| 82 private: | 84 private: |
| 83 class ImageBitmapLoader FINAL : public RefCounted<ImageBitmapLoader>, public
FileReaderLoaderClient { | 85 class ImageBitmapLoader FINAL : public RefCounted<ImageBitmapLoader>, public
FileReaderLoaderClient { |
| 84 public: | 86 public: |
| 85 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories& factor
y, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) | 87 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories& factor
y, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) |
| 86 { | 88 { |
| 87 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); | 89 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); |
| 88 } | 90 } |
| 89 | 91 |
| 90 void loadBlobAsync(ExecutionContext*, Blob*); | 92 void loadBlobAsync(ExecutionContext*, Blob*); |
| 91 | 93 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 102 virtual void didFinishLoading() OVERRIDE; | 104 virtual void didFinishLoading() OVERRIDE; |
| 103 virtual void didFail(FileError::ErrorCode) OVERRIDE; | 105 virtual void didFail(FileError::ErrorCode) OVERRIDE; |
| 104 | 106 |
| 105 ScriptState* m_scriptState; | 107 ScriptState* m_scriptState; |
| 106 FileReaderLoader m_loader; | 108 FileReaderLoader m_loader; |
| 107 ImageBitmapFactories* m_factory; | 109 ImageBitmapFactories* m_factory; |
| 108 RefPtr<ScriptPromiseResolver> m_resolver; | 110 RefPtr<ScriptPromiseResolver> m_resolver; |
| 109 IntRect m_cropRect; | 111 IntRect m_cropRect; |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 static const char* supplementName(); | |
| 113 static ImageBitmapFactories& from(EventTarget&); | 114 static ImageBitmapFactories& from(EventTarget&); |
| 114 | 115 |
| 115 template <class T> | 116 static ImageBitmapFactories& fromInternal(DOMWindow&); |
| 116 static ImageBitmapFactories& fromInternal(T&); | |
| 117 | 117 |
| 118 void addLoader(PassRefPtr<ImageBitmapLoader>); | 118 void addLoader(PassRefPtr<ImageBitmapLoader>); |
| 119 | 119 |
| 120 HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders; | 120 HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // FIXME: oilpan: remove once DOMWindow and its Supplementable becomes heap allo
cated. |
| 124 class WorkerGlobalScopeImageBitmapFactories FINAL : public NoBaseWillBeGarbageCo
llectedFinalized<WorkerGlobalScopeImageBitmapFactories>, public ImageBitmapFacto
ries, public WillBeHeapSupplement<WorkerGlobalScope> { |
| 125 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkerGlobalScopeImageBitmapFactories)
; |
| 126 public: |
| 127 virtual ~WorkerGlobalScopeImageBitmapFactories() { } |
| 128 |
| 129 virtual void trace(Visitor*); |
| 130 |
| 131 private: |
| 132 friend class ImageBitmapFactories; |
| 133 static ImageBitmapFactories& fromInternal(WorkerGlobalScope&); |
| 134 }; |
| 135 |
| 123 } // namespace WebCore | 136 } // namespace WebCore |
| 124 | 137 |
| 125 #endif // ImageBitmapFactories_h | 138 #endif // ImageBitmapFactories_h |
| OLD | NEW |