| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 "this name has already been used with this registry"); | 77 "this name has already been used with this registry"); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (!builder.checkConstructorNotRegistered()) | 81 if (!builder.checkConstructorNotRegistered()) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 // TODO(dominicc): Implement steps: | 84 // TODO(dominicc): Implement steps: |
| 85 // 5: localName | 85 // 5: localName |
| 86 // 6-7: extends processing | 86 // 6-7: extends processing |
| 87 // 8-9: observed attributes caching | 87 |
| 88 // 8-9: observed attributes caching is done below, together with callbacks. |
| 88 | 89 |
| 89 // TODO(dominicc): Add a test where the prototype getter destroys | 90 // TODO(dominicc): Add a test where the prototype getter destroys |
| 90 // the context. | 91 // the context. |
| 91 | 92 |
| 92 if (!builder.checkPrototype()) | 93 if (!builder.checkPrototype()) |
| 93 return; | 94 return; |
| 94 | 95 |
| 95 // TODO(dominicc): Implement steps: | 96 // 8-9: observed attributes caching |
| 96 // 12-13: connected callback | 97 // 12-13: connected callback |
| 97 // 14-15: disconnected callback | 98 // 14-15: disconnected callback |
| 98 // 16-17: attribute changed callback | 99 // 16-17: attribute changed callback |
| 99 | 100 |
| 101 if (!builder.cacheProperties()) |
| 102 return; |
| 103 |
| 100 // TODO(dominicc): Add a test where retrieving the prototype | 104 // TODO(dominicc): Add a test where retrieving the prototype |
| 101 // recursively calls define with the same name. | 105 // recursively calls define with the same name. |
| 102 | 106 |
| 103 CustomElementDescriptor descriptor(name, name); | 107 CustomElementDescriptor descriptor(name, name); |
| 104 CustomElementDefinition* definition = builder.build(descriptor); | 108 CustomElementDefinition* definition = builder.build(descriptor); |
| 105 CHECK(!exceptionState.hadException()); | 109 CHECK(!exceptionState.hadException()); |
| 106 CHECK(definition->descriptor() == descriptor); | 110 CHECK(definition->descriptor() == descriptor); |
| 107 DefinitionMap::AddResult result = | 111 DefinitionMap::AddResult result = |
| 108 m_definitions.add(descriptor.name(), definition); | 112 m_definitions.add(descriptor.name(), definition); |
| 109 CHECK(result.isNewEntry); | 113 CHECK(result.isNewEntry); |
| 110 | 114 |
| 111 // TODO(dominicc): Implement steps: | 115 // TODO(dominicc): Implement steps: |
| 112 // 20: when-defined promise processing | 116 // 20: when-defined promise processing |
| 113 } | 117 } |
| 114 | 118 |
| 115 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const | 119 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const |
| 116 { | 120 { |
| 117 if (!m_v0) | 121 if (!m_v0) |
| 118 return false; | 122 return false; |
| 119 return m_v0->nameIsDefined(name); | 123 return m_v0->nameIsDefined(name); |
| 120 } | 124 } |
| 121 | 125 |
| 122 CustomElementDefinition* CustomElementsRegistry::definitionForName( | 126 CustomElementDefinition* CustomElementsRegistry::definitionForName( |
| 123 const AtomicString& name) const | 127 const AtomicString& name) const |
| 124 { | 128 { |
| 125 return m_definitions.get(name); | 129 return m_definitions.get(name); |
| 126 } | 130 } |
| 127 | 131 |
| 128 } // namespace blink | 132 } // namespace blink |
| OLD | NEW |