| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ImageBitmap_h | 5 #ifndef ImageBitmap_h |
| 6 #define ImageBitmap_h | 6 #define ImageBitmap_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 class HTMLCanvasElement; | 23 class HTMLCanvasElement; |
| 24 class HTMLVideoElement; | 24 class HTMLVideoElement; |
| 25 class ImageData; | 25 class ImageData; |
| 26 | 26 |
| 27 class CORE_EXPORT ImageBitmap final : public RefCountedWillBeGarbageCollectedFin
alized<ImageBitmap>, public ScriptWrappable, public ImageLoaderClient, public Ca
nvasImageSource, public ImageBitmapSource { | 27 class CORE_EXPORT ImageBitmap final : public RefCountedWillBeGarbageCollectedFin
alized<ImageBitmap>, public ScriptWrappable, public ImageLoaderClient, public Ca
nvasImageSource, public ImageBitmapSource { |
| 28 DEFINE_WRAPPERTYPEINFO(); | 28 DEFINE_WRAPPERTYPEINFO(); |
| 29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmap); | 29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmap); |
| 30 public: | 30 public: |
| 31 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLImageElement*, const I
ntRect&, Document*); | 31 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLImageElement*, const I
ntRect&); |
| 32 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLVideoElement*, const I
ntRect&, Document*); | 32 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLVideoElement*, const I
ntRect&); |
| 33 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLCanvasElement*, const
IntRect&); | 33 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLCanvasElement*, const
IntRect&); |
| 34 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageData*, const IntRect&
); | 34 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageData*, const IntRect&
); |
| 35 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageBitmap*, const IntRec
t&); | 35 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageBitmap*, const IntRec
t&); |
| 36 static PassRefPtrWillBeRawPtr<ImageBitmap> create(Image*, const IntRect&); |
| 36 static PassRefPtrWillBeRawPtr<ImageBitmap> create(PassRefPtr<StaticBitmapIma
ge>); | 37 static PassRefPtrWillBeRawPtr<ImageBitmap> create(PassRefPtr<StaticBitmapIma
ge>); |
| 37 static PassRefPtrWillBeRawPtr<ImageBitmap> create(PassRefPtr<StaticBitmapIma
ge>, const IntRect&); | |
| 38 | 38 |
| 39 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } | 39 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } |
| 40 unsigned long width() const; | 40 unsigned long width() const; |
| 41 unsigned long height() const; | 41 unsigned long height() const; |
| 42 IntSize size() const; | 42 IntSize size() const; |
| 43 | 43 |
| 44 bool isNeutered() const { return m_isNeutered; } | 44 bool isNeutered() const { return m_isNeutered; } |
| 45 bool originClean() const { return m_image->originClean(); } | |
| 46 PassRefPtr<StaticBitmapImage> transfer(); | 45 PassRefPtr<StaticBitmapImage> transfer(); |
| 47 | 46 |
| 48 ~ImageBitmap() override; | 47 ~ImageBitmap() override; |
| 49 | 48 |
| 50 // CanvasImageSource implementation | 49 // CanvasImageSource implementation |
| 51 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi
nt) const override; | 50 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi
nt) const override; |
| 52 bool wouldTaintOrigin(SecurityOrigin*) const override { return !m_image->ori
ginClean(); } | 51 bool wouldTaintOrigin(SecurityOrigin*) const override { return false; } |
| 53 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override; | 52 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override; |
| 54 FloatSize elementSize() const override; | 53 FloatSize elementSize() const override; |
| 55 | 54 |
| 56 // ImageBitmapSource implementation | 55 // ImageBitmapSource implementation |
| 57 IntSize bitmapSourceSize() const override { return size(); } | 56 IntSize bitmapSourceSize() const override { return size(); } |
| 58 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy,
int sw, int sh, ExceptionState&) override; | 57 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy,
int sw, int sh, ExceptionState&) override; |
| 59 | 58 |
| 60 DECLARE_VIRTUAL_TRACE(); | 59 DECLARE_VIRTUAL_TRACE(); |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 ImageBitmap(HTMLImageElement*, const IntRect&, Document*); | 62 ImageBitmap(HTMLImageElement*, const IntRect&); |
| 64 ImageBitmap(HTMLVideoElement*, const IntRect&, Document*); | 63 ImageBitmap(HTMLVideoElement*, const IntRect&); |
| 65 ImageBitmap(HTMLCanvasElement*, const IntRect&); | 64 ImageBitmap(HTMLCanvasElement*, const IntRect&); |
| 66 ImageBitmap(ImageData*, const IntRect&); | 65 ImageBitmap(ImageData*, const IntRect&); |
| 67 ImageBitmap(ImageBitmap*, const IntRect&); | 66 ImageBitmap(ImageBitmap*, const IntRect&); |
| 67 ImageBitmap(Image*, const IntRect&); |
| 68 ImageBitmap(PassRefPtr<StaticBitmapImage>); | 68 ImageBitmap(PassRefPtr<StaticBitmapImage>); |
| 69 ImageBitmap(PassRefPtr<StaticBitmapImage>, const IntRect&); | |
| 70 | 69 |
| 71 // ImageLoaderClient | 70 // ImageLoaderClient |
| 72 void notifyImageSourceChanged() override; | 71 void notifyImageSourceChanged() override; |
| 73 bool requestsHighLiveResourceCachePriority() override { return true; } | 72 bool requestsHighLiveResourceCachePriority() override { return true; } |
| 74 | 73 |
| 75 RefPtr<StaticBitmapImage> m_image; | 74 RefPtr<StaticBitmapImage> m_image; |
| 76 bool m_isNeutered = false; | 75 bool m_isNeutered = false; |
| 77 }; | 76 }; |
| 78 | 77 |
| 79 } // namespace blink | 78 } // namespace blink |
| 80 | 79 |
| 81 #endif // ImageBitmap_h | 80 #endif // ImageBitmap_h |
| OLD | NEW |