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

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

Issue 2420043002: Stop re-signaling a slotchange event (Closed)
Patch Set: rebased Created 4 years, 1 month 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/Source/core/html/HTMLSlotElement.h ('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 /* 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (m_oldDistributedNodes != m_distributedNodes) { 308 if (m_oldDistributedNodes != m_distributedNodes) {
309 for (auto& node : m_oldDistributedNodes) 309 for (auto& node : m_oldDistributedNodes)
310 node->lazyReattachIfAttached(); 310 node->lazyReattachIfAttached();
311 for (auto& node : m_distributedNodes) 311 for (auto& node : m_distributedNodes)
312 node->lazyReattachIfAttached(); 312 node->lazyReattachIfAttached();
313 InspectorInstrumentation::didPerformSlotDistribution(this); 313 InspectorInstrumentation::didPerformSlotDistribution(this);
314 } 314 }
315 m_oldDistributedNodes.clear(); 315 m_oldDistributedNodes.clear();
316 } 316 }
317 317
318 void HTMLSlotElement::enqueueSlotChangeEvent() { 318 void HTMLSlotElement::didSlotChange(SlotChangeType slotChangeType) {
319 if (!m_slotchangeEventEnqueued) { 319 if (slotChangeType == SlotChangeType::Initial)
320 Microtask::enqueueMicrotask(WTF::bind( 320 enqueueSlotChangeEvent();
321 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
322 m_slotchangeEventEnqueued = true;
323 }
324
325 ShadowRoot* root = containingShadowRoot(); 321 ShadowRoot* root = containingShadowRoot();
326 // TODO(hayato): Relax this check if slots in non-shadow trees are well 322 // TODO(hayato): Relax this check if slots in non-shadow trees are well
327 // supported. 323 // supported.
328 DCHECK(root); 324 DCHECK(root);
329 DCHECK(root->isV1()); 325 DCHECK(root->isV1());
330 root->owner()->setNeedsDistributionRecalc(); 326 root->owner()->setNeedsDistributionRecalc();
331 // Check slotchange recursively since this slotchange may cause another 327 // Check slotchange recursively since this slotchange may cause another
332 // slotchange. 328 // slotchange.
333 checkSlotChange(); 329 checkSlotChange(SlotChangeType::Chained);
330 }
331
332 void HTMLSlotElement::enqueueSlotChangeEvent() {
333 if (m_slotchangeEventEnqueued)
334 return;
335 Microtask::enqueueMicrotask(WTF::bind(
336 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
337 m_slotchangeEventEnqueued = true;
334 } 338 }
335 339
336 bool HTMLSlotElement::hasAssignedNodesSlow() const { 340 bool HTMLSlotElement::hasAssignedNodesSlow() const {
337 ShadowRoot* root = containingShadowRoot(); 341 ShadowRoot* root = containingShadowRoot();
338 DCHECK(root); 342 DCHECK(root);
339 DCHECK(root->isV1()); 343 DCHECK(root->isV1());
340 SlotAssignment& assignment = root->ensureSlotAssignment(); 344 SlotAssignment& assignment = root->ensureSlotAssignment();
341 if (assignment.findSlotByName(name()) != this) 345 if (assignment.findSlotByName(name()) != this)
342 return false; 346 return false;
343 return assignment.findHostChildBySlotName(name()); 347 return assignment.findHostChildBySlotName(name());
(...skipping 13 matching lines...) Expand all
357 361
358 DEFINE_TRACE(HTMLSlotElement) { 362 DEFINE_TRACE(HTMLSlotElement) {
359 visitor->trace(m_assignedNodes); 363 visitor->trace(m_assignedNodes);
360 visitor->trace(m_distributedNodes); 364 visitor->trace(m_distributedNodes);
361 visitor->trace(m_oldDistributedNodes); 365 visitor->trace(m_oldDistributedNodes);
362 visitor->trace(m_distributedIndices); 366 visitor->trace(m_distributedIndices);
363 HTMLElement::trace(visitor); 367 HTMLElement::trace(visitor);
364 } 368 }
365 369
366 } // namespace blink 370 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698