Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 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/ScriptPromiseResolver.h" | 34 #include "bindings/v8/ScriptPromiseResolver.h" |
| 35 #include "bindings/v8/ScriptState.h" | |
| 36 #include "core/fileapi/FileReaderLoader.h" | |
| 37 #include "core/fileapi/FileReaderLoaderClient.h" | |
| 38 #include "core/platform/graphics/IntRect.h" | |
| 39 #include "wtf/Forward.h" | |
| 40 #include "wtf/HashSet.h" | |
| 35 | 41 |
| 36 namespace WebCore { | 42 namespace WebCore { |
| 37 | 43 |
| 44 class Blob; | |
| 38 class CanvasRenderingContext2D; | 45 class CanvasRenderingContext2D; |
| 39 class EventTarget; | 46 class EventTarget; |
| 40 class ExceptionState; | 47 class ExceptionState; |
| 41 class HTMLCanvasElement; | 48 class HTMLCanvasElement; |
| 42 class HTMLImageElement; | 49 class HTMLImageElement; |
| 43 class HTMLVideoElement; | 50 class HTMLVideoElement; |
| 44 class ImageBitmap; | 51 class ImageBitmap; |
| 45 class ImageData; | 52 class ImageData; |
| 53 class ScriptExecutionContext; | |
| 46 | 54 |
| 47 namespace ImageBitmapFactories { | 55 class ImageBitmapFactories { |
| 48 | 56 |
| 49 ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, ExceptionState&) ; | 57 class ImageBitmapLoader; |
| 50 ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, int sx, int sy, int sw, int sh, ExceptionState&); | 58 public: |
| 51 ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, ExceptionState&) ; | 59 static ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, Excep tionState&); |
| 52 ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, int sx, int sy, int sw, int sh, ExceptionState&); | 60 static ScriptObject createImageBitmap(EventTarget*, HTMLImageElement*, int s x, int sy, int sw, int sh, ExceptionState&); |
| 53 ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D*, Exceptio nState&); | 61 static ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, Excep tionState&); |
| 54 ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D*, int sx, int sy, int sw, int sh, ExceptionState&); | 62 static ScriptObject createImageBitmap(EventTarget*, HTMLVideoElement*, int s x, int sy, int sw, int sh, ExceptionState&); |
| 55 ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, ExceptionState& ); | 63 static ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D *, ExceptionState&); |
| 56 ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, int sx, int sy, int sw, int sh, ExceptionState&); | 64 static ScriptObject createImageBitmap(EventTarget*, CanvasRenderingContext2D *, int sx, int sy, int sw, int sh, ExceptionState&); |
| 57 ScriptObject createImageBitmap(EventTarget*, ImageData*, ExceptionState&); | 65 static ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, Exce ptionState&); |
| 58 ScriptObject createImageBitmap(EventTarget*, ImageData*, int sx, int sy, int sw, int sh, ExceptionState&); | 66 static ScriptObject createImageBitmap(EventTarget*, HTMLCanvasElement*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 59 ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, ExceptionState&); | 67 static ScriptObject createImageBitmap(EventTarget*, Blob*, ExceptionState&); |
| 60 ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, int sx, int sy, int s w, int sh, ExceptionState&); | 68 static ScriptObject createImageBitmap(EventTarget*, Blob*, int sx, int sy, i nt sw, int sh, ExceptionState&); |
| 69 static ScriptObject createImageBitmap(EventTarget*, ImageData*, ExceptionSta te&); | |
| 70 static ScriptObject createImageBitmap(EventTarget*, ImageData*, int sx, int sy, int sw, int sh, ExceptionState&); | |
| 71 static ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, ExceptionS tate&); | |
| 72 static ScriptObject createImageBitmap(EventTarget*, ImageBitmap*, int sx, in t sy, int sw, int sh, ExceptionState&); | |
| 61 | 73 |
| 62 } // namesapce ImageBitmapFactories | 74 void didStartLoading(PassRefPtr<ImageBitmapLoader>); |
| 75 void didFinishLoading(PassRefPtr<ImageBitmapLoader>); | |
| 76 | |
| 77 private: | |
| 78 class ImageBitmapLoader : public RefCounted<ImageBitmapLoader>, public FileR eaderLoaderClient { | |
| 79 public: | |
| 80 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories* factor y, PassRefPtr<ScriptPromiseResolver> resolver, IntRect* cropRect) | |
|
do-not-use
2013/08/12 15:36:15
It is confusing to take an IntRect raw pointer in
| |
| 81 { | |
| 82 RefPtr<ImageBitmapLoader> imageBitmapLoader = adoptRef(new ImageBitm apLoader(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.
| |
| 83 return imageBitmapLoader.release(); | |
| 84 } | |
| 85 | |
| 86 void loadBlobAsync(ScriptExecutionContext*, Blob*); | |
| 87 | |
| 88 ~ImageBitmapLoader() { } | |
| 89 | |
| 90 private: | |
| 91 ImageBitmapLoader(ImageBitmapFactories*, PassRefPtr<ScriptPromiseResolve r>, IntRect*); | |
| 92 | |
| 93 void rejectPromise(); | |
| 94 | |
| 95 // FileReaderLoaderClient | |
| 96 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.
| |
| 97 virtual void didReceiveData() { } | |
| 98 virtual void didFinishLoading(); | |
| 99 virtual void didFail(FileError::ErrorCode); | |
| 100 | |
| 101 ScriptState* m_scriptState; | |
| 102 FileReaderLoader m_loader; | |
| 103 ImageBitmapFactories* m_factory; | |
| 104 RefPtr<ScriptPromiseResolver> m_resolver; | |
| 105 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
| |
| 106 }; | |
| 107 | |
| 108 HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders; | |
| 109 }; | |
| 110 | |
| 63 } // namespace WebCore | 111 } // namespace WebCore |
| 64 | 112 |
| 65 #endif // ImageBitmapFactories_h | 113 #endif // ImageBitmapFactories_h |
| OLD | NEW |