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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp

Issue 2424693002: Custom Elements: Complete HTMLConstructor Algorithm (Closed)
Patch Set: Redefinition guard Created 4 years, 1 month 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/CustomElementRegistry.h" 5 #include "core/dom/custom/CustomElementRegistry.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 "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
11 #include "core/HTMLElementTypeHelpers.h"
11 #include "core/dom/Document.h" 12 #include "core/dom/Document.h"
12 #include "core/dom/Element.h" 13 #include "core/dom/Element.h"
13 #include "core/dom/ElementDefinitionOptions.h" 14 #include "core/dom/ElementDefinitionOptions.h"
14 #include "core/dom/ExceptionCode.h" 15 #include "core/dom/ExceptionCode.h"
15 #include "core/dom/custom/CEReactionsScope.h" 16 #include "core/dom/custom/CEReactionsScope.h"
16 #include "core/dom/custom/CustomElement.h" 17 #include "core/dom/custom/CustomElement.h"
17 #include "core/dom/custom/CustomElementDefinition.h" 18 #include "core/dom/custom/CustomElementDefinition.h"
18 #include "core/dom/custom/CustomElementDefinitionBuilder.h" 19 #include "core/dom/custom/CustomElementDefinitionBuilder.h"
19 #include "core/dom/custom/CustomElementDescriptor.h" 20 #include "core/dom/custom/CustomElementDescriptor.h"
20 #include "core/dom/custom/CustomElementUpgradeReaction.h" 21 #include "core/dom/custom/CustomElementUpgradeReaction.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (nameIsDefined(name) || v0NameIsDefined(name)) { 113 if (nameIsDefined(name) || v0NameIsDefined(name)) {
113 exceptionState.throwDOMException( 114 exceptionState.throwDOMException(
114 NotSupportedError, 115 NotSupportedError,
115 "this name has already been used with this registry"); 116 "this name has already been used with this registry");
116 return; 117 return;
117 } 118 }
118 119
119 if (!builder.checkConstructorNotRegistered()) 120 if (!builder.checkConstructorNotRegistered())
120 return; 121 return;
121 122
123 AtomicString localName = name;
124
122 // Step 7. customized built-in elements definition 125 // Step 7. customized built-in elements definition
123 // element interface extends option checks 126 // element interface extends option checks
124 if (RuntimeEnabledFeatures::customElementsBuiltinEnabled() && 127 if (RuntimeEnabledFeatures::customElementsBuiltinEnabled() &&
125 options.hasExtends()) { 128 options.hasExtends()) {
126 // If element interface is valid custom element name, throw exception 129 // 7.1. If element interface is valid custom element name, throw exception
130 const AtomicString& extends = AtomicString(options.extends());
127 if (throwIfValidName(AtomicString(options.extends()), exceptionState)) 131 if (throwIfValidName(AtomicString(options.extends()), exceptionState))
128 return; 132 return;
129 // If element interface is undefined element, throw exception 133 // 7.2. If element interface is undefined element, throw exception
130 // Set localname to extends 134 if (htmlElementTypeForTag(extends) ==
135 HTMLElementType::kHTMLUnknownElement) {
136 exceptionState.throwDOMException(
137 NotSupportedError, "\"" + extends + "\" is an HTMLUnknownElement");
138 return;
139 }
140 // 7.3. Set localName to extends
141 localName = extends;
131 } 142 }
132 143
133 // TODO(dominicc): Add a test where the prototype getter destroys 144 // TODO(dominicc): Add a test where the prototype getter destroys
134 // the context. 145 // the context.
135 146
136 // 8. If this CustomElementRegistry's element definition is 147 // 8. If this CustomElementRegistry's element definition is
137 // running flag is set, then throw a "NotSupportedError" 148 // running flag is set, then throw a "NotSupportedError"
138 // DOMException and abort these steps. 149 // DOMException and abort these steps.
139 if (m_elementDefinitionIsRunning) { 150 if (m_elementDefinitionIsRunning) {
140 exceptionState.throwDOMException( 151 exceptionState.throwDOMException(
(...skipping 14 matching lines...) Expand all
155 if (!builder.rememberOriginalProperties()) 166 if (!builder.rememberOriginalProperties())
156 return; 167 return;
157 168
158 // "Then, perform the following substep, regardless of whether 169 // "Then, perform the following substep, regardless of whether
159 // the above steps threw an exception or not: Unset this 170 // the above steps threw an exception or not: Unset this
160 // CustomElementRegistry's element definition is running 171 // CustomElementRegistry's element definition is running
161 // flag." 172 // flag."
162 // (ElementDefinitionIsRunning destructor does this.) 173 // (ElementDefinitionIsRunning destructor does this.)
163 } 174 }
164 175
165 CustomElementDescriptor descriptor(name, name); 176 CustomElementDescriptor descriptor(name, localName);
166 CustomElementDefinition* definition = builder.build(descriptor); 177 CustomElementDefinition* definition = builder.build(descriptor);
167 CHECK(!exceptionState.hadException()); 178 CHECK(!exceptionState.hadException());
168 CHECK(definition->descriptor() == descriptor); 179 CHECK(definition->descriptor() == descriptor);
169 DefinitionMap::AddResult result = 180 DefinitionMap::AddResult result =
170 m_definitions.add(descriptor.name(), definition); 181 m_definitions.add(descriptor.name(), definition);
171 CHECK(result.isNewEntry); 182 CHECK(result.isNewEntry);
172 183
173 HeapVector<Member<Element>> candidates; 184 HeapVector<Member<Element>> candidates;
174 collectCandidates(descriptor, &candidates); 185 collectCandidates(descriptor, &candidates);
175 for (Element* candidate : candidates) 186 for (Element* candidate : candidates)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 m_upgradeCandidates->remove(it); 289 m_upgradeCandidates->remove(it);
279 290
280 Document* document = m_owner->document(); 291 Document* document = m_owner->document();
281 if (!document) 292 if (!document)
282 return; 293 return;
283 294
284 sorter.sorted(elements, document); 295 sorter.sorted(elements, document);
285 } 296 }
286 297
287 } // namespace blink 298 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/interface.h.tmpl ('k') | third_party/WebKit/Source/core/html/HTMLDivElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698