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

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

Issue 2420043002: Stop re-signaling a slotchange event (Closed)
Patch Set: New slotchange behavior 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (m_oldDistributedNodes != m_distributedNodes) { 302 if (m_oldDistributedNodes != m_distributedNodes) {
303 for (auto& node : m_oldDistributedNodes) 303 for (auto& node : m_oldDistributedNodes)
304 node->lazyReattachIfAttached(); 304 node->lazyReattachIfAttached();
305 for (auto& node : m_distributedNodes) 305 for (auto& node : m_distributedNodes)
306 node->lazyReattachIfAttached(); 306 node->lazyReattachIfAttached();
307 InspectorInstrumentation::didPerformSlotDistribution(this); 307 InspectorInstrumentation::didPerformSlotDistribution(this);
308 } 308 }
309 m_oldDistributedNodes.clear(); 309 m_oldDistributedNodes.clear();
310 } 310 }
311 311
312 void HTMLSlotElement::enqueueSlotChangeEvent() { 312 void HTMLSlotElement::didSlotChange(SlotChangeType slotChangeType) {
313 if (!m_slotchangeEventEnqueued) { 313 if (slotChangeType == SlotChangeType::Initial)
314 Microtask::enqueueMicrotask(WTF::bind( 314 enqueueSlotChangeEvent();
315 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
316 m_slotchangeEventEnqueued = true;
317 }
318
319 ShadowRoot* root = containingShadowRoot(); 315 ShadowRoot* root = containingShadowRoot();
320 DCHECK(root); 316 DCHECK(root);
321 DCHECK(root->isV1()); 317 DCHECK(root->isV1());
322 root->owner()->setNeedsDistributionRecalc(); 318 root->owner()->setNeedsDistributionRecalc();
323 // Check slotchange recursively since this slotchange may cause another 319 // Check slotchange recursively since this slotchange may cause another
324 // slotchange. 320 // slotchange.
325 checkSlotChange(); 321 checkSlotChange(SlotChangeType::Chained);
322 }
323
324 void HTMLSlotElement::enqueueSlotChangeEvent() {
325 if (m_slotchangeEventEnqueued)
326 return;
327 Microtask::enqueueMicrotask(WTF::bind(
328 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
329 m_slotchangeEventEnqueued = true;
326 } 330 }
327 331
328 bool HTMLSlotElement::hasAssignedNodesSlow() const { 332 bool HTMLSlotElement::hasAssignedNodesSlow() const {
329 ShadowRoot* root = containingShadowRoot(); 333 ShadowRoot* root = containingShadowRoot();
330 DCHECK(root); 334 DCHECK(root);
331 DCHECK(root->isV1()); 335 DCHECK(root->isV1());
332 SlotAssignment& assignment = root->ensureSlotAssignment(); 336 SlotAssignment& assignment = root->ensureSlotAssignment();
333 if (assignment.findSlotByName(name()) != this) 337 if (assignment.findSlotByName(name()) != this)
334 return false; 338 return false;
335 return assignment.findHostChildBySlotName(name()); 339 return assignment.findHostChildBySlotName(name());
(...skipping 13 matching lines...) Expand all
349 353
350 DEFINE_TRACE(HTMLSlotElement) { 354 DEFINE_TRACE(HTMLSlotElement) {
351 visitor->trace(m_assignedNodes); 355 visitor->trace(m_assignedNodes);
352 visitor->trace(m_distributedNodes); 356 visitor->trace(m_distributedNodes);
353 visitor->trace(m_oldDistributedNodes); 357 visitor->trace(m_oldDistributedNodes);
354 visitor->trace(m_distributedIndices); 358 visitor->trace(m_distributedIndices);
355 HTMLElement::trace(visitor); 359 HTMLElement::trace(visitor);
356 } 360 }
357 361
358 } // namespace blink 362 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698