| 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/CustomElementDefinition.h" | 10 #include "core/dom/custom/CustomElementDefinition.h" |
| 11 #include "core/dom/custom/CustomElementReactionStack.h" |
| 10 #include "core/dom/custom/CustomElementsRegistry.h" | 12 #include "core/dom/custom/CustomElementsRegistry.h" |
| 11 #include "core/dom/custom/V0CustomElement.h" | 13 #include "core/dom/custom/V0CustomElement.h" |
| 12 #include "core/dom/custom/V0CustomElementRegistrationContext.h" | 14 #include "core/dom/custom/V0CustomElementRegistrationContext.h" |
| 15 #include "core/frame/FrameHost.h" |
| 13 #include "core/frame/LocalDOMWindow.h" | 16 #include "core/frame/LocalDOMWindow.h" |
| 14 #include "core/html/HTMLElement.h" | 17 #include "core/html/HTMLElement.h" |
| 15 #include "platform/text/Character.h" | 18 #include "platform/text/Character.h" |
| 16 #include "wtf/text/AtomicStringHash.h" | 19 #include "wtf/text/AtomicStringHash.h" |
| 17 | 20 |
| 18 namespace blink { | 21 namespace blink { |
| 19 | 22 |
| 20 CustomElementsRegistry* CustomElement::registry(const Element& element) | 23 CustomElementsRegistry* CustomElement::registry(const Element& element) |
| 21 { | 24 { |
| 22 return registry(element.document()); | 25 return registry(element.document()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 element = toHTMLElement(v0element); | 155 element = toHTMLElement(v0element); |
| 153 } else { | 156 } else { |
| 154 element = HTMLElement::create(tagName, document); | 157 element = HTMLElement::create(tagName, document); |
| 155 } | 158 } |
| 156 | 159 |
| 157 element->setCustomElementState(CustomElementState::Undefined); | 160 element->setCustomElementState(CustomElementState::Undefined); |
| 158 | 161 |
| 159 return element; | 162 return element; |
| 160 } | 163 } |
| 161 | 164 |
| 165 void CustomElement::enqueue(Element* element, CustomElementReaction* reaction) |
| 166 { |
| 167 // To enqueue an element on the appropriate element queue |
| 168 // https://html.spec.whatwg.org/multipage/scripting.html#enqueue-an-element-
on-the-appropriate-element-queue |
| 169 |
| 170 // If the custom element reactions stack is not empty, then |
| 171 // Add element to the current element queue. |
| 172 if (CEReactionsScope* current = CEReactionsScope::current()) { |
| 173 current->enqueueToCurrentQueue(element, reaction); |
| 174 return; |
| 175 } |
| 176 |
| 177 // If the custom element reactions stack is empty, then |
| 178 // Add element to the backup element queue. |
| 179 element->document().frameHost()->customElementReactionStack() |
| 180 .enqueueToBackupQueue(element, reaction); |
| 181 } |
| 182 |
| 162 void CustomElement::enqueueConnectedCallback(Element* element) | 183 void CustomElement::enqueueConnectedCallback(Element* element) |
| 163 { | 184 { |
| 164 DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom); | 185 DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom); |
| 165 CustomElementDefinition* definition = definitionForElement(*element); | 186 CustomElementDefinition* definition = definitionForElement(*element); |
| 166 if (definition->hasConnectedCallback()) | 187 if (definition->hasConnectedCallback()) |
| 167 definition->enqueueConnectedCallback(element); | 188 definition->enqueueConnectedCallback(element); |
| 168 } | 189 } |
| 169 | 190 |
| 170 void CustomElement::enqueueDisconnectedCallback(Element* element) | 191 void CustomElement::enqueueDisconnectedCallback(Element* element) |
| 171 { | 192 { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 196 CustomElementsRegistry* registry = CustomElement::registry(*element); | 217 CustomElementsRegistry* registry = CustomElement::registry(*element); |
| 197 if (!registry) | 218 if (!registry) |
| 198 return; | 219 return; |
| 199 if (CustomElementDefinition* definition = registry->definitionForName(elemen
t->localName())) | 220 if (CustomElementDefinition* definition = registry->definitionForName(elemen
t->localName())) |
| 200 definition->enqueueUpgradeReaction(element); | 221 definition->enqueueUpgradeReaction(element); |
| 201 else | 222 else |
| 202 registry->addCandidate(element); | 223 registry->addCandidate(element); |
| 203 } | 224 } |
| 204 | 225 |
| 205 } // namespace blink | 226 } // namespace blink |
| OLD | NEW |