| 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( |
| 117 ScriptState* scriptState, |
| 118 const AtomicString& name) |
| 119 { |
| 120 CustomElementDefinition* definition = definitionForName(name); |
| 121 if (!definition) |
| 122 return ScriptValue(scriptState, v8Undefined()); |
| 123 return definition->getConstructor(scriptState); |
| 124 } |
| 125 |
| 115 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const | 126 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const |
| 116 { | 127 { |
| 117 if (!m_v0) | 128 if (!m_v0) |
| 118 return false; | 129 return false; |
| 119 return m_v0->nameIsDefined(name); | 130 return m_v0->nameIsDefined(name); |
| 120 } | 131 } |
| 121 | 132 |
| 122 CustomElementDefinition* CustomElementsRegistry::definitionForName( | 133 CustomElementDefinition* CustomElementsRegistry::definitionForName( |
| 123 const AtomicString& name) const | 134 const AtomicString& name) const |
| 124 { | 135 { |
| 125 return m_definitions.get(name); | 136 return m_definitions.get(name); |
| 126 } | 137 } |
| 127 | 138 |
| 128 } // namespace blink | 139 } // namespace blink |
| OLD | NEW |