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

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: space 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.
ikilpatrick 2017/01/18 01:32:32 If you like this comment could be expanded now tha
22 class CSSPaintDefinition final 23 class CSSPaintDefinition final
23 : public GarbageCollectedFinalized<CSSPaintDefinition> { 24 : public GarbageCollectedFinalized<CSSPaintDefinition> {
24 public: 25 public:
25 static CSSPaintDefinition* create( 26 static CSSPaintDefinition* create(
26 ScriptState*, 27 ScriptState*,
27 v8::Local<v8::Function> constructor, 28 v8::Local<v8::Function> constructor,
28 v8::Local<v8::Function> paint, 29 v8::Local<v8::Function> paint,
29 Vector<CSSPropertyID>&, 30 Vector<CSSPropertyID>&,
30 Vector<AtomicString>& customInvalidationProperties, 31 Vector<AtomicString>& customInvalidationProperties,
32 Vector<CSSSyntaxDescriptor>& inputArgumentTypes,
31 bool hasAlpha); 33 bool hasAlpha);
32 virtual ~CSSPaintDefinition(); 34 virtual ~CSSPaintDefinition();
33 35
34 // Invokes the javascript 'paint' callback on an instance of the javascript 36 // Invokes the javascript 'paint' callback on an instance of the javascript
35 // class. The size given will be the size of the PaintRenderingContext2D 37 // class. The size given will be the size of the PaintRenderingContext2D
36 // given to the callback. 38 // given to the callback.
37 // 39 //
38 // This may return a nullptr (representing an invalid image) if javascript 40 // This may return a nullptr (representing an invalid image) if javascript
39 // throws an error. 41 // throws an error.
40 PassRefPtr<Image> paint(const LayoutObject&, const IntSize&, float zoom); 42 PassRefPtr<Image> paint(const LayoutObject&, const IntSize&, float zoom);
41 const Vector<CSSPropertyID>& nativeInvalidationProperties() const { 43 const Vector<CSSPropertyID>& nativeInvalidationProperties() const {
42 return m_nativeInvalidationProperties; 44 return m_nativeInvalidationProperties;
43 } 45 }
44 const Vector<AtomicString>& customInvalidationProperties() const { 46 const Vector<AtomicString>& customInvalidationProperties() const {
45 return m_customInvalidationProperties; 47 return m_customInvalidationProperties;
46 } 48 }
49 const Vector<CSSSyntaxDescriptor>& inputArgumentTypes() const {
50 return m_inputArgumentTypes;
51 }
47 bool hasAlpha() const { return m_hasAlpha; } 52 bool hasAlpha() const { return m_hasAlpha; }
48 53
49 ScriptState* getScriptState() const { return m_scriptState.get(); } 54 ScriptState* getScriptState() const { return m_scriptState.get(); }
50 55
51 v8::Local<v8::Function> paintFunctionForTesting(v8::Isolate* isolate) { 56 v8::Local<v8::Function> paintFunctionForTesting(v8::Isolate* isolate) {
52 return m_paint.newLocal(isolate); 57 return m_paint.newLocal(isolate);
53 } 58 }
54 59
55 DEFINE_INLINE_TRACE(){}; 60 DEFINE_INLINE_TRACE(){};
56 61
57 private: 62 private:
58 CSSPaintDefinition(ScriptState*, 63 CSSPaintDefinition(ScriptState*,
59 v8::Local<v8::Function> constructor, 64 v8::Local<v8::Function> constructor,
60 v8::Local<v8::Function> paint, 65 v8::Local<v8::Function> paint,
61 Vector<CSSPropertyID>& nativeInvalidationProperties, 66 Vector<CSSPropertyID>& nativeInvalidationProperties,
62 Vector<AtomicString>& customInvalidationProperties, 67 Vector<AtomicString>& customInvalidationProperties,
68 Vector<CSSSyntaxDescriptor>& inputArgumentTypes,
63 bool hasAlpha); 69 bool hasAlpha);
64 70
65 void maybeCreatePaintInstance(); 71 void maybeCreatePaintInstance();
66 72
67 RefPtr<ScriptState> m_scriptState; 73 RefPtr<ScriptState> m_scriptState;
68 74
69 // This object keeps the class instance object, constructor function and 75 // This object keeps the class instance object, constructor function and
70 // paint function alive. This object needs to be destroyed to break a 76 // paint function alive. This object needs to be destroyed to break a
71 // reference cycle between it and the PaintWorkletGlobalScope. 77 // reference cycle between it and the PaintWorkletGlobalScope.
72 ScopedPersistent<v8::Function> m_constructor; 78 ScopedPersistent<v8::Function> m_constructor;
73 ScopedPersistent<v8::Function> m_paint; 79 ScopedPersistent<v8::Function> m_paint;
74 80
75 // At the moment there is only ever one instance of a paint class per type. 81 // At the moment there is only ever one instance of a paint class per type.
76 ScopedPersistent<v8::Object> m_instance; 82 ScopedPersistent<v8::Object> m_instance;
77 83
78 bool m_didCallConstructor; 84 bool m_didCallConstructor;
79 85
80 Vector<CSSPropertyID> m_nativeInvalidationProperties; 86 Vector<CSSPropertyID> m_nativeInvalidationProperties;
81 Vector<AtomicString> m_customInvalidationProperties; 87 Vector<AtomicString> m_customInvalidationProperties;
88 // Input argument types, if applicable.
89 Vector<CSSSyntaxDescriptor> m_inputArgumentTypes;
82 bool m_hasAlpha; 90 bool m_hasAlpha;
83 }; 91 };
84 92
85 } // namespace blink 93 } // namespace blink
86 94
87 #endif // CSSPaintDefinition_h 95 #endif // CSSPaintDefinition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698