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

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

Issue 2896773002: [DONT COMMIT] PaintWorklet: Move paintWorklet from 'window' to 'CSS' (Closed)
Patch Set: WIP Created 3 years, 6 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 bef58fcd3961ed1343b2c1688bb99a3ec19f3298..68e84f233a3f679d40c58bb7337d2755e2d41b45 100644
--- a/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
+++ b/third_party/WebKit/Source/modules/csspaint/PaintWorklet.cpp
@@ -6,11 +6,23 @@
#include "bindings/core/v8/V8BindingForCore.h"
#include "core/dom/Document.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "modules/csspaint/PaintWorkletGlobalScope.h"
namespace blink {
+// static
+PaintWorklet* PaintWorklet::From(LocalDOMWindow& window) {
+ PaintWorklet* supplement = static_cast<PaintWorklet*>(
+ Supplement<LocalDOMWindow>::From(window, SupplementName()));
+ if (!supplement && window.GetFrame()) {
+ supplement = Create(window.GetFrame());
+ ProvideTo(window, SupplementName(), supplement);
+ }
+ return supplement;
+}
+
// static
PaintWorklet* PaintWorklet::Create(LocalFrame* frame) {
return new PaintWorklet(frame);
@@ -18,6 +30,7 @@ PaintWorklet* PaintWorklet::Create(LocalFrame* frame) {
PaintWorklet::PaintWorklet(LocalFrame* frame)
: Worklet(frame),
+ Supplement<LocalDOMWindow>(*frame->DomWindow()),
pending_generator_registry_(new PaintWorkletPendingGeneratorRegistry) {}
PaintWorklet::~PaintWorklet() = default;
@@ -36,9 +49,14 @@ void PaintWorklet::AddPendingGenerator(const String& name,
pending_generator_registry_->AddPendingGenerator(name, generator);
}
+const char* PaintWorklet::SupplementName() {
+ return "PaintWorklet";
+}
+
DEFINE_TRACE(PaintWorklet) {
visitor->Trace(pending_generator_registry_);
Worklet::Trace(visitor);
+ Supplement<LocalDOMWindow>::Trace(visitor);
}
bool PaintWorklet::NeedsToCreateGlobalScope() {

Powered by Google App Engine
This is Rietveld 408576698