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

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h

Issue 2561773003: Parse input argument types and store the argument types in CSSPaintDefinition. (Closed)
Patch Set: update tests Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 CSSPaintDefinition_h 5 #ifndef CSSPaintDefinition_h
6 #define CSSPaintDefinition_h 6 #define CSSPaintDefinition_h
7 7
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "core/CSSPropertyNames.h" 9 #include "core/CSSPropertyNames.h"
10 #include "core/css/CSSSyntaxDescriptor.h"
10 #include "platform/geometry/IntSize.h" 11 #include "platform/geometry/IntSize.h"
11 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
12 #include <v8.h> 13 #include <v8.h>
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class Image; 17 class Image;
17 class LayoutObject; 18 class LayoutObject;
18 class ScriptState; 19 class ScriptState;
19 20
20 // Represents a javascript class registered on the PaintWorkletGlobalScope by 21 // Represents a javascript class registered on the PaintWorkletGlobalScope by
21 // the author. 22 // the author. It will store the properties for invalidation and input argument
23 // types as well.
22 class CSSPaintDefinition final 24 class CSSPaintDefinition final
23 : public GarbageCollectedFinalized<CSSPaintDefinition> { 25 : public GarbageCollectedFinalized<CSSPaintDefinition> {
24 public: 26 public:
25 static CSSPaintDefinition* create( 27 static CSSPaintDefinition* create(
26 ScriptState*, 28 ScriptState*,
27 v8::Local<v8::Function> constructor, 29 v8::Local<v8::Function> constructor,
28 v8::Local<v8::Function> paint, 30 v8::Local<v8::Function> paint,
29 Vector<CSSPropertyID>&, 31 Vector<CSSPropertyID>&,
30 Vector<AtomicString>& customInvalidationProperties, 32 Vector<AtomicString>& customInvalidationProperties,
33 Vector<CSSSyntaxDescriptor>& inputArgumentTypes,
31 bool hasAlpha); 34 bool hasAlpha);
32 virtual ~CSSPaintDefinition(); 35 virtual ~CSSPaintDefinition();
33 36
34 // Invokes the javascript 'paint' callback on an instance of the javascript 37 // Invokes the javascript 'paint' callback on an instance of the javascript
35 // class. The size given will be the size of the PaintRenderingContext2D 38 // class. The size given will be the size of the PaintRenderingContext2D
36 // given to the callback. 39 // given to the callback.
37 // 40 //
38 // This may return a nullptr (representing an invalid image) if javascript 41 // This may return a nullptr (representing an invalid image) if javascript
39 // throws an error. 42 // throws an error.
40 PassRefPtr<Image> paint(const LayoutObject&, const IntSize&, float zoom); 43 PassRefPtr<Image> paint(const LayoutObject&, const IntSize&, float zoom);
41 const Vector<CSSPropertyID>& nativeInvalidationProperties() const { 44 const Vector<CSSPropertyID>& nativeInvalidationProperties() const {
42 return m_nativeInvalidationProperties; 45 return m_nativeInvalidationProperties;
43 } 46 }
44 const Vector<AtomicString>& customInvalidationProperties() const { 47 const Vector<AtomicString>& customInvalidationProperties() const {
45 return m_customInvalidationProperties; 48 return m_customInvalidationProperties;
46 } 49 }
50 const Vector<CSSSyntaxDescriptor>& inputArgumentTypes() const {
51 return m_inputArgumentTypes;
52 }
47 bool hasAlpha() const { return m_hasAlpha; } 53 bool hasAlpha() const { return m_hasAlpha; }
48 54
49 ScriptState* getScriptState() const { return m_scriptState.get(); } 55 ScriptState* getScriptState() const { return m_scriptState.get(); }
50 56
51 v8::Local<v8::Function> paintFunctionForTesting(v8::Isolate* isolate) { 57 v8::Local<v8::Function> paintFunctionForTesting(v8::Isolate* isolate) {
52 return m_paint.newLocal(isolate); 58 return m_paint.newLocal(isolate);
53 } 59 }
54 60
55 DEFINE_INLINE_TRACE(){}; 61 DEFINE_INLINE_TRACE(){};
56 62
57 private: 63 private:
58 CSSPaintDefinition(ScriptState*, 64 CSSPaintDefinition(ScriptState*,
59 v8::Local<v8::Function> constructor, 65 v8::Local<v8::Function> constructor,
60 v8::Local<v8::Function> paint, 66 v8::Local<v8::Function> paint,
61 Vector<CSSPropertyID>& nativeInvalidationProperties, 67 Vector<CSSPropertyID>& nativeInvalidationProperties,
62 Vector<AtomicString>& customInvalidationProperties, 68 Vector<AtomicString>& customInvalidationProperties,
69 Vector<CSSSyntaxDescriptor>& inputArgumentTypes,
63 bool hasAlpha); 70 bool hasAlpha);
64 71
65 void maybeCreatePaintInstance(); 72 void maybeCreatePaintInstance();
66 73
67 RefPtr<ScriptState> m_scriptState; 74 RefPtr<ScriptState> m_scriptState;
68 75
69 // This object keeps the class instance object, constructor function and 76 // This object keeps the class instance object, constructor function and
70 // paint function alive. This object needs to be destroyed to break a 77 // paint function alive. This object needs to be destroyed to break a
71 // reference cycle between it and the PaintWorkletGlobalScope. 78 // reference cycle between it and the PaintWorkletGlobalScope.
72 ScopedPersistent<v8::Function> m_constructor; 79 ScopedPersistent<v8::Function> m_constructor;
73 ScopedPersistent<v8::Function> m_paint; 80 ScopedPersistent<v8::Function> m_paint;
74 81
75 // At the moment there is only ever one instance of a paint class per type. 82 // At the moment there is only ever one instance of a paint class per type.
76 ScopedPersistent<v8::Object> m_instance; 83 ScopedPersistent<v8::Object> m_instance;
77 84
78 bool m_didCallConstructor; 85 bool m_didCallConstructor;
79 86
80 Vector<CSSPropertyID> m_nativeInvalidationProperties; 87 Vector<CSSPropertyID> m_nativeInvalidationProperties;
81 Vector<AtomicString> m_customInvalidationProperties; 88 Vector<AtomicString> m_customInvalidationProperties;
89 // Input argument types, if applicable.
90 Vector<CSSSyntaxDescriptor> m_inputArgumentTypes;
82 bool m_hasAlpha; 91 bool m_hasAlpha;
83 }; 92 };
84 93
85 } // namespace blink 94 } // namespace blink
86 95
87 #endif // CSSPaintDefinition_h 96 #endif // CSSPaintDefinition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698