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

Side by Side Diff: third_party/WebKit/Source/modules/compositorworker/AnimatorDefinition.cpp

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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "modules/compositorworker/AnimatorDefinition.h"
6
7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8ObjectConstructor.h"
10 #include "core/dom/ExecutionContext.h"
11 #include "modules/compositorworker/Animator.h"
12
13 namespace blink {
14
15 AnimatorDefinition* AnimatorDefinition::create(
16 ScriptState* scriptState,
17 v8::Local<v8::Function> constructor,
18 v8::Local<v8::Function> animate) {
19 return new AnimatorDefinition(scriptState, constructor, animate);
flackr 2017/03/13 19:04:51 I think error checking the animate function on the
20 }
21
22 AnimatorDefinition::AnimatorDefinition(ScriptState* scriptState,
23 v8::Local<v8::Function> constructor,
24 v8::Local<v8::Function> animate)
25 : m_scriptState(scriptState),
26 m_constructor(scriptState->isolate(), constructor),
27 m_animate(scriptState->isolate(), animate) {}
28
29 AnimatorDefinition::~AnimatorDefinition() {}
30
31 Animator* AnimatorDefinition::createInstance() {
32 v8::Isolate* isolate = m_scriptState->isolate();
33 v8::Local<v8::Function> constructor = m_constructor.newLocal(isolate);
34 DCHECK(!isUndefinedOrNull(constructor));
35
36 v8::Local<v8::Object> instance;
37 if (!V8ObjectConstructor::newInstance(isolate, constructor)
38 .ToLocal(&instance)) {
39 instance = v8::Local<v8::Object>();
40 }
41
42 return Animator::create(m_scriptState.get(), this, instance);
43 }
44
45 void AnimatorDefinition::animate(v8::Local<v8::Object> animatorInstance) {
46 ScriptState::Scope scope(m_scriptState.get());
47
48 v8::Isolate* isolate = m_scriptState->isolate();
49
50 if (isUndefinedOrNull(animatorInstance))
51 return;
52
53 v8::Local<v8::Function> animate = m_animate.newLocal(isolate);
54
55 v8::TryCatch block(isolate);
56 block.SetVerbose(true);
57
58 V8ScriptRunner::callFunction(animate, m_scriptState->getExecutionContext(),
59 animatorInstance, 0, nullptr, isolate);
60
61 // The animate function may have produced an error!
62 if (block.HasCaught())
flackr 2017/03/13 19:04:51 Should we not be catching this error? Or logging i
63 return;
64 }
65
66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698