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&); | 31 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLImageElement*, const I ntRect&, Document*); |
32 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLVideoElement*, const I ntRect&); | 32 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLVideoElement*, const I ntRect&, Document*); |
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&); | |
37 static PassRefPtrWillBeRawPtr<ImageBitmap> create(PassRefPtr<StaticBitmapIma ge>); | 36 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_isOriginClean; } | |
45 PassRefPtr<StaticBitmapImage> transfer(); | 46 PassRefPtr<StaticBitmapImage> transfer(); |
46 | 47 |
47 ~ImageBitmap() override; | 48 ~ImageBitmap() override; |
48 | 49 |
49 // CanvasImageSource implementation | 50 // CanvasImageSource implementation |
50 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi nt) const override; | 51 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi nt) const override; |
51 bool wouldTaintOrigin(SecurityOrigin*) const override { return false; } | 52 bool wouldTaintOrigin(SecurityOrigin*) const override { return !m_isOriginCl ean; } |
52 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override; | 53 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override; |
53 FloatSize elementSize() const override; | 54 FloatSize elementSize() const override; |
54 | 55 |
55 // ImageBitmapSource implementation | 56 // ImageBitmapSource implementation |
56 IntSize bitmapSourceSize() const override { return size(); } | 57 IntSize bitmapSourceSize() const override { return size(); } |
57 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy, int sw, int sh, ExceptionState&) override; | 58 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy, int sw, int sh, ExceptionState&) override; |
58 | 59 |
59 DECLARE_VIRTUAL_TRACE(); | 60 DECLARE_VIRTUAL_TRACE(); |
60 | 61 |
61 private: | 62 private: |
62 ImageBitmap(HTMLImageElement*, const IntRect&); | 63 ImageBitmap(HTMLImageElement*, const IntRect&, Document*); |
63 ImageBitmap(HTMLVideoElement*, const IntRect&); | 64 ImageBitmap(HTMLVideoElement*, const IntRect&, Document*); |
64 ImageBitmap(HTMLCanvasElement*, const IntRect&); | 65 ImageBitmap(HTMLCanvasElement*, const IntRect&); |
65 ImageBitmap(ImageData*, const IntRect&); | 66 ImageBitmap(ImageData*, const IntRect&); |
66 ImageBitmap(ImageBitmap*, const IntRect&); | 67 ImageBitmap(ImageBitmap*, const IntRect&); |
67 ImageBitmap(Image*, const IntRect&); | |
68 ImageBitmap(PassRefPtr<StaticBitmapImage>); | 68 ImageBitmap(PassRefPtr<StaticBitmapImage>); |
69 ImageBitmap(PassRefPtr<StaticBitmapImage>, const IntRect&); | |
69 | 70 |
70 // ImageLoaderClient | 71 // ImageLoaderClient |
71 void notifyImageSourceChanged() override; | 72 void notifyImageSourceChanged() override; |
72 bool requestsHighLiveResourceCachePriority() override { return true; } | 73 bool requestsHighLiveResourceCachePriority() override { return true; } |
73 | 74 |
74 RefPtr<StaticBitmapImage> m_image; | 75 RefPtr<StaticBitmapImage> m_image; |
75 bool m_isNeutered = false; | 76 bool m_isNeutered = false; |
77 bool m_isOriginClean = true; | |
Justin Novosad
2016/01/08 22:09:39
Can we safely get rid of this and just always use
xidachen
2016/01/09 12:23:47
This makes perfect sense and it is not hard. Since
| |
76 }; | 78 }; |
77 | 79 |
78 } // namespace blink | 80 } // namespace blink |
79 | 81 |
80 #endif // ImageBitmap_h | 82 #endif // ImageBitmap_h |
OLD | NEW |