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

Side by Side 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-31T18:12:12 Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/custom/CustomElementsRegistry.h" 5 #include "core/dom/custom/CustomElementsRegistry.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptCustomElementDefinitionBuilder.h" 8 #include "bindings/core/v8/ScriptCustomElementDefinitionBuilder.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ElementRegistrationOptions.h" 10 #include "core/dom/ElementRegistrationOptions.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 CHECK(!exceptionState.hadException()); 105 CHECK(!exceptionState.hadException());
106 CHECK(definition->descriptor() == descriptor); 106 CHECK(definition->descriptor() == descriptor);
107 DefinitionMap::AddResult result = 107 DefinitionMap::AddResult result =
108 m_definitions.add(descriptor.name(), definition); 108 m_definitions.add(descriptor.name(), definition);
109 CHECK(result.isNewEntry); 109 CHECK(result.isNewEntry);
110 110
111 // TODO(dominicc): Implement steps: 111 // TODO(dominicc): Implement steps:
112 // 20: when-defined promise processing 112 // 20: when-defined promise processing
113 } 113 }
114 114
115 // https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsregis try-get
116 ScriptValue CustomElementsRegistry::get(
117 ScriptState* scriptState,
118 const AtomicString& name)
119 {
120 CustomElementDefinition* definition = definitionForName(name);
121 if (!definition) {
122 // Binding layer converts |ScriptValue()| to script specific value,
dominicc (has gone to gerrit) 2016/05/31 22:56:32 Love this comment. Short and specific.
123 // e.g. |undefined| for v8.
124 return ScriptValue();
125 }
126 return definition->getConstructor(scriptState);
127 }
128
115 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const 129 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const
116 { 130 {
117 if (!m_v0) 131 if (!m_v0)
118 return false; 132 return false;
119 return m_v0->nameIsDefined(name); 133 return m_v0->nameIsDefined(name);
120 } 134 }
121 135
122 CustomElementDefinition* CustomElementsRegistry::definitionForName( 136 CustomElementDefinition* CustomElementsRegistry::definitionForName(
123 const AtomicString& name) const 137 const AtomicString& name) const
124 { 138 {
125 return m_definitions.get(name); 139 return m_definitions.get(name);
126 } 140 }
127 141
128 } // namespace blink 142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698