OLD | NEW |
(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/csspaint/PaintWorkletGlobalScopeProxy.h" |
| 6 |
| 7 #include "bindings/core/v8/ScriptSourceCode.h" |
| 8 #include "bindings/core/v8/V8BindingForCore.h" |
| 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/LocalFrame.h" |
| 11 #include "platform/weborigin/KURL.h" |
| 12 #include "platform/wtf/WTF.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 PaintWorkletGlobalScopeProxy* PaintWorkletGlobalScopeProxy::From( |
| 17 WorkletGlobalScopeProxy* proxy) { |
| 18 return static_cast<PaintWorkletGlobalScopeProxy*>(proxy); |
| 19 } |
| 20 |
| 21 PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy(LocalFrame* frame) { |
| 22 DCHECK(IsMainThread()); |
| 23 Document* document = frame->GetDocument(); |
| 24 global_scope_ = PaintWorkletGlobalScope::Create( |
| 25 frame, document->Url(), document->UserAgent(), |
| 26 document->GetSecurityOrigin(), ToIsolate(document)); |
| 27 } |
| 28 |
| 29 void PaintWorkletGlobalScopeProxy::FetchAndInvokeScript( |
| 30 const KURL& module_url_record, |
| 31 WorkletPendingTasks* pending_tasks) { |
| 32 DCHECK(IsMainThread()); |
| 33 global_scope_->FetchAndInvokeScript(module_url_record, pending_tasks); |
| 34 } |
| 35 |
| 36 void PaintWorkletGlobalScopeProxy::EvaluateScript( |
| 37 const ScriptSourceCode& script_source_code) { |
| 38 // This should be called only for threaded worklets that still use classic |
| 39 // script loading. |
| 40 NOTREACHED(); |
| 41 } |
| 42 |
| 43 void PaintWorkletGlobalScopeProxy::TerminateWorkletGlobalScope() { |
| 44 DCHECK(IsMainThread()); |
| 45 global_scope_->Terminate(); |
| 46 // Nullify the global scope to cut a potential reference cycle. |
| 47 global_scope_ = nullptr; |
| 48 } |
| 49 |
| 50 CSSPaintDefinition* PaintWorkletGlobalScopeProxy::FindDefinition( |
| 51 const String& name) { |
| 52 DCHECK(IsMainThread()); |
| 53 return global_scope_->FindDefinition(name); |
| 54 } |
| 55 |
| 56 void PaintWorkletGlobalScopeProxy::AddPendingGenerator( |
| 57 const String& name, |
| 58 CSSPaintImageGeneratorImpl* generator) { |
| 59 DCHECK(IsMainThread()); |
| 60 global_scope_->AddPendingGenerator(name, generator); |
| 61 } |
| 62 |
| 63 } // namespace blink |
OLD | NEW |