| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CSSPaintImageGenerator_h | 5 #ifndef CSSPaintImageGenerator_h |
| 6 #define CSSPaintImageGenerator_h | 6 #define CSSPaintImageGenerator_h |
| 7 | 7 |
| 8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/css/cssom/CSSStyleValue.h" | 10 #include "core/css/cssom/CSSStyleValue.h" |
| 11 #include "platform/geometry/IntSize.h" | 11 #include "platform/geometry/IntSize.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class CSSSyntaxDescriptor; | 16 class CSSSyntaxDescriptor; |
| 17 class Document; | 17 class Document; |
| 18 class Image; | 18 class Image; |
| 19 class LayoutObject; | 19 class ImageResourceObserver; |
| 20 | 20 |
| 21 // Produces a PaintGeneratedImage from a CSS Paint API callback. | 21 // Produces a PaintGeneratedImage from a CSS Paint API callback. |
| 22 // https://drafts.css-houdini.org/css-paint-api/ | 22 // https://drafts.css-houdini.org/css-paint-api/ |
| 23 class CORE_EXPORT CSSPaintImageGenerator | 23 class CORE_EXPORT CSSPaintImageGenerator |
| 24 : public GarbageCollectedFinalized<CSSPaintImageGenerator> { | 24 : public GarbageCollectedFinalized<CSSPaintImageGenerator> { |
| 25 public: | 25 public: |
| 26 // This observer is used if the paint worklet doesn't have a javascript | 26 // This observer is used if the paint worklet doesn't have a javascript |
| 27 // class registered with the correct name yet. | 27 // class registered with the correct name yet. |
| 28 // paintImageGeneratorReady is called when the javascript class is | 28 // paintImageGeneratorReady is called when the javascript class is |
| 29 // registered and ready to use. | 29 // registered and ready to use. |
| 30 class Observer : public GarbageCollectedFinalized<Observer> { | 30 class Observer : public GarbageCollectedFinalized<Observer> { |
| 31 public: | 31 public: |
| 32 virtual ~Observer(){}; | 32 virtual ~Observer(){}; |
| 33 virtual void PaintImageGeneratorReady() = 0; | 33 virtual void PaintImageGeneratorReady() = 0; |
| 34 DEFINE_INLINE_VIRTUAL_TRACE() {} | 34 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 static CSSPaintImageGenerator* Create(const String& name, | 37 static CSSPaintImageGenerator* Create(const String& name, |
| 38 Document&, | 38 const Document&, |
| 39 Observer*); | 39 Observer*); |
| 40 virtual ~CSSPaintImageGenerator(); | 40 virtual ~CSSPaintImageGenerator(); |
| 41 | 41 |
| 42 typedef CSSPaintImageGenerator* (*CSSPaintImageGeneratorCreateFunction)( | 42 typedef CSSPaintImageGenerator* (*CSSPaintImageGeneratorCreateFunction)( |
| 43 const String&, | 43 const String&, |
| 44 Document&, | 44 const Document&, |
| 45 Observer*); | 45 Observer*); |
| 46 static void Init(CSSPaintImageGeneratorCreateFunction); | 46 static void Init(CSSPaintImageGeneratorCreateFunction); |
| 47 | 47 |
| 48 // Invokes the CSS Paint API 'paint' callback. May return a nullptr | 48 // Invokes the CSS Paint API 'paint' callback. May return a nullptr |
| 49 // representing an invalid image if an error occurred. | 49 // representing an invalid image if an error occurred. |
| 50 virtual PassRefPtr<Image> Paint(const LayoutObject&, | 50 virtual PassRefPtr<Image> Paint(const ImageResourceObserver&, |
| 51 const IntSize&, | 51 const IntSize&, |
| 52 const CSSStyleValueVector*) = 0; | 52 const CSSStyleValueVector*) = 0; |
| 53 | 53 |
| 54 virtual const Vector<CSSPropertyID>& NativeInvalidationProperties() const = 0; | 54 virtual const Vector<CSSPropertyID>& NativeInvalidationProperties() const = 0; |
| 55 virtual const Vector<AtomicString>& CustomInvalidationProperties() const = 0; | 55 virtual const Vector<AtomicString>& CustomInvalidationProperties() const = 0; |
| 56 virtual bool HasAlpha() const = 0; | 56 virtual bool HasAlpha() const = 0; |
| 57 virtual const Vector<CSSSyntaxDescriptor>& InputArgumentTypes() const = 0; | 57 virtual const Vector<CSSSyntaxDescriptor>& InputArgumentTypes() const = 0; |
| 58 virtual bool IsImageGeneratorReady() const = 0; | 58 virtual bool IsImageGeneratorReady() const = 0; |
| 59 | 59 |
| 60 DEFINE_INLINE_VIRTUAL_TRACE() {} | 60 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| 64 | 64 |
| 65 #endif // CSSPaintImageGenerator_h | 65 #endif // CSSPaintImageGenerator_h |
| OLD | NEW |