| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 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/ScriptPromiseResolver.h" | 35 #include "bindings/v8/ScriptPromiseResolver.h" |
| 35 #include "bindings/v8/ScriptState.h" | 36 #include "bindings/v8/ScriptState.h" |
| 36 #include "core/fileapi/FileReaderLoader.h" | 37 #include "core/fileapi/FileReaderLoader.h" |
| 37 #include "core/fileapi/FileReaderLoaderClient.h" | 38 #include "core/fileapi/FileReaderLoaderClient.h" |
| 38 #include "core/platform/Supplementable.h" | 39 #include "core/platform/Supplementable.h" |
| 39 #include "core/platform/graphics/IntRect.h" | 40 #include "core/platform/graphics/IntRect.h" |
| 40 #include "wtf/Forward.h" | 41 #include "wtf/Forward.h" |
| 41 #include "wtf/HashSet.h" | 42 #include "wtf/HashSet.h" |
| 42 | 43 |
| 43 namespace WebCore { | 44 namespace WebCore { |
| 44 | 45 |
| 45 class Blob; | 46 class Blob; |
| 46 class CanvasRenderingContext2D; | 47 class CanvasRenderingContext2D; |
| 47 class EventTarget; | 48 class EventTarget; |
| 48 class ExceptionState; | 49 class ExceptionState; |
| 49 class HTMLCanvasElement; | 50 class HTMLCanvasElement; |
| 50 class HTMLImageElement; | 51 class HTMLImageElement; |
| 51 class HTMLVideoElement; | 52 class HTMLVideoElement; |
| 52 class ImageBitmap; | 53 class ImageBitmap; |
| 53 class ImageData; | 54 class ImageData; |
| 54 class ScriptExecutionContext; | 55 class ScriptExecutionContext; |
| 55 | 56 |
| 56 class ImageBitmapFactories : public Supplement<DOMWindow>, public Supplement<Scr
iptExecutionContext> { | 57 class ImageBitmapFactories : public Supplement<DOMWindow>, public Supplement<Scr
iptExecutionContext> { |
| 57 | 58 |
| 58 class ImageBitmapLoader; | 59 class ImageBitmapLoader; |
| 59 | 60 |
| 60 public: | 61 public: |
| 61 static ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, Excep
tionState&); | 62 static ScriptPromise createImageBitmap(EventTarget*, HTMLImageElement*, Exce
ptionState&); |
| 62 static ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, int s
x, int sy, int sw, int sh, ExceptionState&); | 63 static ScriptPromise createImageBitmap(EventTarget*, HTMLImageElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 63 static ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, Excep
tionState&); | 64 static ScriptPromise createImageBitmap(EventTarget*, HTMLVideoElement*, Exce
ptionState&); |
| 64 static ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, int s
x, int sy, int sw, int sh, ExceptionState&); | 65 static ScriptPromise createImageBitmap(EventTarget*, HTMLVideoElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 65 static ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D
*, ExceptionState&); | 66 static ScriptPromise createImageBitmap(EventTarget*, CanvasRenderingContext2
D*, ExceptionState&); |
| 66 static ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D
*, 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&); |
| 67 static ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, Exce
ptionState&); | 68 static ScriptPromise createImageBitmap(EventTarget*, HTMLCanvasElement*, Exc
eptionState&); |
| 68 static ScriptObject 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&); |
| 69 static ScriptObject createImageBitmap(EventTarget*, Blob*, ExceptionState&); | 70 static ScriptPromise createImageBitmap(EventTarget*, Blob*, ExceptionState&)
; |
| 70 static ScriptObject createImageBitmap(EventTarget*, Blob*, int sx, int sy, i
nt sw, int sh, ExceptionState&); | 71 static ScriptPromise createImageBitmap(EventTarget*, Blob*, int sx, int sy,
int sw, int sh, ExceptionState&); |
| 71 static ScriptObject createImageBitmap(EventTarget*, ImageData*, ExceptionSta
te&); | 72 static ScriptPromise createImageBitmap(EventTarget*, ImageData*, ExceptionSt
ate&); |
| 72 static ScriptObject 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&); |
| 73 static ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, ExceptionS
tate&); | 74 static ScriptPromise createImageBitmap(EventTarget*, ImageBitmap*, Exception
State&); |
| 74 static ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, int sx, in
t sy, int sw, int sh, ExceptionState&); | 75 static ScriptPromise createImageBitmap(EventTarget*, ImageBitmap*, int sx, i
nt sy, int sw, int sh, ExceptionState&); |
| 75 | 76 |
| 76 void didFinishLoading(ImageBitmapLoader*); | 77 void didFinishLoading(ImageBitmapLoader*); |
| 77 | 78 |
| 78 virtual ~ImageBitmapFactories() { } | 79 virtual ~ImageBitmapFactories() { } |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 class ImageBitmapLoader : public RefCounted<ImageBitmapLoader>, public FileR
eaderLoaderClient { | 82 class ImageBitmapLoader : public RefCounted<ImageBitmapLoader>, public FileR
eaderLoaderClient { |
| 82 public: | 83 public: |
| 83 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories* factor
y, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) | 84 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories* factor
y, ScriptPromiseResolver resolver, const IntRect& cropRect) |
| 84 { | 85 { |
| 85 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); | 86 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void loadBlobAsync(ScriptExecutionContext*, Blob*); | 89 void loadBlobAsync(ScriptExecutionContext*, Blob*); |
| 89 | 90 |
| 90 ~ImageBitmapLoader() { } | 91 ~ImageBitmapLoader() { } |
| 91 | 92 |
| 92 private: | 93 private: |
| 93 ImageBitmapLoader(ImageBitmapFactories*, PassRefPtr<ScriptPromiseResolve
r>, const IntRect&); | 94 ImageBitmapLoader(ImageBitmapFactories*, ScriptPromiseResolver, const In
tRect&); |
| 94 | 95 |
| 95 void rejectPromise(); | 96 void rejectPromise(); |
| 96 | 97 |
| 97 // FileReaderLoaderClient | 98 // FileReaderLoaderClient |
| 98 virtual void didStartLoading() OVERRIDE { } | 99 virtual void didStartLoading() OVERRIDE { } |
| 99 virtual void didReceiveData() OVERRIDE { } | 100 virtual void didReceiveData() OVERRIDE { } |
| 100 virtual void didFinishLoading() OVERRIDE; | 101 virtual void didFinishLoading() OVERRIDE; |
| 101 virtual void didFail(FileError::ErrorCode) OVERRIDE; | 102 virtual void didFail(FileError::ErrorCode) OVERRIDE; |
| 102 | 103 |
| 103 ScriptState* m_scriptState; | 104 ScriptState* m_scriptState; |
| 104 FileReaderLoader m_loader; | 105 FileReaderLoader m_loader; |
| 105 ImageBitmapFactories* m_factory; | 106 ImageBitmapFactories* m_factory; |
| 106 RefPtr<ScriptPromiseResolver> m_resolver; | 107 ScriptPromiseResolver m_resolver; |
| 107 IntRect m_cropRect; | 108 IntRect m_cropRect; |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 static const char* supplementName(); | 111 static const char* supplementName(); |
| 111 static ImageBitmapFactories* from(EventTarget*); | 112 static ImageBitmapFactories* from(EventTarget*); |
| 112 | 113 |
| 113 template <class T> | 114 template <class T> |
| 114 static ImageBitmapFactories* fromInternal(T*); | 115 static ImageBitmapFactories* fromInternal(T*); |
| 115 | 116 |
| 116 void addLoader(PassRefPtr<ImageBitmapLoader>); | 117 void addLoader(PassRefPtr<ImageBitmapLoader>); |
| 117 | 118 |
| 118 HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders; | 119 HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders; |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 } // namespace WebCore | 122 } // namespace WebCore |
| 122 | 123 |
| 123 #endif // ImageBitmapFactories_h | 124 #endif // ImageBitmapFactories_h |
| OLD | NEW |