| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/csspaint/PaintWorkletGlobalScope.h" | 5 #include "modules/csspaint/PaintWorkletGlobalScope.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8BindingMacros.h" | 7 #include "bindings/core/v8/V8BindingMacros.h" |
| 8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 9 #include "core/CSSPropertyNames.h" | 9 #include "core/CSSPropertyNames.h" |
| 10 #include "core/css/CSSSyntaxDescriptor.h" | 10 #include "core/css/CSSSyntaxDescriptor.h" |
| 11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
| 12 #include "core/inspector/MainThreadDebugger.h" | 12 #include "core/inspector/MainThreadDebugger.h" |
| 13 #include "modules/csspaint/CSSPaintDefinition.h" | 13 #include "modules/csspaint/CSSPaintDefinition.h" |
| 14 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" | 14 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 PaintWorkletGlobalScope* PaintWorkletGlobalScope::Create( | 19 PaintWorkletGlobalScope* PaintWorkletGlobalScope::Create( |
| 20 LocalFrame* frame, | 20 LocalFrame* frame, |
| 21 const KURL& url, | 21 const KURL& url, |
| 22 const String& user_agent, | 22 const String& user_agent, |
| 23 PassRefPtr<SecurityOrigin> security_origin, | 23 PassRefPtr<SecurityOrigin> security_origin, |
| 24 v8::Isolate* isolate) { | 24 v8::Isolate* isolate, |
| 25 WorkletObjectProxy* object_proxy) { |
| 25 PaintWorkletGlobalScope* paint_worklet_global_scope = | 26 PaintWorkletGlobalScope* paint_worklet_global_scope = |
| 26 new PaintWorkletGlobalScope(frame, url, user_agent, | 27 new PaintWorkletGlobalScope(frame, url, user_agent, |
| 27 std::move(security_origin), isolate); | 28 std::move(security_origin), isolate, |
| 29 object_proxy); |
| 28 paint_worklet_global_scope->ScriptController()->InitializeContextIfNeeded(); | 30 paint_worklet_global_scope->ScriptController()->InitializeContextIfNeeded(); |
| 29 MainThreadDebugger::Instance()->ContextCreated( | 31 MainThreadDebugger::Instance()->ContextCreated( |
| 30 paint_worklet_global_scope->ScriptController()->GetScriptState(), | 32 paint_worklet_global_scope->ScriptController()->GetScriptState(), |
| 31 paint_worklet_global_scope->GetFrame(), | 33 paint_worklet_global_scope->GetFrame(), |
| 32 paint_worklet_global_scope->GetSecurityOrigin()); | 34 paint_worklet_global_scope->GetSecurityOrigin()); |
| 33 return paint_worklet_global_scope; | 35 return paint_worklet_global_scope; |
| 34 } | 36 } |
| 35 | 37 |
| 36 PaintWorkletGlobalScope::PaintWorkletGlobalScope( | 38 PaintWorkletGlobalScope::PaintWorkletGlobalScope( |
| 37 LocalFrame* frame, | 39 LocalFrame* frame, |
| 38 const KURL& url, | 40 const KURL& url, |
| 39 const String& user_agent, | 41 const String& user_agent, |
| 40 PassRefPtr<SecurityOrigin> security_origin, | 42 PassRefPtr<SecurityOrigin> security_origin, |
| 41 v8::Isolate* isolate) | 43 v8::Isolate* isolate, |
| 44 WorkletObjectProxy* object_proxy) |
| 42 : MainThreadWorkletGlobalScope(frame, | 45 : MainThreadWorkletGlobalScope(frame, |
| 43 url, | 46 url, |
| 44 user_agent, | 47 user_agent, |
| 45 std::move(security_origin), | 48 std::move(security_origin), |
| 46 isolate) {} | 49 isolate, |
| 50 object_proxy) {} |
| 47 | 51 |
| 48 PaintWorkletGlobalScope::~PaintWorkletGlobalScope() {} | 52 PaintWorkletGlobalScope::~PaintWorkletGlobalScope() {} |
| 49 | 53 |
| 50 void PaintWorkletGlobalScope::Dispose() { | 54 void PaintWorkletGlobalScope::Dispose() { |
| 51 MainThreadDebugger::Instance()->ContextWillBeDestroyed( | 55 MainThreadDebugger::Instance()->ContextWillBeDestroyed( |
| 52 ScriptController()->GetScriptState()); | 56 ScriptController()->GetScriptState()); |
| 53 // Explicitly clear the paint defininitions to break a reference cycle | 57 // Explicitly clear the paint defininitions to break a reference cycle |
| 54 // between them and this global scope. | 58 // between them and this global scope. |
| 55 paint_definitions_.Clear(); | 59 paint_definitions_.Clear(); |
| 56 | 60 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 set->insert(generator); | 220 set->insert(generator); |
| 217 } | 221 } |
| 218 | 222 |
| 219 DEFINE_TRACE(PaintWorkletGlobalScope) { | 223 DEFINE_TRACE(PaintWorkletGlobalScope) { |
| 220 visitor->Trace(paint_definitions_); | 224 visitor->Trace(paint_definitions_); |
| 221 visitor->Trace(pending_generators_); | 225 visitor->Trace(pending_generators_); |
| 222 MainThreadWorkletGlobalScope::Trace(visitor); | 226 MainThreadWorkletGlobalScope::Trace(visitor); |
| 223 } | 227 } |
| 224 | 228 |
| 225 } // namespace blink | 229 } // namespace blink |
| OLD | NEW |