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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp

Issue 2085853004: Force reattach all shadow host's children (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/shadow-dom/layout-update-on-slotassignment.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/NodeTraversal.h" 9 #include "core/dom/NodeTraversal.h"
10 #include "core/dom/shadow/ElementShadow.h" 10 #include "core/dom/shadow/ElementShadow.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 SlotAssignment::SlotAssignment(ShadowRoot& owner) 102 SlotAssignment::SlotAssignment(ShadowRoot& owner)
103 : m_slotMap(DocumentOrderedMap::create()) 103 : m_slotMap(DocumentOrderedMap::create())
104 , m_owner(&owner) 104 , m_owner(&owner)
105 , m_needsCollectSlots(false) 105 , m_needsCollectSlots(false)
106 , m_slotCount(0) 106 , m_slotCount(0)
107 { 107 {
108 } 108 }
109 109
110 static void detachNotAssignedNode(Node& node)
111 {
112 if (node.layoutObject())
113 node.lazyReattachIfAttached();
114 }
115
116 void SlotAssignment::resolveAssignment() 110 void SlotAssignment::resolveAssignment()
117 { 111 {
118 for (Member<HTMLSlotElement> slot : slots()) 112 for (Member<HTMLSlotElement> slot : slots())
119 slot->clearDistribution(); 113 slot->clearDistribution();
120 114
121 for (Node& child : NodeTraversal::childrenOf(m_owner->host())) { 115 for (Node& child : NodeTraversal::childrenOf(m_owner->host())) {
122 if (!child.isSlotable()) { 116 if (child.layoutObject())
123 detachNotAssignedNode(child); 117 child.lazyReattachIfAttached();
118 if (!child.isSlotable())
124 continue; 119 continue;
125 }
126 HTMLSlotElement* slot = findSlotByName(child.slotName()); 120 HTMLSlotElement* slot = findSlotByName(child.slotName());
127 if (slot) 121 if (slot)
128 slot->appendAssignedNode(child); 122 slot->appendAssignedNode(child);
129 else
130 detachNotAssignedNode(child);
131 } 123 }
132 } 124 }
133 125
134 void SlotAssignment::resolveDistribution() 126 void SlotAssignment::resolveDistribution()
135 { 127 {
136 resolveAssignment(); 128 resolveAssignment();
137 const HeapVector<Member<HTMLSlotElement>>& slots = this->slots(); 129 const HeapVector<Member<HTMLSlotElement>>& slots = this->slots();
138 130
139 for (auto slot : slots) 131 for (auto slot : slots)
140 slot->resolveDistributedNodes(); 132 slot->resolveDistributedNodes();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 167 }
176 168
177 DEFINE_TRACE(SlotAssignment) 169 DEFINE_TRACE(SlotAssignment)
178 { 170 {
179 visitor->trace(m_slots); 171 visitor->trace(m_slots);
180 visitor->trace(m_slotMap); 172 visitor->trace(m_slotMap);
181 visitor->trace(m_owner); 173 visitor->trace(m_owner);
182 } 174 }
183 175
184 } // namespace blink 176 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/shadow-dom/layout-update-on-slotassignment.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698