| Index: third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
|
| diff --git a/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp b/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
|
| index 5631ede6909a80d6c746431a4abca10773172f2f..caf643b9ad97f10d12500141f47b78985d8d024d 100644
|
| --- a/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
|
| +++ b/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
|
| @@ -16,28 +16,42 @@ PaintWorklet* PaintWorklet::Create(LocalFrame* frame) {
|
| return new PaintWorklet(frame);
|
| }
|
|
|
| -PaintWorklet::PaintWorklet(LocalFrame* frame)
|
| - : MainThreadWorklet(frame),
|
| - global_scope_proxy_(
|
| - WTF::MakeUnique<PaintWorkletGlobalScopeProxy>(frame)) {}
|
| +PaintWorklet::PaintWorklet(LocalFrame* frame) : MainThreadWorklet(frame) {}
|
|
|
| PaintWorklet::~PaintWorklet() = default;
|
|
|
| -WorkletGlobalScopeProxy* PaintWorklet::GetWorkletGlobalScopeProxy() const {
|
| - return global_scope_proxy_.get();
|
| -}
|
| -
|
| CSSPaintDefinition* PaintWorklet::FindDefinition(const String& name) {
|
| - return global_scope_proxy_->FindDefinition(name);
|
| + // TODO(nhiroki): Support the case where there are multiple global scopes.
|
| + DCHECK_EQ(1u, global_scope_proxies_.size());
|
| + PaintWorkletGlobalScopeProxy* proxy =
|
| + PaintWorkletGlobalScopeProxy::From(global_scope_proxies_.begin()->get());
|
| + return proxy->FindDefinition(name);
|
| }
|
|
|
| void PaintWorklet::AddPendingGenerator(const String& name,
|
| CSSPaintImageGeneratorImpl* generator) {
|
| - return global_scope_proxy_->AddPendingGenerator(name, generator);
|
| + // TODO(nhiroki): Support the case where there are multiple global scopes.
|
| + DCHECK_EQ(1u, global_scope_proxies_.size());
|
| + PaintWorkletGlobalScopeProxy* proxy =
|
| + PaintWorkletGlobalScopeProxy::From(global_scope_proxies_.begin()->get());
|
| + return proxy->AddPendingGenerator(name, generator);
|
| }
|
|
|
| DEFINE_TRACE(PaintWorklet) {
|
| MainThreadWorklet::Trace(visitor);
|
| }
|
|
|
| +void PaintWorklet::AddWorkletGlobalScopesIfNeeded() {
|
| + // "The user agent must have, and select from at least two
|
| + // PaintWorkletGlobalScopes in the worklet's WorkletGlobalScopes list, unless
|
| + // the user agent is under memory constraints."
|
| + // https://drafts.css-houdini.org/css-paint-api-1/#drawing-an-image
|
| + // TODO(nhiroki): Create at least two global scopes.
|
| + if (!global_scope_proxies_.IsEmpty())
|
| + return;
|
| + std::unique_ptr<WorkletGlobalScopeProxy> proxy =
|
| + WTF::MakeUnique<PaintWorkletGlobalScopeProxy>(frame_);
|
| + global_scope_proxies_.insert(std::move(proxy));
|
| +}
|
| +
|
| } // namespace blink
|
|
|