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

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

Issue 1994093002: Introduce CustomElementRegistry#get() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-05-19T17:33:00 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.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp
index 6163dced4530d47532ca1639222c3e9ac9f85fd2..a6206a8d2eb053bf3e4b4cdddf4e1596182502f5 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp
@@ -137,7 +137,7 @@ void CustomElementsRegistry::define(ScriptState* scriptState,
// The map keeps the constructor and prototypes alive.
v8CallOrCrash(map->Set(context, constructor, idValue));
v8CallOrCrash(map->Set(context, idValue, prototype));
- m_names.add(name);
+ m_names.add(name, id);
// TODO(dominicc): Implement steps:
// 20: when-defined promise processing
@@ -154,6 +154,19 @@ CustomElementDefinition* CustomElementsRegistry::definitionForConstructor(
return m_definitions[id];
}
+// http://w3c.github.io/webcomponents/spec/custom/#dom-customelementsregistry-get
kojii 2016/05/19 10:04:32 It's already old, should be: https://html.spec.wha
yosin_UTC9 2016/05/23 04:45:06 Done
+ScriptValue CustomElementsRegistry::get(
+ ScriptState* scriptState, const AtomicString& name) const
+{
+ const auto& it = m_names.find(name);
+ if (it == m_names.end())
+ return ScriptValue(scriptState, v8Undefined());
+ v8::Local<v8::Context> context = scriptState->context();
dominicc (has gone to gerrit) 2016/05/19 22:12:10 You should CHECK that scriptState->world().isMainW
+ v8::Local<v8::Map> map = idMap(scriptState);
+ v8::Local<v8::Value> idValue = toV8(it->value, scriptState);
+ return ScriptValue(scriptState, v8CallOrCrash(map->Get(context, idValue)));
dominicc (has gone to gerrit) 2016/05/19 22:12:10 I believe this is the prototype; not the construct
+}
+
v8::Local<v8::Object> CustomElementsRegistry::prototype(
ScriptState* scriptState,
const CustomElementDefinition& def)
@@ -170,7 +183,7 @@ bool CustomElementsRegistry::nameIsDefined(const AtomicString& name) const
return m_names.contains(name);
}
-v8::Local<v8::Map> CustomElementsRegistry::idMap(ScriptState* scriptState)
+v8::Local<v8::Map> CustomElementsRegistry::idMap(ScriptState* scriptState) const
{
DCHECK(scriptState->world().isMainWorld());
v8::Local<v8::Object> wrapper =

Powered by Google App Engine
This is Rietveld 408576698