| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 AnimatorDefinition_h | 5 #ifndef AnimatorDefinition_h |
| 6 #define AnimatorDefinition_h | 6 #define AnimatorDefinition_h |
| 7 | 7 |
| 8 #include "platform/bindings/ScopedPersistent.h" | 8 #include "platform/bindings/ScriptWrappable.h" |
| 9 #include "platform/bindings/TraceWrapperV8Reference.h" |
| 9 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 10 #include "v8/include/v8.h" | 11 #include "v8/include/v8.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 // This class represents a valid registered Javascript animator. Note that it | 15 // This class represents a valid registered Javascript animator. Note that it |
| 15 // assumed the argument passed to its constructor have been validated to have | 16 // assumed the argument passed to its constructor have been validated to have |
| 16 // proper type. | 17 // proper type. |
| 17 // It can be used to instantiate new animators and also to call the Javascript | 18 // It can be used to instantiate new animators and also to call the Javascript |
| 18 // 'animate' callback on a given instance. | 19 // 'animate' callback on a given instance. |
| 19 class AnimatorDefinition final | 20 class AnimatorDefinition final |
| 20 : public GarbageCollectedFinalized<AnimatorDefinition> { | 21 : public GarbageCollectedFinalized<AnimatorDefinition>, |
| 22 public TraceWrapperBase { |
| 21 public: | 23 public: |
| 22 AnimatorDefinition(v8::Isolate*, | 24 AnimatorDefinition(v8::Isolate*, |
| 23 v8::Local<v8::Function> constructor, | 25 v8::Local<v8::Function> constructor, |
| 24 v8::Local<v8::Function> animate); | 26 v8::Local<v8::Function> animate); |
| 25 ~AnimatorDefinition(); | 27 ~AnimatorDefinition(); |
| 26 DEFINE_INLINE_TRACE() {} | 28 DEFINE_INLINE_TRACE() {} |
| 29 DECLARE_TRACE_WRAPPERS(); |
| 27 | 30 |
| 28 v8::Local<v8::Function> ConstructorLocal(v8::Isolate*); | 31 v8::Local<v8::Function> ConstructorLocal(v8::Isolate*); |
| 29 | 32 |
| 30 private: | 33 private: |
| 31 // This object keeps the constructor function, and animate function alive. | 34 // This object keeps the constructor function, and animate function alive. |
| 32 // It needs to be destroyed to break a reference cycle between it and the | 35 // It participates in wrapper tracing as it holds onto V8 wrappers. |
| 33 // AnimationWorkletGlobalScope. This cycle is broken in | 36 TraceWrapperV8Reference<v8::Function> constructor_; |
| 34 // |AnimationWorkletGlobalScope::Dispose()|. | 37 TraceWrapperV8Reference<v8::Function> animate_; |
| 35 ScopedPersistent<v8::Function> constructor_; | |
| 36 ScopedPersistent<v8::Function> animate_; | |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 } // namespace blink | 40 } // namespace blink |
| 40 | 41 |
| 41 #endif // AnimatorDefinition_h | 42 #endif // AnimatorDefinition_h |
| OLD | NEW |