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. |
| 89 // TODO(kojii): https://github.com/whatwg/html/issues/1373 for the ordering. |
| 90 // When it's resolved, revisit if this code needs changes. |
88 | 91 |
89 // TODO(dominicc): Add a test where the prototype getter destroys | 92 // TODO(dominicc): Add a test where the prototype getter destroys |
90 // the context. | 93 // the context. |
91 | 94 |
92 if (!builder.checkPrototype()) | 95 if (!builder.checkPrototype()) |
93 return; | 96 return; |
94 | 97 |
95 // TODO(dominicc): Implement steps: | 98 // 8-9: observed attributes caching |
96 // 12-13: connected callback | 99 // 12-13: connected callback |
97 // 14-15: disconnected callback | 100 // 14-15: disconnected callback |
98 // 16-17: attribute changed callback | 101 // 16-17: attribute changed callback |
99 | 102 |
| 103 if (!builder.cacheProperties()) |
| 104 return; |
| 105 |
100 // TODO(dominicc): Add a test where retrieving the prototype | 106 // TODO(dominicc): Add a test where retrieving the prototype |
101 // recursively calls define with the same name. | 107 // recursively calls define with the same name. |
102 | 108 |
103 CustomElementDescriptor descriptor(name, name); | 109 CustomElementDescriptor descriptor(name, name); |
104 CustomElementDefinition* definition = builder.build(descriptor); | 110 CustomElementDefinition* definition = builder.build(descriptor); |
105 CHECK(!exceptionState.hadException()); | 111 CHECK(!exceptionState.hadException()); |
106 CHECK(definition->descriptor() == descriptor); | 112 CHECK(definition->descriptor() == descriptor); |
107 DefinitionMap::AddResult result = | 113 DefinitionMap::AddResult result = |
108 m_definitions.add(descriptor.name(), definition); | 114 m_definitions.add(descriptor.name(), definition); |
109 CHECK(result.isNewEntry); | 115 CHECK(result.isNewEntry); |
110 | 116 |
111 // TODO(dominicc): Implement steps: | 117 // TODO(dominicc): Implement steps: |
112 // 20: when-defined promise processing | 118 // 20: when-defined promise processing |
113 } | 119 } |
114 | 120 |
115 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const | 121 bool CustomElementsRegistry::v0NameIsDefined(const AtomicString& name) const |
116 { | 122 { |
117 if (!m_v0) | 123 if (!m_v0) |
118 return false; | 124 return false; |
119 return m_v0->nameIsDefined(name); | 125 return m_v0->nameIsDefined(name); |
120 } | 126 } |
121 | 127 |
122 CustomElementDefinition* CustomElementsRegistry::definitionForName( | 128 CustomElementDefinition* CustomElementsRegistry::definitionForName( |
123 const AtomicString& name) const | 129 const AtomicString& name) const |
124 { | 130 { |
125 return m_definitions.get(name); | 131 return m_definitions.get(name); |
126 } | 132 } |
127 | 133 |
128 } // namespace blink | 134 } // namespace blink |
OLD | NEW |