| Index: third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h
|
| diff --git a/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h b/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h
|
| index 0d183732ce06945914be4d6e39ce20e003e7b391..ebd4203c11f67a4e7fcf542d30a2f04a6a4f3595 100644
|
| --- a/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h
|
| +++ b/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h
|
| @@ -12,13 +12,26 @@
|
|
|
| namespace blink {
|
|
|
| +class Image;
|
| class ScriptState;
|
|
|
| +// Represents a javascript class registered on the PaintWorkletGlobalScope by
|
| +// the author.
|
| class CSSPaintDefinition final : public GarbageCollectedFinalized<CSSPaintDefinition> {
|
| public:
|
| static CSSPaintDefinition* create(ScriptState*, v8::Local<v8::Function> constructor, v8::Local<v8::Function> paint);
|
| virtual ~CSSPaintDefinition();
|
|
|
| + // Invokes the javascript 'paint' callback on an instance of the javascript
|
| + // class. The size given will be the size of the PaintRenderingContext2D
|
| + // given to the callback.
|
| + //
|
| + // This may return a nullptr (representing an invalid image) if javascript
|
| + // throws an error.
|
| + PassRefPtr<Image> paint(const IntSize&);
|
| +
|
| + ScriptState* getScriptState() const { return m_scriptState.get(); }
|
| +
|
| v8::Local<v8::Function> paintFunctionForTesting(v8::Isolate* isolate) { return m_paint.newLocal(isolate); }
|
|
|
| DEFINE_INLINE_TRACE() { };
|
| @@ -26,13 +39,22 @@ public:
|
| private:
|
| CSSPaintDefinition(ScriptState*, v8::Local<v8::Function> constructor, v8::Local<v8::Function> paint);
|
|
|
| + void maybeCreatePaintInstance();
|
| +
|
| RefPtr<ScriptState> m_scriptState;
|
|
|
| - // This object keeps the constructor and paint functions alive. This object
|
| - // needs to be destroyed to break a reference cycle between it and the
|
| - // PaintWorkletGlobalScope.
|
| + // This object keeps the class instance object, constructor function and
|
| + // paint function alive. This object needs to be destroyed to break a
|
| + // reference cycle between it and the PaintWorkletGlobalScope.
|
| ScopedPersistent<v8::Function> m_constructor;
|
| ScopedPersistent<v8::Function> m_paint;
|
| +
|
| + // At the moment there is only ever one instance of a paint class per type.
|
| + ScopedPersistent<v8::Object> m_instance;
|
| +
|
| + // True if the constructor of the class threw an error when we tried
|
| + // creating the javascript class. After this we don't retry creating.
|
| + bool m_invalidConstructor;
|
| };
|
|
|
| } // namespace blink
|
|
|