OLD | NEW |
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 Loading... |
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(const AtomicString& name) |
| 117 { |
| 118 CustomElementDefinition* definition = definitionForName(name); |
| 119 if (!definition) { |
| 120 // Binding layer converts |ScriptValue()| to script specific value, |
| 121 // e.g. |undefined| for v8. |
| 122 return ScriptValue(); |
| 123 } |
| 124 return definition->getConstructorForScript(); |
| 125 } |
| 126 |
115 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const | 127 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const |
116 { | 128 { |
117 if (!m_v0) | 129 if (!m_v0) |
118 return false; | 130 return false; |
119 return m_v0->nameIsDefined(name); | 131 return m_v0->nameIsDefined(name); |
120 } | 132 } |
121 | 133 |
122 CustomElementDefinition* CustomElementsRegistry::definitionForName( | 134 CustomElementDefinition* CustomElementsRegistry::definitionForName( |
123 const AtomicString& name) const | 135 const AtomicString& name) const |
124 { | 136 { |
125 return m_definitions.get(name); | 137 return m_definitions.get(name); |
126 } | 138 } |
127 | 139 |
128 } // namespace blink | 140 } // namespace blink |
OLD | NEW |