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/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" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // To create an element: | 93 // To create an element: |
94 // https://dom.spec.whatwg.org/#concept-create-element | 94 // https://dom.spec.whatwg.org/#concept-create-element |
95 // 6. If definition is non-null, then: | 95 // 6. If definition is non-null, then: |
96 HTMLElement* element; | 96 HTMLElement* element; |
97 if (CustomElementsRegistry* registry = CustomElement::registry(document)) { | 97 if (CustomElementsRegistry* registry = CustomElement::registry(document)) { |
98 if (CustomElementDefinition* definition = registry->definitionForName(ta
gName.localName())) { | 98 if (CustomElementDefinition* definition = registry->definitionForName(ta
gName.localName())) { |
99 // 6.2. If the synchronous custom elements flag is not set: | 99 // 6.2. If the synchronous custom elements flag is not set: |
100 if (flags & AsynchronousCustomElements) | 100 if (flags & AsynchronousCustomElements) |
101 return createCustomElementAsync(document, *definition, tagName); | 101 return createCustomElementAsync(document, *definition, tagName); |
102 | 102 |
103 // TODO(kojii): Synchronous mode implementation coming after async. | 103 // When invoked from "create an element for a token": |
| 104 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-elem
ent-for-the-token |
| 105 // 7. If this step throws an exception, then report the exception, |
| 106 // and let element be instead a new element that implements |
| 107 // HTMLUnknownElement. |
| 108 if (flags & CreatedByParser) |
| 109 return definition->createCustomElementIgnoringErrors(document, t
agName); |
| 110 |
| 111 // 6.1. If the synchronous custom elements flag is set: |
| 112 return definition->createCustomElement(document, tagName); |
104 } | 113 } |
105 } | 114 } |
106 | 115 |
107 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati
onContext()) { | 116 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati
onContext()) { |
108 Element* v0element = document.registrationContext()->createCustomTagElem
ent(document, tagName); | 117 Element* v0element = document.registrationContext()->createCustomTagElem
ent(document, tagName); |
109 SECURITY_DCHECK(v0element->isHTMLElement()); | 118 SECURITY_DCHECK(v0element->isHTMLElement()); |
110 element = toHTMLElement(v0element); | 119 element = toHTMLElement(v0element); |
111 } else { | 120 } else { |
112 element = HTMLElement::create(tagName, document); | 121 element = HTMLElement::create(tagName, document); |
113 } | 122 } |
(...skipping 24 matching lines...) Expand all Loading... |
138 void CustomElement::enqueueUpgradeReaction(Element* element, CustomElementDefini
tion* definition) | 147 void CustomElement::enqueueUpgradeReaction(Element* element, CustomElementDefini
tion* definition) |
139 { | 148 { |
140 // CEReactionsScope must be created by [CEReactions] in IDL, | 149 // CEReactionsScope must be created by [CEReactions] in IDL, |
141 // or callers must setup explicitly if it does not go through bindings. | 150 // or callers must setup explicitly if it does not go through bindings. |
142 DCHECK(CEReactionsScope::current()); | 151 DCHECK(CEReactionsScope::current()); |
143 CEReactionsScope::current()->enqueue(element, | 152 CEReactionsScope::current()->enqueue(element, |
144 new CustomElementUpgradeReaction(definition)); | 153 new CustomElementUpgradeReaction(definition)); |
145 } | 154 } |
146 | 155 |
147 } // namespace blink | 156 } // namespace blink |
OLD | NEW |