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

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

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: fix layout test failures Created 3 years, 7 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/PaintWorkletGlobalScope.cpp
diff --git a/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp b/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp
index 20c8688b9b8949bd3a2610b857ddb814d70c7b69..64318718a9bdbd9aafbd056c9828f4704ac82d35 100644
--- a/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp
+++ b/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp
@@ -45,7 +45,8 @@ PaintWorkletGlobalScope::PaintWorkletGlobalScope(
url,
user_agent,
std::move(security_origin),
- isolate) {}
+ isolate),
+ pending_generator_registry_(new PaintWorkletPendingGeneratorRegistry) {}
PaintWorkletGlobalScope::~PaintWorkletGlobalScope() {}
@@ -193,17 +194,7 @@ void PaintWorkletGlobalScope::registerPaint(const String& name,
native_invalidation_properties, custom_invalidation_properties,
input_argument_types, has_alpha);
paint_definitions_.Set(name, definition);
-
- // Set the definition on any pending generators.
- GeneratorHashSet* set = pending_generators_.at(name);
- if (set) {
- for (const auto& generator : *set) {
- if (generator) {
- generator->SetDefinition(definition);
- }
- }
- }
- pending_generators_.erase(name);
+ pending_generator_registry_->SetDefinition(name, definition);
}
CSSPaintDefinition* PaintWorkletGlobalScope::FindDefinition(
@@ -214,16 +205,12 @@ CSSPaintDefinition* PaintWorkletGlobalScope::FindDefinition(
void PaintWorkletGlobalScope::AddPendingGenerator(
const String& name,
CSSPaintImageGeneratorImpl* generator) {
- Member<GeneratorHashSet>& set =
- pending_generators_.insert(name, nullptr).stored_value->value;
- if (!set)
- set = new GeneratorHashSet;
- set->insert(generator);
+ pending_generator_registry_->AddPendingGenerator(name, generator);
}
DEFINE_TRACE(PaintWorkletGlobalScope) {
visitor->Trace(paint_definitions_);
- visitor->Trace(pending_generators_);
+ visitor->Trace(pending_generator_registry_);
MainThreadWorkletGlobalScope::Trace(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698