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

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

Issue 2894233002: [animation-worklet] invoke animate callback on mutation signal (Closed)
Patch Set: Created 3 years, 7 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/Animator.h"
6
7 #include "bindings/core/v8/V8ScriptRunner.h"
8 #include "core/dom/ExecutionContext.h"
9 #include "modules/compositorworker/AnimatorDefinition.h"
10 #include "platform/bindings/ScriptState.h"
11 #include "platform/bindings/V8Binding.h"
12
13 namespace blink {
14
15 Animator* Animator::Create(v8::Isolate* isolate,
16 AnimatorDefinition* definition,
17 v8::Local<v8::Object> instance) {
18 return new Animator(isolate, definition, instance);
19 }
20
21 Animator::Animator(v8::Isolate* isolate,
22 AnimatorDefinition* definition,
23 v8::Local<v8::Object> instance)
24 : definition_(definition), instance_(isolate, instance) {}
25
26 Animator::~Animator() {}
27
28 DEFINE_TRACE(Animator) {
29 visitor->Trace(definition_);
30 }
31
32 void Animator::Animate(ScriptState* script_state) const {
33 v8::Isolate* isolate = script_state->GetIsolate();
34
35 v8::Local<v8::Object> instance = instance_.NewLocal(isolate);
36 v8::Local<v8::Function> animate = definition_->AnimateLocal(isolate);
37
38 if (IsUndefinedOrNull(instance) || IsUndefinedOrNull(animate))
39 return;
40
41 ScriptState::Scope scope(script_state);
42 v8::TryCatch block(isolate);
43 block.SetVerbose(true);
44
45 V8ScriptRunner::CallFunction(animate, ExecutionContext::From(script_state),
46 instance, 0, nullptr, isolate);
47
48 // The animate function may have produced an error!
49 // TODO(majidvp): We should probably just throw here.
50 if (block.HasCaught())
51 return;
52 }
53
54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698