| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shadow/SlotAssignment.h" | 5 #include "core/dom/shadow/SlotAssignment.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
| 9 #include "core/dom/Node.h" | 9 #include "core/dom/Node.h" |
| 10 #include "core/dom/NodeTraversal.h" | 10 #include "core/dom/NodeTraversal.h" |
| 11 #include "core/dom/shadow/ElementShadow.h" | 11 #include "core/dom/shadow/ElementShadow.h" |
| 12 #include "core/dom/shadow/InsertionPoint.h" | 12 #include "core/dom/shadow/InsertionPoint.h" |
| 13 #include "core/dom/shadow/ShadowRoot.h" | 13 #include "core/dom/shadow/ShadowRoot.h" |
| 14 #include "core/html/HTMLSlotElement.h" | 14 #include "core/html/HTMLSlotElement.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 void SlotAssignment::slotAdded(HTMLSlotElement& slot) { | 18 void SlotAssignment::didAddSlot(HTMLSlotElement& slot) { |
| 19 // Relevant DOM Standard: | 19 // Relevant DOM Standard: |
| 20 // https://dom.spec.whatwg.org/#concept-node-insert | 20 // https://dom.spec.whatwg.org/#concept-node-insert |
| 21 // 6.4: Run assign slotables for a tree with node's tree and a set containing | 21 // 6.4: Run assign slotables for a tree with node's tree and a set containing |
| 22 // each inclusive descendant of node that is a slot. | 22 // each inclusive descendant of node that is a slot. |
| 23 | 23 |
| 24 ++m_slotCount; | 24 ++m_slotCount; |
| 25 m_needsCollectSlots = true; | 25 m_needsCollectSlots = true; |
| 26 | 26 |
| 27 if (!m_slotMap->contains(slot.name())) { | 27 if (!m_slotMap->contains(slot.name())) { |
| 28 m_slotMap->add(slot.name(), &slot); | 28 m_slotMap->add(slot.name(), &slot); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 m_slotMap->remove(oldSlotName, &slot); | 84 m_slotMap->remove(oldSlotName, &slot); |
| 85 m_slotMap->add(slot.name(), &slot); | 85 m_slotMap->add(slot.name(), &slot); |
| 86 | 86 |
| 87 bool hasAssignedNodesAfter = slot.hasAssignedNodesSlow(); | 87 bool hasAssignedNodesAfter = slot.hasAssignedNodesSlow(); |
| 88 | 88 |
| 89 if (hasAssignedNodesBefore || hasAssignedNodesAfter) | 89 if (hasAssignedNodesBefore || hasAssignedNodesAfter) |
| 90 slot.didSlotChange(SlotChangeType::Initial); | 90 slot.didSlotChange(SlotChangeType::Initial); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SlotAssignment::hostChildSlotNameChanged(const AtomicString& oldValue, | 93 void SlotAssignment::didChangeHostChildSlotName(const AtomicString& oldValue, |
| 94 const AtomicString& newValue) { | 94 const AtomicString& newValue) { |
| 95 if (HTMLSlotElement* slot = | 95 if (HTMLSlotElement* slot = |
| 96 findSlotByName(HTMLSlotElement::normalizeSlotName(oldValue))) { | 96 findSlotByName(HTMLSlotElement::normalizeSlotName(oldValue))) { |
| 97 slot->didSlotChange(SlotChangeType::Initial); | 97 slot->didSlotChange(SlotChangeType::Initial); |
| 98 m_owner->owner()->setNeedsDistributionRecalc(); | 98 m_owner->owner()->setNeedsDistributionRecalc(); |
| 99 } | 99 } |
| 100 if (HTMLSlotElement* slot = | 100 if (HTMLSlotElement* slot = |
| 101 findSlotByName(HTMLSlotElement::normalizeSlotName(newValue))) { | 101 findSlotByName(HTMLSlotElement::normalizeSlotName(newValue))) { |
| 102 slot->didSlotChange(SlotChangeType::Initial); | 102 slot->didSlotChange(SlotChangeType::Initial); |
| 103 m_owner->owner()->setNeedsDistributionRecalc(); | 103 m_owner->owner()->setNeedsDistributionRecalc(); |
| 104 } | 104 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 DCHECK_EQ(m_slots.size(), m_slotCount); | 176 DCHECK_EQ(m_slots.size(), m_slotCount); |
| 177 } | 177 } |
| 178 | 178 |
| 179 DEFINE_TRACE(SlotAssignment) { | 179 DEFINE_TRACE(SlotAssignment) { |
| 180 visitor->trace(m_slots); | 180 visitor->trace(m_slots); |
| 181 visitor->trace(m_slotMap); | 181 visitor->trace(m_slotMap); |
| 182 visitor->trace(m_owner); | 182 visitor->trace(m_owner); |
| 183 } | 183 } |
| 184 | 184 |
| 185 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |