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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 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 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) { 126 void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) {
127 size_t index = m_distributedNodes.size(); 127 size_t index = m_distributedNodes.size();
128 m_distributedNodes.appendVector(other.m_distributedNodes); 128 m_distributedNodes.appendVector(other.m_distributedNodes);
129 for (const auto& node : other.m_distributedNodes) 129 for (const auto& node : other.m_distributedNodes)
130 m_distributedIndices.set(node.get(), index++); 130 m_distributedIndices.set(node.get(), index++);
131 } 131 }
132 132
133 void HTMLSlotElement::clearDistribution() { 133 void HTMLSlotElement::clearDistribution() {
134 // TODO(hayato): Figure out when to call lazyReattachDistributedNodesIfNeeded( ) 134 // TODO(hayato): Figure out when to call
135 // lazyReattachDistributedNodesIfNeeded()
135 m_assignedNodes.clear(); 136 m_assignedNodes.clear();
136 m_distributedNodes.clear(); 137 m_distributedNodes.clear();
137 m_distributedIndices.clear(); 138 m_distributedIndices.clear();
138 } 139 }
139 140
140 void HTMLSlotElement::saveAndClearDistribution() { 141 void HTMLSlotElement::saveAndClearDistribution() {
141 m_oldDistributedNodes.swap(m_distributedNodes); 142 m_oldDistributedNodes.swap(m_distributedNodes);
142 clearDistribution(); 143 clearDistribution();
143 } 144 }
144 145
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 214 }
214 215
215 Node::InsertionNotificationRequest HTMLSlotElement::insertedInto( 216 Node::InsertionNotificationRequest HTMLSlotElement::insertedInto(
216 ContainerNode* insertionPoint) { 217 ContainerNode* insertionPoint) {
217 HTMLElement::insertedInto(insertionPoint); 218 HTMLElement::insertedInto(insertionPoint);
218 ShadowRoot* root = containingShadowRoot(); 219 ShadowRoot* root = containingShadowRoot();
219 if (root) { 220 if (root) {
220 DCHECK(root->owner()); 221 DCHECK(root->owner());
221 root->owner()->setNeedsDistributionRecalc(); 222 root->owner()->setNeedsDistributionRecalc();
222 // Relevant DOM Standard: https://dom.spec.whatwg.org/#concept-node-insert 223 // Relevant DOM Standard: https://dom.spec.whatwg.org/#concept-node-insert
223 // - 6.4: Run assign slotables for a tree with node's tree and a set contai ning each inclusive descendant of node that is a slot. 224 // - 6.4: Run assign slotables for a tree with node's tree and a set
225 // containing each inclusive descendant of node that is a slot.
224 if (root->isV1() && !wasInShadowTreeBeforeInserted(*this, *insertionPoint)) 226 if (root->isV1() && !wasInShadowTreeBeforeInserted(*this, *insertionPoint))
225 root->ensureSlotAssignment().slotAdded(*this); 227 root->ensureSlotAssignment().slotAdded(*this);
226 } 228 }
227 229
228 // We could have been distributed into in a detached subtree, make sure to 230 // We could have been distributed into in a detached subtree, make sure to
229 // clear the distribution when inserted again to avoid cycles. 231 // clear the distribution when inserted again to avoid cycles.
230 clearDistribution(); 232 clearDistribution();
231 233
232 return InsertionDone; 234 return InsertionDone;
233 } 235 }
234 236
235 static ShadowRoot* containingShadowRootBeforeRemoved( 237 static ShadowRoot* containingShadowRootBeforeRemoved(
236 Node& removedDescendant, 238 Node& removedDescendant,
237 ContainerNode& insertionPoint) { 239 ContainerNode& insertionPoint) {
238 if (ShadowRoot* root = removedDescendant.containingShadowRoot()) 240 if (ShadowRoot* root = removedDescendant.containingShadowRoot())
239 return root; 241 return root;
240 return insertionPoint.containingShadowRoot(); 242 return insertionPoint.containingShadowRoot();
241 } 243 }
242 244
243 void HTMLSlotElement::removedFrom(ContainerNode* insertionPoint) { 245 void HTMLSlotElement::removedFrom(ContainerNode* insertionPoint) {
244 // `removedFrom` is called after the node is removed from the tree. 246 // `removedFrom` is called after the node is removed from the tree.
245 // That means: 247 // That means:
246 // 1. If this slot is still in a tree scope, it means the slot has been in a s hadow tree. An inclusive shadow-including ancestor of the shadow host was origin ally removed from its parent. 248 // 1. If this slot is still in a tree scope, it means the slot has been in a
247 // 2. Or (this slot is now not in a tree scope), this slot's inclusive ancesto r was orginally removed from its parent (== insertion point). This slot and the originally removed node was in the same tree. 249 // shadow tree. An inclusive shadow-including ancestor of the shadow host was
250 // originally removed from its parent.
251 // 2. Or (this slot is now not in a tree scope), this slot's inclusive
252 // ancestor was orginally removed from its parent (== insertion point). This
253 // slot and the originally removed node was in the same tree.
248 254
249 ShadowRoot* root = containingShadowRootBeforeRemoved(*this, *insertionPoint); 255 ShadowRoot* root = containingShadowRootBeforeRemoved(*this, *insertionPoint);
250 if (root) { 256 if (root) {
251 if (ElementShadow* rootOwner = root->owner()) 257 if (ElementShadow* rootOwner = root->owner())
252 rootOwner->setNeedsDistributionRecalc(); 258 rootOwner->setNeedsDistributionRecalc();
253 } 259 }
254 260
255 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. 261 // Since this insertion point is no longer visible from the shadow subtree, it
262 // need to clean itself up.
256 clearDistribution(); 263 clearDistribution();
257 264
258 if (root && root->isV1() && root == insertionPoint->treeScope().rootNode()) { 265 if (root && root->isV1() && root == insertionPoint->treeScope().rootNode()) {
259 // This slot was in a shadow tree and got disconnected from the shadow root. 266 // This slot was in a shadow tree and got disconnected from the shadow root.
260 root->ensureSlotAssignment().slotRemoved(*this); 267 root->ensureSlotAssignment().slotRemoved(*this);
261 } 268 }
262 269
263 HTMLElement::removedFrom(insertionPoint); 270 HTMLElement::removedFrom(insertionPoint);
264 } 271 }
265 272
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 if (!m_slotchangeEventEnqueued) { 310 if (!m_slotchangeEventEnqueued) {
304 Microtask::enqueueMicrotask(WTF::bind( 311 Microtask::enqueueMicrotask(WTF::bind(
305 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this))); 312 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
306 m_slotchangeEventEnqueued = true; 313 m_slotchangeEventEnqueued = true;
307 } 314 }
308 315
309 ShadowRoot* root = containingShadowRoot(); 316 ShadowRoot* root = containingShadowRoot();
310 DCHECK(root); 317 DCHECK(root);
311 DCHECK(root->isV1()); 318 DCHECK(root->isV1());
312 root->owner()->setNeedsDistributionRecalc(); 319 root->owner()->setNeedsDistributionRecalc();
313 // Check slotchange recursively since this slotchange may cause another slotch ange. 320 // Check slotchange recursively since this slotchange may cause another
321 // slotchange.
314 checkSlotChange(); 322 checkSlotChange();
315 } 323 }
316 324
317 bool HTMLSlotElement::hasAssignedNodesSlow() const { 325 bool HTMLSlotElement::hasAssignedNodesSlow() const {
318 ShadowRoot* root = containingShadowRoot(); 326 ShadowRoot* root = containingShadowRoot();
319 DCHECK(root); 327 DCHECK(root);
320 DCHECK(root->isV1()); 328 DCHECK(root->isV1());
321 SlotAssignment& assignment = root->ensureSlotAssignment(); 329 SlotAssignment& assignment = root->ensureSlotAssignment();
322 if (assignment.findSlotByName(name()) != this) 330 if (assignment.findSlotByName(name()) != this)
323 return false; 331 return false;
(...skipping 14 matching lines...) Expand all
338 346
339 DEFINE_TRACE(HTMLSlotElement) { 347 DEFINE_TRACE(HTMLSlotElement) {
340 visitor->trace(m_assignedNodes); 348 visitor->trace(m_assignedNodes);
341 visitor->trace(m_distributedNodes); 349 visitor->trace(m_distributedNodes);
342 visitor->trace(m_oldDistributedNodes); 350 visitor->trace(m_oldDistributedNodes);
343 visitor->trace(m_distributedIndices); 351 visitor->trace(m_distributedIndices);
344 HTMLElement::trace(visitor); 352 HTMLElement::trace(visitor);
345 } 353 }
346 354
347 } // namespace blink 355 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | third_party/WebKit/Source/core/html/HTMLTableColElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698