| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 definition->enqueueConnectedCallback(element); | 207 definition->enqueueConnectedCallback(element); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void CustomElement::enqueueDisconnectedCallback(Element* element) | 210 void CustomElement::enqueueDisconnectedCallback(Element* element) |
| 211 { | 211 { |
| 212 CustomElementDefinition* definition = definitionForElementWithoutCheck(*elem
ent); | 212 CustomElementDefinition* definition = definitionForElementWithoutCheck(*elem
ent); |
| 213 if (definition->hasDisconnectedCallback()) | 213 if (definition->hasDisconnectedCallback()) |
| 214 definition->enqueueDisconnectedCallback(element); | 214 definition->enqueueDisconnectedCallback(element); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void CustomElement::enqueueAdoptedCallback(Element* element) | 217 void CustomElement::enqueueAdoptedCallback( |
| 218 Element* element, Document* oldOwner, Document* newOwner) |
| 218 { | 219 { |
| 219 DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom); | 220 DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom); |
| 220 CustomElementDefinition* definition = definitionForElementWithoutCheck(*elem
ent); | 221 CustomElementDefinition* definition = definitionForElementWithoutCheck(*elem
ent); |
| 221 if (definition->hasAdoptedCallback()) | 222 if (definition->hasAdoptedCallback()) |
| 222 definition->enqueueAdoptedCallback(element); | 223 definition->enqueueAdoptedCallback(element, oldOwner, newOwner); |
| 223 } | 224 } |
| 224 | 225 |
| 225 void CustomElement::enqueueAttributeChangedCallback(Element* element, | 226 void CustomElement::enqueueAttributeChangedCallback(Element* element, |
| 226 const QualifiedName& name, | 227 const QualifiedName& name, |
| 227 const AtomicString& oldValue, const AtomicString& newValue) | 228 const AtomicString& oldValue, const AtomicString& newValue) |
| 228 { | 229 { |
| 229 CustomElementDefinition* definition = definitionForElementWithoutCheck(*elem
ent); | 230 CustomElementDefinition* definition = definitionForElementWithoutCheck(*elem
ent); |
| 230 if (definition->hasAttributeChangedCallback(name)) | 231 if (definition->hasAttributeChangedCallback(name)) |
| 231 definition->enqueueAttributeChangedCallback(element, name, oldValue, new
Value); | 232 definition->enqueueAttributeChangedCallback(element, name, oldValue, new
Value); |
| 232 } | 233 } |
| 233 | 234 |
| 234 void CustomElement::tryToUpgrade(Element* element) | 235 void CustomElement::tryToUpgrade(Element* element) |
| 235 { | 236 { |
| 236 // Try to upgrade an element | 237 // Try to upgrade an element |
| 237 // https://html.spec.whatwg.org/multipage/scripting.html#concept-try-upgrade | 238 // https://html.spec.whatwg.org/multipage/scripting.html#concept-try-upgrade |
| 238 | 239 |
| 239 DCHECK_EQ(element->getCustomElementState(), CustomElementState::Undefined); | 240 DCHECK_EQ(element->getCustomElementState(), CustomElementState::Undefined); |
| 240 | 241 |
| 241 CustomElementRegistry* registry = CustomElement::registry(*element); | 242 CustomElementRegistry* registry = CustomElement::registry(*element); |
| 242 if (!registry) | 243 if (!registry) |
| 243 return; | 244 return; |
| 244 if (CustomElementDefinition* definition = registry->definitionForName(elemen
t->localName())) | 245 if (CustomElementDefinition* definition = registry->definitionForName(elemen
t->localName())) |
| 245 definition->enqueueUpgradeReaction(element); | 246 definition->enqueueUpgradeReaction(element); |
| 246 else | 247 else |
| 247 registry->addCandidate(element); | 248 registry->addCandidate(element); |
| 248 } | 249 } |
| 249 | 250 |
| 250 } // namespace blink | 251 } // namespace blink |
| OLD | NEW |