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

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

Issue 2170383002: CustomElements: adopt node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge conflict resolution 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/CustomElementDefinition.h" 5 #include "core/dom/custom/CustomElementDefinition.h"
6 6
7 #include "core/dom/Attr.h" 7 #include "core/dom/Attr.h"
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "core/dom/custom/CustomElement.h" 9 #include "core/dom/custom/CustomElement.h"
10 #include "core/dom/custom/CustomElementAdoptedCallbackReaction.h"
10 #include "core/dom/custom/CustomElementAttributeChangedCallbackReaction.h" 11 #include "core/dom/custom/CustomElementAttributeChangedCallbackReaction.h"
11 #include "core/dom/custom/CustomElementConnectedCallbackReaction.h" 12 #include "core/dom/custom/CustomElementConnectedCallbackReaction.h"
12 #include "core/dom/custom/CustomElementDisconnectedCallbackReaction.h" 13 #include "core/dom/custom/CustomElementDisconnectedCallbackReaction.h"
13 #include "core/dom/custom/CustomElementUpgradeReaction.h" 14 #include "core/dom/custom/CustomElementUpgradeReaction.h"
14 #include "core/html/HTMLElement.h" 15 #include "core/html/HTMLElement.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 CustomElementDefinition::CustomElementDefinition( 19 CustomElementDefinition::CustomElementDefinition(
19 const CustomElementDescriptor& descriptor) 20 const CustomElementDescriptor& descriptor)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 if (m_constructionStack.last().get()) 121 if (m_constructionStack.last().get())
121 DCHECK_EQ(m_constructionStack.last(), element); 122 DCHECK_EQ(m_constructionStack.last(), element);
122 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*. 123 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*.
123 m_constructionStack.removeLast(); 124 m_constructionStack.removeLast();
124 125
125 if (!succeeded) { 126 if (!succeeded) {
126 element->setCustomElementState(CustomElementState::Failed); 127 element->setCustomElementState(CustomElementState::Failed);
127 return; 128 return;
128 } 129 }
129 130
130 element->setCustomElementState(CustomElementState::Custom); 131 element->setCustomElementDefinition(this);
131 } 132 }
132 133
133 bool CustomElementDefinition::hasAttributeChangedCallback( 134 bool CustomElementDefinition::hasAttributeChangedCallback(
134 const QualifiedName& name) const 135 const QualifiedName& name) const
135 { 136 {
136 return m_observedAttributes.contains(name.localName()); 137 return m_observedAttributes.contains(name.localName());
137 } 138 }
138 139
139 bool CustomElementDefinition::hasStyleAttributeChangedCallback() const 140 bool CustomElementDefinition::hasStyleAttributeChangedCallback() const
140 { 141 {
(...skipping 11 matching lines...) Expand all
152 CustomElement::enqueue(element, 153 CustomElement::enqueue(element,
153 new CustomElementConnectedCallbackReaction(this)); 154 new CustomElementConnectedCallbackReaction(this));
154 } 155 }
155 156
156 void CustomElementDefinition::enqueueDisconnectedCallback(Element* element) 157 void CustomElementDefinition::enqueueDisconnectedCallback(Element* element)
157 { 158 {
158 CustomElement::enqueue(element, 159 CustomElement::enqueue(element,
159 new CustomElementDisconnectedCallbackReaction(this)); 160 new CustomElementDisconnectedCallbackReaction(this));
160 } 161 }
161 162
163 void CustomElementDefinition::enqueueAdoptedCallback(Element* element)
164 {
165 CustomElement::enqueue(element,
166 new CustomElementAdoptedCallbackReaction(this));
167 }
168
162 void CustomElementDefinition::enqueueAttributeChangedCallback(Element* element, 169 void CustomElementDefinition::enqueueAttributeChangedCallback(Element* element,
163 const QualifiedName& name, 170 const QualifiedName& name,
164 const AtomicString& oldValue, const AtomicString& newValue) 171 const AtomicString& oldValue, const AtomicString& newValue)
165 { 172 {
166 CustomElement::enqueue(element, 173 CustomElement::enqueue(element,
167 new CustomElementAttributeChangedCallbackReaction(this, name, 174 new CustomElementAttributeChangedCallbackReaction(this, name,
168 oldValue, newValue)); 175 oldValue, newValue));
169 } 176 }
170 177
171 void CustomElementDefinition::enqueueAttributeChangedCallbackForAllAttributes( 178 void CustomElementDefinition::enqueueAttributeChangedCallbackForAllAttributes(
172 Element* element) 179 Element* element)
173 { 180 {
174 // Avoid synchronizing all attributes unless it is needed, while enqueing 181 // Avoid synchronizing all attributes unless it is needed, while enqueing
175 // callbacks "in order" as defined in the spec. 182 // callbacks "in order" as defined in the spec.
176 // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an- element 183 // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an- element
177 for (const AtomicString& name : m_observedAttributes) 184 for (const AtomicString& name : m_observedAttributes)
178 element->synchronizeAttribute(name); 185 element->synchronizeAttribute(name);
179 for (const auto& attribute : element->attributesWithoutUpdate()) { 186 for (const auto& attribute : element->attributesWithoutUpdate()) {
180 if (hasAttributeChangedCallback(attribute.name())) { 187 if (hasAttributeChangedCallback(attribute.name())) {
181 enqueueAttributeChangedCallback(element, attribute.name(), 188 enqueueAttributeChangedCallback(element, attribute.name(),
182 nullAtom, attribute.value()); 189 nullAtom, attribute.value());
183 } 190 }
184 } 191 }
185 } 192 }
186 193
187 } // namespace blink 194 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698