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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 class CanvasRenderingContext2D; | 47 class CanvasRenderingContext2D; |
| 48 class EventTarget; | 48 class EventTarget; |
| 49 class ExceptionState; | 49 class ExceptionState; |
| 50 class HTMLCanvasElement; | 50 class HTMLCanvasElement; |
| 51 class HTMLImageElement; | 51 class HTMLImageElement; |
| 52 class HTMLVideoElement; | 52 class HTMLVideoElement; |
| 53 class ImageBitmap; | 53 class ImageBitmap; |
| 54 class ImageData; | 54 class ImageData; |
| 55 class ExecutionContext; | 55 class ExecutionContext; |
| 56 | 56 |
| 57 class ImageBitmapFactories : public Supplement<DOMWindow> { | 57 class ImageBitmapFactories FINAL : public NoBaseWillBeGarbageCollectedFinalized< ImageBitmapFactories>, public WillBeHeapSupplement<DOMWindow>, public WillBeHeap Supplement<WorkerGlobalScope> { |
|
haraken
2014/03/27 00:59:03
Ditto.
sof
2014/03/27 07:25:51
No, we need to release the HashSet on finalization
| |
| 58 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmapFactories); | |
| 58 | 59 |
| 60 private: | |
| 59 class ImageBitmapLoader; | 61 class ImageBitmapLoader; |
|
haraken
2014/03/27 00:59:03
Nit: I think you can just move this to the above l
sof
2014/03/27 07:25:51
It's a local class. But the forward decl is avoida
| |
| 60 | 62 |
| 61 public: | 63 public: |
| 62 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, Exce ptionState&); | 64 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, Exce ptionState&); |
| 63 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, int sx, int sy, int sw, int sh, ExceptionState&); | 65 static ScriptPromise createImageBitmap(EventTarget&, HTMLImageElement*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 64 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, Exce ptionState&); | 66 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, Exce ptionState&); |
| 65 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, int sx, int sy, int sw, int sh, ExceptionState&); | 67 static ScriptPromise createImageBitmap(EventTarget&, HTMLVideoElement*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 66 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2 D*, ExceptionState&); | 68 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2 D*, ExceptionState&); |
| 67 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2 D*, int sx, int sy, int sw, int sh, ExceptionState&); | 69 static ScriptPromise createImageBitmap(EventTarget&, CanvasRenderingContext2 D*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 68 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, Exc eptionState&); | 70 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, Exc eptionState&); |
| 69 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, int sx, int sy, int sw, int sh, ExceptionState&); | 71 static ScriptPromise createImageBitmap(EventTarget&, HTMLCanvasElement*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 70 static ScriptPromise createImageBitmap(EventTarget&, Blob*, ExceptionState&) ; | 72 static ScriptPromise createImageBitmap(EventTarget&, Blob*, ExceptionState&) ; |
| 71 static ScriptPromise createImageBitmap(EventTarget&, Blob*, int sx, int sy, int sw, int sh, ExceptionState&); | 73 static ScriptPromise createImageBitmap(EventTarget&, Blob*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 72 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, ExceptionSt ate&); | 74 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, ExceptionSt ate&); |
| 73 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, int sx, int sy, int sw, int sh, ExceptionState&); | 75 static ScriptPromise createImageBitmap(EventTarget&, ImageData*, int sx, int sy, int sw, int sh, ExceptionState&); |
| 74 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, Exception State&); | 76 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, Exception State&); |
| 75 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, int sx, i nt sy, int sw, int sh, ExceptionState&); | 77 static ScriptPromise createImageBitmap(EventTarget&, ImageBitmap*, int sx, i nt sy, int sw, int sh, ExceptionState&); |
| 76 | 78 |
| 77 void didFinishLoading(ImageBitmapLoader*); | 79 void didFinishLoading(ImageBitmapLoader*); |
| 80 virtual ~ImageBitmapFactories() { } | |
| 78 | 81 |
| 79 virtual ~ImageBitmapFactories() { } | 82 void trace(Visitor*) { } |
| 80 | 83 |
| 81 protected: | 84 protected: |
| 82 static const char* supplementName(); | 85 static const char* supplementName(); |
| 83 | 86 |
| 84 private: | 87 private: |
| 85 class ImageBitmapLoader FINAL : public RefCounted<ImageBitmapLoader>, public FileReaderLoaderClient { | 88 class ImageBitmapLoader FINAL : public RefCounted<ImageBitmapLoader>, public FileReaderLoaderClient { |
| 86 public: | 89 public: |
| 87 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories& factor y, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) | 90 static PassRefPtr<ImageBitmapLoader> create(ImageBitmapFactories& factor y, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) |
| 88 { | 91 { |
| 89 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); | 92 return adoptRef(new ImageBitmapLoader(factory, resolver, cropRect)); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 106 | 109 |
| 107 ScriptState* m_scriptState; | 110 ScriptState* m_scriptState; |
| 108 FileReaderLoader m_loader; | 111 FileReaderLoader m_loader; |
| 109 ImageBitmapFactories* m_factory; | 112 ImageBitmapFactories* m_factory; |
| 110 RefPtr<ScriptPromiseResolver> m_resolver; | 113 RefPtr<ScriptPromiseResolver> m_resolver; |
| 111 IntRect m_cropRect; | 114 IntRect m_cropRect; |
| 112 }; | 115 }; |
| 113 | 116 |
| 114 static ImageBitmapFactories& from(EventTarget&); | 117 static ImageBitmapFactories& from(EventTarget&); |
| 115 | 118 |
| 116 static ImageBitmapFactories& fromInternal(DOMWindow&); | 119 template<class GlobalObject> |
| 120 static ImageBitmapFactories& fromInternal(GlobalObject&); | |
| 117 | 121 |
| 118 void addLoader(PassRefPtr<ImageBitmapLoader>); | 122 void addLoader(PassRefPtr<ImageBitmapLoader>); |
| 119 | 123 |
| 120 HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders; | 124 HashSet<RefPtr<ImageBitmapLoader> > m_pendingLoaders; |
| 121 }; | 125 }; |
| 122 | 126 |
| 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 | |
| 136 } // namespace WebCore | 127 } // namespace WebCore |
| 137 | 128 |
| 138 #endif // ImageBitmapFactories_h | 129 #endif // ImageBitmapFactories_h |
| OLD | NEW |