| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class HTMLVideoElement; | 53 class HTMLVideoElement; |
| 54 class ImageBitmap; | 54 class ImageBitmap; |
| 55 class ImageData; | 55 class ImageData; |
| 56 class ExecutionContext; | 56 class ExecutionContext; |
| 57 | 57 |
| 58 class ImageBitmapFactories FINAL : public Supplement<DOMWindow>, public WorkerSu
pplement { | 58 class ImageBitmapFactories FINAL : public Supplement<DOMWindow>, public WorkerSu
pplement { |
| 59 | 59 |
| 60 class ImageBitmapLoader; | 60 class ImageBitmapLoader; |
| 61 | 61 |
| 62 public: | 62 public: |
| 63 static ScriptPromise createImageBitmap(EventTarget*, HTMLImageElement*, Exce
ptionState&); | 63 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, Exce
ptionState&); |
| 64 static ScriptPromise createImageBitmap(EventTarget*, HTMLImageElement*, int
sx, int sy, int sw, int sh, ExceptionState&); | 64 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 65 static ScriptPromise createImageBitmap(EventTarget*, HTMLVideoElement*, Exce
ptionState&); | 65 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, Exce
ptionState&); |
| 66 static ScriptPromise createImageBitmap(EventTarget*, HTMLVideoElement*, int
sx, int sy, int sw, int sh, ExceptionState&); | 66 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 67 static ScriptPromise createImageBitmap(EventTarget*, CanvasRenderingContext2
D*, ExceptionState&); | 67 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2
D*, ExceptionState&); |
| 68 static ScriptPromise createImageBitmap(EventTarget*, CanvasRenderingContext2
D*, int sx, int sy, int sw, int sh, ExceptionState&); | 68 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2
D*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 69 static ScriptPromise createImageBitmap(EventTarget*, HTMLCanvasElement*, Exc
eptionState&); | 69 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, Exc
eptionState&); |
| 70 static ScriptPromise createImageBitmap(EventTarget*, HTMLCanvasElement*, int
sx, int sy, int sw, int sh, ExceptionState&); | 70 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, int
sx, int sy, int sw, int sh, ExceptionState&); |
| 71 static ScriptPromise createImageBitmap(EventTarget*, Blob*, ExceptionState&)
; | 71 static ScriptPromise createImageBitmap(EventTarget&, Blob*, ExceptionState&)
; |
| 72 static ScriptPromise createImageBitmap(EventTarget*, Blob*, int sx, int sy,
int sw, int sh, ExceptionState&); | 72 static ScriptPromise createImageBitmap(EventTarget&, Blob*, int sx, int sy,
int sw, int sh, ExceptionState&); |
| 73 static ScriptPromise createImageBitmap(EventTarget*, ImageData*, ExceptionSt
ate&); | 73 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, ExceptionSt
ate&); |
| 74 static ScriptPromise createImageBitmap(EventTarget*, ImageData*, int sx, int
sy, int sw, int sh, ExceptionState&); | 74 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, int sx, int
sy, int sw, int sh, ExceptionState&); |
| 75 static ScriptPromise createImageBitmap(EventTarget*, ImageBitmap*, Exception
State&); | 75 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, Exception
State&); |
| 76 static ScriptPromise createImageBitmap(EventTarget*, ImageBitmap*, int sx, i
nt sy, int sw, int sh, ExceptionState&); | 76 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, int sx, i
nt sy, int sw, int sh, ExceptionState&); |
| 77 | 77 |
| 78 void didFinishLoading(ImageBitmapLoader*); | 78 void didFinishLoading(ImageBitmapLoader*); |
| 79 | 79 |
| 80 virtual ~ImageBitmapFactories() { } | 80 virtual ~ImageBitmapFactories() { } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 class ImageBitmapLoader FINAL : public RefCounted<ImageBitmapLoader>, public
FileReaderLoaderClient { | 83 class ImageBitmapLoader FINAL : public RefCounted<ImageBitmapLoader>, public
FileReaderLoaderClient { |
| 84 public: | 84 public: |
| 85 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories* factor
y, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) | 85 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories& factor
y, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) |
| 86 { | 86 { |
| 87 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); | 87 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void loadBlobAsync(ExecutionContext*, Blob*); | 90 void loadBlobAsync(ExecutionContext*, Blob*); |
| 91 | 91 |
| 92 virtual ~ImageBitmapLoader() { } | 92 virtual ~ImageBitmapLoader() { } |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 ImageBitmapLoader(ImageBitmapFactories*, PassRefPtr<ScriptPromiseResolve
r>, const IntRect&); | 95 ImageBitmapLoader(ImageBitmapFactories&, PassRefPtr<ScriptPromiseResolve
r>, const IntRect&); |
| 96 | 96 |
| 97 void rejectPromise(); | 97 void rejectPromise(); |
| 98 | 98 |
| 99 // FileReaderLoaderClient | 99 // FileReaderLoaderClient |
| 100 virtual void didStartLoading() OVERRIDE { } | 100 virtual void didStartLoading() OVERRIDE { } |
| 101 virtual void didReceiveData() OVERRIDE { } | 101 virtual void didReceiveData() OVERRIDE { } |
| 102 virtual void didFinishLoading() OVERRIDE; | 102 virtual void didFinishLoading() OVERRIDE; |
| 103 virtual void didFail(FileError::ErrorCode) OVERRIDE; | 103 virtual void didFail(FileError::ErrorCode) OVERRIDE; |
| 104 | 104 |
| 105 ScriptState* m_scriptState; | 105 ScriptState* m_scriptState; |
| 106 FileReaderLoader m_loader; | 106 FileReaderLoader m_loader; |
| 107 ImageBitmapFactories* m_factory; | 107 ImageBitmapFactories* m_factory; |
| 108 RefPtr<ScriptPromiseResolver> m_resolver; | 108 RefPtr<ScriptPromiseResolver> m_resolver; |
| 109 IntRect m_cropRect; | 109 IntRect m_cropRect; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 static const char* supplementName(); | 112 static const char* supplementName(); |
| 113 static ImageBitmapFactories* from(EventTarget*); | 113 static ImageBitmapFactories& from(EventTarget&); |
| 114 | 114 |
| 115 template <class T> | 115 template <class T> |
| 116 static ImageBitmapFactories* fromInternal(T*); | 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 } // namespace WebCore | 123 } // namespace WebCore |
| 124 | 124 |
| 125 #endif // ImageBitmapFactories_h | 125 #endif // ImageBitmapFactories_h |
| OLD | NEW |