diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h')
-rw-r--r-- | chromium/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/chromium/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h b/chromium/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h index 6bd200d8dde..958840fc5a2 100644 --- a/chromium/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h +++ b/chromium/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h @@ -11,6 +11,7 @@ #include "third_party/blink/renderer/modules/csspaint/paint_worklet_pending_generator_registry.h" #include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -23,12 +24,25 @@ class MODULES_EXPORT PaintWorkletGlobalScope final : public WorkletGlobalScope { USING_GARBAGE_COLLECTED_MIXIN(PaintWorkletGlobalScope); public: + // Creates a main-thread bound PaintWorkletGlobalScope. static PaintWorkletGlobalScope* Create( LocalFrame*, std::unique_ptr<GlobalScopeCreationParams>, WorkerReportingProxy&, PaintWorkletPendingGeneratorRegistry*, size_t global_scope_number); + + // Creates an worklet-thread bound PaintWorkletGlobalScope. + static PaintWorkletGlobalScope* Create( + std::unique_ptr<GlobalScopeCreationParams>, + WorkerThread*); + + PaintWorkletGlobalScope(LocalFrame*, + std::unique_ptr<GlobalScopeCreationParams>, + WorkerReportingProxy&, + PaintWorkletPendingGeneratorRegistry*); + PaintWorkletGlobalScope(std::unique_ptr<GlobalScopeCreationParams>, + WorkerThread*); ~PaintWorkletGlobalScope() override; void Dispose() final; @@ -43,10 +57,9 @@ class MODULES_EXPORT PaintWorkletGlobalScope final : public WorkletGlobalScope { void Trace(blink::Visitor*) override; private: - PaintWorkletGlobalScope(LocalFrame*, - std::unique_ptr<GlobalScopeCreationParams>, - WorkerReportingProxy&, - PaintWorkletPendingGeneratorRegistry*); + // Registers the global scope with a proxy client, if not already done. Only + // used for worklet-thread bound PaintWorkletGlobalScopes. + void RegisterWithProxyClientIfNeeded(); // The implementation of the "paint definition" concept: // https://drafts.css-houdini.org/css-paint-api/#paint-definition @@ -54,14 +67,24 @@ class MODULES_EXPORT PaintWorkletGlobalScope final : public WorkletGlobalScope { DefinitionMap; DefinitionMap paint_definitions_; - Member<PaintWorkletPendingGeneratorRegistry> pending_generator_registry_; + // Only used for main-thread bound PaintWorkletGlobalScopes. + // TODO(smcgruer): Move elsewhere for worklet-thread bound + // PaintWorkletGlobalScope. + Member<PaintWorkletPendingGeneratorRegistry> pending_generator_registry_ = + nullptr; + + // Tracks whether this PaintWorkletGlobalScope has been registered with a + // PaintWorkletProxyClient. Only used in worklet-thread bound + // PaintWorkletGlobalScopes. + bool registered_ = false; }; -DEFINE_TYPE_CASTS(PaintWorkletGlobalScope, - ExecutionContext, - context, - context->IsPaintWorkletGlobalScope(), - context.IsPaintWorkletGlobalScope()); +template <> +struct DowncastTraits<PaintWorkletGlobalScope> { + static bool AllowFrom(const ExecutionContext& context) { + return context.IsPaintWorkletGlobalScope(); + } +}; } // namespace blink |