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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h

Issue 2003593003: Make CustomElementsRegistry lazily initialize script state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/core/dom/custom/CustomElementsRegistry.h
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h
index de7d2aaa98ccb722181a7683df4dfefd92421b95..1973aa24a8e76a0233cd78c8551d3af57079a7a2 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h
@@ -29,9 +29,8 @@ class CORE_EXPORT CustomElementsRegistry final
DEFINE_WRAPPERTYPEINFO();
public:
using Id = uint32_t;
- static CustomElementsRegistry* create(
- ScriptState*,
- V0CustomElementRegistrationContext*);
+
+ static CustomElementsRegistry* create(V0CustomElementRegistrationContext*);
void define(
ScriptState*,
@@ -55,10 +54,15 @@ public:
private:
CustomElementsRegistry(const V0CustomElementRegistrationContext*);
+ void ensureScriptInitialized(ScriptState* scriptState)
+ {
+ if (State::ScriptNotInitialized == m_state)
+ initializeScript(scriptState);
+ }
+ void initializeScript(ScriptState*);
+
// Retrieves the Map which, given a constructor, contains the id
// of the definition; or given an id, contains the prototype.
- // Returns true if the map was retrieved; false if the map was
- // not initialized yet.
v8::Local<v8::Map> idMap(ScriptState*);
bool idForConstructor(
@@ -68,6 +72,12 @@ private:
bool v0NameIsDefined(const AtomicString& name);
+ enum class State {
esprehn 2016/05/21 01:47:02 We should be able to null check something instead,
+ ScriptNotInitialized,
+ ScriptInitialized
+ };
+ State m_state;
+
Member<const V0CustomElementRegistrationContext> m_v0;
HeapVector<Member<CustomElementDefinition>> m_definitions;
HashSet<AtomicString> m_names;

Powered by Google App Engine
This is Rietveld 408576698