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

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

Issue 2166213002: Fire attributeChangedCallback on style changes for Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dominicc review Created 4 years, 5 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/CustomElementAttributeChangedCallbackReaction.h" 10 #include "core/dom/custom/CustomElementAttributeChangedCallbackReaction.h"
11 #include "core/dom/custom/CustomElementConnectedCallbackReaction.h" 11 #include "core/dom/custom/CustomElementConnectedCallbackReaction.h"
12 #include "core/dom/custom/CustomElementDisconnectedCallbackReaction.h" 12 #include "core/dom/custom/CustomElementDisconnectedCallbackReaction.h"
13 #include "core/dom/custom/CustomElementUpgradeReaction.h" 13 #include "core/dom/custom/CustomElementUpgradeReaction.h"
14 #include "core/html/HTMLElement.h" 14 #include "core/html/HTMLElement.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 CustomElementDefinition::CustomElementDefinition( 18 CustomElementDefinition::CustomElementDefinition(
19 const CustomElementDescriptor& descriptor) 19 const CustomElementDescriptor& descriptor)
20 : m_descriptor(descriptor) 20 : m_descriptor(descriptor)
21 { 21 {
22 } 22 }
23 23
24 CustomElementDefinition::CustomElementDefinition( 24 CustomElementDefinition::CustomElementDefinition(
25 const CustomElementDescriptor& descriptor, 25 const CustomElementDescriptor& descriptor,
26 const HashSet<AtomicString>& observedAttributes) 26 const HashSet<AtomicString>& observedAttributes)
27 : m_observedAttributes(observedAttributes) 27 : m_descriptor(descriptor)
28 , m_descriptor(descriptor) 28 , m_observedAttributes(observedAttributes)
29 , m_hasStyleAttributeChangedCallback(
30 observedAttributes.contains(HTMLNames::styleAttr.localName()))
29 { 31 {
30 } 32 }
31 33
32 CustomElementDefinition::~CustomElementDefinition() 34 CustomElementDefinition::~CustomElementDefinition()
33 { 35 {
34 } 36 }
35 37
36 DEFINE_TRACE(CustomElementDefinition) 38 DEFINE_TRACE(CustomElementDefinition)
37 { 39 {
38 visitor->trace(m_constructionStack); 40 visitor->trace(m_constructionStack);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*. 122 DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*.
121 m_constructionStack.removeLast(); 123 m_constructionStack.removeLast();
122 124
123 if (!succeeded) 125 if (!succeeded)
124 return; 126 return;
125 127
126 CHECK(element->getCustomElementState() == CustomElementState::Custom); 128 CHECK(element->getCustomElementState() == CustomElementState::Custom);
127 } 129 }
128 130
129 bool CustomElementDefinition::hasAttributeChangedCallback( 131 bool CustomElementDefinition::hasAttributeChangedCallback(
130 const QualifiedName& name) 132 const QualifiedName& name) const
131 { 133 {
132 return m_observedAttributes.contains(name.localName()); 134 return m_observedAttributes.contains(name.localName());
133 } 135 }
134 136
137 bool CustomElementDefinition::hasStyleAttributeChangedCallback() const
138 {
139 return m_hasStyleAttributeChangedCallback;
140 }
141
135 void CustomElementDefinition::enqueueUpgradeReaction(Element* element) 142 void CustomElementDefinition::enqueueUpgradeReaction(Element* element)
136 { 143 {
137 CustomElement::enqueue(element, 144 CustomElement::enqueue(element,
138 new CustomElementUpgradeReaction(this)); 145 new CustomElementUpgradeReaction(this));
139 } 146 }
140 147
141 void CustomElementDefinition::enqueueConnectedCallback(Element* element) 148 void CustomElementDefinition::enqueueConnectedCallback(Element* element)
142 { 149 {
143 CustomElement::enqueue(element, 150 CustomElement::enqueue(element,
144 new CustomElementConnectedCallbackReaction(this)); 151 new CustomElementConnectedCallbackReaction(this));
(...skipping 24 matching lines...) Expand all
169 element->synchronizeAttribute(name); 176 element->synchronizeAttribute(name);
170 for (const auto& attribute : element->attributesWithoutUpdate()) { 177 for (const auto& attribute : element->attributesWithoutUpdate()) {
171 if (hasAttributeChangedCallback(attribute.name())) { 178 if (hasAttributeChangedCallback(attribute.name())) {
172 enqueueAttributeChangedCallback(element, attribute.name(), 179 enqueueAttributeChangedCallback(element, attribute.name(),
173 nullAtom, attribute.value()); 180 nullAtom, attribute.value());
174 } 181 }
175 } 182 }
176 } 183 }
177 184
178 } // namespace blink 185 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698