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

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

Issue 2903703003: Use wrapper tracing for worklets. (Closed)
Patch Set: Separating in two CLs Created 3 years, 6 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 "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/css/CSSSyntaxDescriptor.h" 9 #include "core/css/CSSSyntaxDescriptor.h"
10 #include "core/css/cssom/CSSStyleValue.h" 10 #include "core/css/cssom/CSSStyleValue.h"
11 #include "platform/bindings/ScopedPersistent.h" 11 #include "platform/bindings/ScriptWrappable.h"
12 #include "platform/bindings/TraceWrapperMember.h"
13 #include "platform/bindings/TraceWrapperV8Reference.h"
12 #include "platform/geometry/IntSize.h" 14 #include "platform/geometry/IntSize.h"
13 #include "platform/heap/Handle.h" 15 #include "platform/heap/Handle.h"
14 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
15 17
16 namespace blink { 18 namespace blink {
17 19
18 class Image; 20 class Image;
19 class LayoutObject; 21 class LayoutObject;
20 class ScriptState; 22 class ScriptState;
21 23
22 // Represents a javascript class registered on the PaintWorkletGlobalScope by 24 // Represents a javascript class registered on the PaintWorkletGlobalScope by
23 // the author. It will store the properties for invalidation and input argument 25 // the author. It will store the properties for invalidation and input argument
24 // types as well. 26 // types as well.
25 class CSSPaintDefinition final 27 class CSSPaintDefinition final
26 : public GarbageCollectedFinalized<CSSPaintDefinition> { 28 : public GarbageCollectedFinalized<CSSPaintDefinition>,
29 public TraceWrapperBase {
27 public: 30 public:
28 static CSSPaintDefinition* Create( 31 static CSSPaintDefinition* Create(
29 ScriptState*, 32 ScriptState*,
30 v8::Local<v8::Function> constructor, 33 v8::Local<v8::Function> constructor,
31 v8::Local<v8::Function> paint, 34 v8::Local<v8::Function> paint,
32 Vector<CSSPropertyID>&, 35 Vector<CSSPropertyID>&,
33 Vector<AtomicString>& custom_invalidation_properties, 36 Vector<AtomicString>& custom_invalidation_properties,
34 Vector<CSSSyntaxDescriptor>& input_argument_types, 37 Vector<CSSSyntaxDescriptor>& input_argument_types,
35 bool has_alpha); 38 bool has_alpha);
36 virtual ~CSSPaintDefinition(); 39 virtual ~CSSPaintDefinition();
(...skipping 18 matching lines...) Expand all
55 } 58 }
56 bool HasAlpha() const { return has_alpha_; } 59 bool HasAlpha() const { return has_alpha_; }
57 60
58 ScriptState* GetScriptState() const { return script_state_.Get(); } 61 ScriptState* GetScriptState() const { return script_state_.Get(); }
59 62
60 v8::Local<v8::Function> PaintFunctionForTesting(v8::Isolate* isolate) { 63 v8::Local<v8::Function> PaintFunctionForTesting(v8::Isolate* isolate) {
61 return paint_.NewLocal(isolate); 64 return paint_.NewLocal(isolate);
62 } 65 }
63 66
64 DEFINE_INLINE_TRACE(){}; 67 DEFINE_INLINE_TRACE(){};
68 DECLARE_TRACE_WRAPPERS();
65 69
66 private: 70 private:
67 CSSPaintDefinition(ScriptState*, 71 CSSPaintDefinition(ScriptState*,
68 v8::Local<v8::Function> constructor, 72 v8::Local<v8::Function> constructor,
69 v8::Local<v8::Function> paint, 73 v8::Local<v8::Function> paint,
70 Vector<CSSPropertyID>& native_invalidation_properties, 74 Vector<CSSPropertyID>& native_invalidation_properties,
71 Vector<AtomicString>& custom_invalidation_properties, 75 Vector<AtomicString>& custom_invalidation_properties,
72 Vector<CSSSyntaxDescriptor>& input_argument_types, 76 Vector<CSSSyntaxDescriptor>& input_argument_types,
73 bool has_alpha); 77 bool has_alpha);
74 78
75 void MaybeCreatePaintInstance(); 79 void MaybeCreatePaintInstance();
76 80
77 RefPtr<ScriptState> script_state_; 81 RefPtr<ScriptState> script_state_;
78 82
79 // This object keeps the class instance object, constructor function and 83 // This object keeps the class instance object, constructor function and
80 // paint function alive. This object needs to be destroyed to break a 84 // paint function alive. It participates in wrapper tracing as it holds onto
81 // reference cycle between it and the PaintWorkletGlobalScope. 85 // V8 wrappers.
82 ScopedPersistent<v8::Function> constructor_; 86 TraceWrapperV8Reference<v8::Function> constructor_;
83 ScopedPersistent<v8::Function> paint_; 87 TraceWrapperV8Reference<v8::Function> paint_;
84 88
85 // At the moment there is only ever one instance of a paint class per type. 89 // At the moment there is only ever one instance of a paint class per type.
86 ScopedPersistent<v8::Object> instance_; 90 TraceWrapperV8Reference<v8::Object> instance_;
87 91
88 bool did_call_constructor_; 92 bool did_call_constructor_;
89 93
90 Vector<CSSPropertyID> native_invalidation_properties_; 94 Vector<CSSPropertyID> native_invalidation_properties_;
91 Vector<AtomicString> custom_invalidation_properties_; 95 Vector<AtomicString> custom_invalidation_properties_;
92 // Input argument types, if applicable. 96 // Input argument types, if applicable.
93 Vector<CSSSyntaxDescriptor> input_argument_types_; 97 Vector<CSSSyntaxDescriptor> input_argument_types_;
94 bool has_alpha_; 98 bool has_alpha_;
95 }; 99 };
96 100
97 } // namespace blink 101 } // namespace blink
98 102
99 #endif // CSSPaintDefinition_h 103 #endif // CSSPaintDefinition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698