Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h

Issue 1866623002: Hook up CSSPaintValue::image to CSS Paint API callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments + rebase. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..a7290e47adc56a38436ae6e8ab1ecd3e5981107e 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,20 @@ 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;
+
+ bool m_didCallConstructor;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698