Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Unified Diff: third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp

Issue 2840523002: [DONT COMMIT] Worklet: Implement "addModule()" algorithm for main thread worklets (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6f6df37d8250d48138820ae982ae82581bb2908d..32beb22d6783c30fc4e878851c470f8c66a4cc76 100644
--- a/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
+++ b/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
@@ -8,6 +8,7 @@
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
#include "modules/csspaint/PaintWorkletGlobalScope.h"
+#include "modules/csspaint/PaintWorkletGlobalScopeProxy.h"
namespace blink {
@@ -16,34 +17,50 @@ PaintWorklet* PaintWorklet::Create(LocalFrame* frame) {
return new PaintWorklet(frame);
}
-PaintWorklet::PaintWorklet(LocalFrame* frame)
- : MainThreadWorklet(frame),
- paint_worklet_global_scope_(PaintWorkletGlobalScope::Create(
- frame,
- frame->GetDocument()->Url(),
- frame->GetDocument()->UserAgent(),
- frame->GetDocument()->GetSecurityOrigin(),
- ToIsolate(frame->GetDocument()),
- this)) {}
+PaintWorklet::PaintWorklet(LocalFrame* frame) : MainThreadWorklet(frame) {}
PaintWorklet::~PaintWorklet() {}
-PaintWorkletGlobalScope* PaintWorklet::GetWorkletGlobalScopeProxy() const {
- return paint_worklet_global_scope_.Get();
-}
-
CSSPaintDefinition* PaintWorklet::FindDefinition(const String& name) {
- return paint_worklet_global_scope_->FindDefinition(name);
+ for (const auto& proxy : global_scope_proxies_) {
+ PaintWorkletGlobalScope* global_scope =
+ PaintWorkletGlobalScopeProxy::From(proxy.get())->global_scope();
+ CSSPaintDefinition* definition = global_scope->FindDefinition(name);
+ if (definition)
+ return definition;
nhiroki 2017/04/25 09:31:32 ikilpatrick@: I'm not sure how FindDefinition() sh
+ }
+ return nullptr;
}
void PaintWorklet::AddPendingGenerator(const String& name,
CSSPaintImageGeneratorImpl* generator) {
- return paint_worklet_global_scope_->AddPendingGenerator(name, generator);
+ for (const auto& proxy : global_scope_proxies_) {
+ PaintWorkletGlobalScope* global_scope =
+ PaintWorkletGlobalScopeProxy::From(proxy.get())->global_scope();
+ global_scope->AddPendingGenerator(name, generator);
nhiroki 2017/04/25 09:31:32 ikilpatrick@: ditto. Is it right to call this func
+ }
}
DEFINE_TRACE(PaintWorklet) {
- visitor->Trace(paint_worklet_global_scope_);
MainThreadWorklet::Trace(visitor);
}
+void PaintWorklet::CreateWorkletGlobalScope() {
+ MainThreadWorklet::CreateWorkletGlobalScope();
+
+ // Step 12: "Let workletGlobalScope be a PaintWorkletGlobalScope from the list
+ // of worklet' s WorkletGlobalScopes from the paint Worklet."
+ //
+ // "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.
+ std::unique_ptr<WorkletGlobalScopeProxy> proxy =
+ PaintWorkletGlobalScopeProxy::Create(frame_, this);
+ global_scope_proxies_.insert(std::move(proxy));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698