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

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

Issue 2173623003: Add "Failed" custom element state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid multiple toElement Created 4 years, 4 months 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/CustomElement.h" 5 #include "core/dom/custom/CustomElement.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/QualifiedName.h" 8 #include "core/dom/QualifiedName.h"
9 #include "core/dom/custom/CEReactionsScope.h" 9 #include "core/dom/custom/CEReactionsScope.h"
10 #include "core/dom/custom/CustomElementDefinition.h" 10 #include "core/dom/custom/CustomElementDefinition.h"
11 #include "core/dom/custom/CustomElementReactionStack.h" 11 #include "core/dom/custom/CustomElementReactionStack.h"
12 #include "core/dom/custom/CustomElementsRegistry.h" 12 #include "core/dom/custom/CustomElementsRegistry.h"
13 #include "core/dom/custom/V0CustomElement.h" 13 #include "core/dom/custom/V0CustomElement.h"
14 #include "core/dom/custom/V0CustomElementRegistrationContext.h" 14 #include "core/dom/custom/V0CustomElementRegistrationContext.h"
15 #include "core/frame/FrameHost.h" 15 #include "core/frame/FrameHost.h"
16 #include "core/frame/LocalDOMWindow.h" 16 #include "core/frame/LocalDOMWindow.h"
17 #include "core/html/HTMLElement.h" 17 #include "core/html/HTMLElement.h"
18 #include "core/html/HTMLUnknownElement.h"
18 #include "platform/text/Character.h" 19 #include "platform/text/Character.h"
19 #include "wtf/text/AtomicStringHash.h" 20 #include "wtf/text/AtomicStringHash.h"
20 21
21 namespace blink { 22 namespace blink {
22 23
23 CustomElementsRegistry* CustomElement::registry(const Element& element) 24 CustomElementsRegistry* CustomElement::registry(const Element& element)
24 { 25 {
25 return registry(element.document()); 26 return registry(element.document());
26 } 27 }
27 28
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 element = toHTMLElement(v0element); 162 element = toHTMLElement(v0element);
162 } else { 163 } else {
163 element = HTMLElement::create(tagName, document); 164 element = HTMLElement::create(tagName, document);
164 } 165 }
165 166
166 element->setCustomElementState(CustomElementState::Undefined); 167 element->setCustomElementState(CustomElementState::Undefined);
167 168
168 return element; 169 return element;
169 } 170 }
170 171
172 HTMLElement* CustomElement::createFailedElement(Document& document, const Qualif iedName& tagName)
173 {
174 DCHECK(shouldCreateCustomElement(document, tagName));
175
176 // "create an element for a token":
177 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for- the-token
178
179 // 7. If this step throws an exception, let element be instead a new element
180 // that implements HTMLUnknownElement, with no attributes, namespace set to
181 // given namespace, namespace prefix set to null, custom element state set
182 // to "failed", and node document set to document.
183
184 HTMLElement* element = HTMLUnknownElement::create(tagName, document);
185 element->setCustomElementState(CustomElementState::Failed);
186 return element;
187 }
188
171 void CustomElement::enqueue(Element* element, CustomElementReaction* reaction) 189 void CustomElement::enqueue(Element* element, CustomElementReaction* reaction)
172 { 190 {
173 // To enqueue an element on the appropriate element queue 191 // To enqueue an element on the appropriate element queue
174 // https://html.spec.whatwg.org/multipage/scripting.html#enqueue-an-element- on-the-appropriate-element-queue 192 // https://html.spec.whatwg.org/multipage/scripting.html#enqueue-an-element- on-the-appropriate-element-queue
175 193
176 // If the custom element reactions stack is not empty, then 194 // If the custom element reactions stack is not empty, then
177 // Add element to the current element queue. 195 // Add element to the current element queue.
178 if (CEReactionsScope* current = CEReactionsScope::current()) { 196 if (CEReactionsScope* current = CEReactionsScope::current()) {
179 current->enqueueToCurrentQueue(element, reaction); 197 current->enqueueToCurrentQueue(element, reaction);
180 return; 198 return;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 CustomElementsRegistry* registry = CustomElement::registry(*element); 238 CustomElementsRegistry* registry = CustomElement::registry(*element);
221 if (!registry) 239 if (!registry)
222 return; 240 return;
223 if (CustomElementDefinition* definition = registry->definitionForName(elemen t->localName())) 241 if (CustomElementDefinition* definition = registry->definitionForName(elemen t->localName()))
224 definition->enqueueUpgradeReaction(element); 242 definition->enqueueUpgradeReaction(element);
225 else 243 else
226 registry->addCandidate(element); 244 registry->addCandidate(element);
227 } 245 }
228 246
229 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698