| Index: third_party/WebKit/Source/modules/compositorworker/Animator.cpp
|
| diff --git a/third_party/WebKit/Source/modules/compositorworker/Animator.cpp b/third_party/WebKit/Source/modules/compositorworker/Animator.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3c9e6f74e0be01b7a54999811908e64d7ae20b17
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/compositorworker/Animator.cpp
|
| @@ -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.
|
| +
|
| +#include "modules/compositorworker/Animator.h"
|
| +
|
| +#include "bindings/core/v8/V8ScriptRunner.h"
|
| +#include "core/dom/ExecutionContext.h"
|
| +#include "modules/compositorworker/AnimatorDefinition.h"
|
| +#include "platform/bindings/ScriptState.h"
|
| +#include "platform/bindings/V8Binding.h"
|
| +
|
| +namespace blink {
|
| +
|
| +Animator* Animator::Create(v8::Isolate* isolate,
|
| + AnimatorDefinition* definition,
|
| + v8::Local<v8::Object> instance) {
|
| + return new Animator(isolate, definition, instance);
|
| +}
|
| +
|
| +Animator::Animator(v8::Isolate* isolate,
|
| + AnimatorDefinition* definition,
|
| + v8::Local<v8::Object> instance)
|
| + : definition_(definition), instance_(isolate, instance) {}
|
| +
|
| +Animator::~Animator() {}
|
| +
|
| +DEFINE_TRACE(Animator) {
|
| + visitor->Trace(definition_);
|
| +}
|
| +
|
| +void Animator::Animate(ScriptState* script_state) const {
|
| + v8::Isolate* isolate = script_state->GetIsolate();
|
| +
|
| + v8::Local<v8::Object> instance = instance_.NewLocal(isolate);
|
| + v8::Local<v8::Function> animate = definition_->AnimateLocal(isolate);
|
| +
|
| + if (IsUndefinedOrNull(instance) || IsUndefinedOrNull(animate))
|
| + return;
|
| +
|
| + ScriptState::Scope scope(script_state);
|
| + v8::TryCatch block(isolate);
|
| + block.SetVerbose(true);
|
| +
|
| + V8ScriptRunner::CallFunction(animate, ExecutionContext::From(script_state),
|
| + instance, 0, nullptr, isolate);
|
| +
|
| + // The animate function may have produced an error!
|
| + // TODO(majidvp): We should probably just throw here.
|
| + if (block.HasCaught())
|
| + return;
|
| +}
|
| +
|
| +} // namespace blink
|
|
|