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

Unified Diff: third_party/WebKit/Source/modules/compositorworker/AnimatorDefinition.h

Issue 2745823002: [animation-worklet] Implement registerAnimator in worklet scope (Closed)
Patch Set: remove empty array Created 3 years, 9 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/compositorworker/AnimatorDefinition.h
diff --git a/third_party/WebKit/Source/modules/compositorworker/AnimatorDefinition.h b/third_party/WebKit/Source/modules/compositorworker/AnimatorDefinition.h
new file mode 100644
index 0000000000000000000000000000000000000000..5a81491279d2cccfeb40f75442aa48d31a3ccd29
--- /dev/null
+++ b/third_party/WebKit/Source/modules/compositorworker/AnimatorDefinition.h
@@ -0,0 +1,54 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef AnimatorDefinition_h
+#define AnimatorDefinition_h
+
+#include "bindings/core/v8/ScopedPersistent.h"
+#include "platform/heap/Handle.h"
+#include "v8/include/v8.h"
+
+namespace blink {
+
+class ScriptState;
+class Animator;
+
+// This class represents a valid registered Javascript animator. Note that it
+// assumed the argument passed to its constructor have been validated to have
+// proper type.
+// It can be used to instantiate new animators and also to call the Javascript
+// 'animate' callback one a given instance.
+class AnimatorDefinition final
+ : public GarbageCollectedFinalized<AnimatorDefinition> {
+ public:
+ static AnimatorDefinition* create(ScriptState*,
+ v8::Local<v8::Function> constructor,
+ v8::Local<v8::Function> animate);
+
+ ~AnimatorDefinition();
+ DEFINE_INLINE_TRACE() {}
+
+ Animator* createInstance();
+
+ // Invoke the the Javascript 'animate' callback one the given instance.
flackr 2017/03/13 19:04:52 nit: s/one/on
majidvp 2017/03/13 22:07:54 removed.
+ // TODO(majidvp): should take a list of proxies
+ void animate(v8::Local<v8::Object> animatorInstance);
+
+ private:
+ AnimatorDefinition(ScriptState*,
+ v8::Local<v8::Function> constructor,
+ v8::Local<v8::Function> animate);
+
+ RefPtr<ScriptState> m_scriptState;
+
+ // This object keeps the constructor function, and animate function alive.
flackr 2017/03/13 19:04:52 Isn't the animate function kept alive through the
majidvp 2017/03/13 22:07:53 Mainly so it does not change. We can choose to loo
flackr 2017/03/14 18:30:29 Let's call out in the comment that we keep the ori
+ // It needs to be destroyed to break a reference cycle between it and the
+ // AnimationWorkletGlobalScope.
+ ScopedPersistent<v8::Function> m_constructor;
+ ScopedPersistent<v8::Function> m_animate;
+};
+
+} // namespace blink
+
+#endif // AnimatorDefinition_h

Powered by Google App Engine
This is Rietveld 408576698