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

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

Issue 2299033005: Pass the old and new owner documents to the adoptedCallback. (Closed)
Patch Set: WTF_ARRAY_LENGTH Created 4 years, 3 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/CustomElementAdoptedCallbackReaction.h"
11 #include "core/dom/custom/CustomElementAttributeChangedCallbackReaction.h" 11 #include "core/dom/custom/CustomElementAttributeChangedCallbackReaction.h"
12 #include "core/dom/custom/CustomElementConnectedCallbackReaction.h" 12 #include "core/dom/custom/CustomElementConnectedCallbackReaction.h"
13 #include "core/dom/custom/CustomElementDisconnectedCallbackReaction.h" 13 #include "core/dom/custom/CustomElementDisconnectedCallbackReaction.h"
14 #include "core/dom/custom/CustomElementReaction.h"
14 #include "core/dom/custom/CustomElementUpgradeReaction.h" 15 #include "core/dom/custom/CustomElementUpgradeReaction.h"
15 #include "core/html/HTMLElement.h" 16 #include "core/html/HTMLElement.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 CustomElementDefinition::CustomElementDefinition( 20 CustomElementDefinition::CustomElementDefinition(
20 const CustomElementDescriptor& descriptor) 21 const CustomElementDescriptor& descriptor)
21 : m_descriptor(descriptor) 22 : m_descriptor(descriptor)
22 { 23 {
23 } 24 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 CustomElement::enqueue(element, 183 CustomElement::enqueue(element,
183 new CustomElementConnectedCallbackReaction(this)); 184 new CustomElementConnectedCallbackReaction(this));
184 } 185 }
185 186
186 void CustomElementDefinition::enqueueDisconnectedCallback(Element* element) 187 void CustomElementDefinition::enqueueDisconnectedCallback(Element* element)
187 { 188 {
188 CustomElement::enqueue(element, 189 CustomElement::enqueue(element,
189 new CustomElementDisconnectedCallbackReaction(this)); 190 new CustomElementDisconnectedCallbackReaction(this));
190 } 191 }
191 192
192 void CustomElementDefinition::enqueueAdoptedCallback(Element* element) 193 void CustomElementDefinition::enqueueAdoptedCallback(
194 Element* element, Document* oldDocument, Document* newDocument)
193 { 195 {
194 CustomElement::enqueue(element, 196 CustomElementReaction* reaction =
195 new CustomElementAdoptedCallbackReaction(this)); 197 new CustomElementAdoptedCallbackReaction(this, oldDocument, newDocument) ;
198 CustomElement::enqueue(element, reaction);
196 } 199 }
197 200
198 void CustomElementDefinition::enqueueAttributeChangedCallback(Element* element, 201 void CustomElementDefinition::enqueueAttributeChangedCallback(Element* element,
199 const QualifiedName& name, 202 const QualifiedName& name,
200 const AtomicString& oldValue, const AtomicString& newValue) 203 const AtomicString& oldValue, const AtomicString& newValue)
201 { 204 {
202 CustomElement::enqueue(element, 205 CustomElement::enqueue(element,
203 new CustomElementAttributeChangedCallbackReaction(this, name, 206 new CustomElementAttributeChangedCallbackReaction(this, name,
204 oldValue, newValue)); 207 oldValue, newValue));
205 } 208 }
206 209
207 void CustomElementDefinition::enqueueAttributeChangedCallbackForAllAttributes( 210 void CustomElementDefinition::enqueueAttributeChangedCallbackForAllAttributes(
208 Element* element) 211 Element* element)
209 { 212 {
210 // Avoid synchronizing all attributes unless it is needed, while enqueing 213 // Avoid synchronizing all attributes unless it is needed, while enqueing
211 // callbacks "in order" as defined in the spec. 214 // callbacks "in order" as defined in the spec.
212 // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an- element 215 // https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an- element
213 for (const AtomicString& name : m_observedAttributes) 216 for (const AtomicString& name : m_observedAttributes)
214 element->synchronizeAttribute(name); 217 element->synchronizeAttribute(name);
215 for (const auto& attribute : element->attributesWithoutUpdate()) { 218 for (const auto& attribute : element->attributesWithoutUpdate()) {
216 if (hasAttributeChangedCallback(attribute.name())) { 219 if (hasAttributeChangedCallback(attribute.name())) {
217 enqueueAttributeChangedCallback(element, attribute.name(), 220 enqueueAttributeChangedCallback(element, attribute.name(),
218 nullAtom, attribute.value()); 221 nullAtom, attribute.value());
219 } 222 }
220 } 223 }
221 } 224 }
222 225
223 } // namespace blink 226 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698